Redis的安装部署
1.目录规划
redis 下载目录
/data/soft/
redis 安装目录
/opt/redis_cluster/redis_{PORT}/{conf,logs,pid}
redis 数据目录
/data/redis_cluster/redis_{PORT}/redis_{PORT}.rdb
redis 运维脚本
/root/scripts/redis_shell.sh
2.安装操作命令
mkdir -p /data/redis_cluster/redis_6379
mkdir -p /opt/redis_cluster/redis_6379/{conf,pid,logs}
cd /data/soft/
wget http://download.redis.io/releases/redis-3.2.9.tar.gz
tar zxf redis-3.2.9.tar.gz -C /opt/redis_cluster/
ln -s /opt/redis_cluster/redis-3.2.9/ /opt/redis_cluster/redis
cd /opt/redis_cluster/redis
make && make install
3.配置文件
cd /opt/redis_cluster/redis_6379/conf/
cat >redis_6379.conf <<EOF
daemonize yes
bind 10.0.0.51
port 6379
pidfile /opt/redis_cluster/redis_6379/pid/redis_6379.pid
logfile /opt/redis_cluster/redis_6379/logs/redis_6379.log
databases 16
dbfilename redis_6379.rdb
dir /data/redis_cluster/redis_6379
EOF
4.启动
redis-server /opt/redis_cluster/redis_6379/conf/redis_6379.conf
5.检查
ps -ef|grep redis
netstat -lntup|grep 6379
6.配置hosts文件
cat >/etc/hosts<<EOF
10.0.0.51 db01
10.0.0.52 db02
10.0.0.53 db03
EOF
7.测试
[root@db-01 ~]# redis-cli -h db01
[root@db-01 ~]# redis-cli -h db01
db01:6379> set k1 v1
OK
db01:6379> get k1
"v1"
db01:6379>