一、redis三台集群服务器上传压缩包
链接:https://pan.baidu.com/s/1EXDEVhaNzMxZmN12GiyKHg 提取码:bmov
二、redis-master部署
运行下述命令部署:
unzip redis4.0.14.zip
useradd redis
mv redis4.0.14 /home/redis/
mkdir -p /data/redis/redis6379
chown -R redis.redis /data/redis /home/redis/redis4.0.14
chmod 775 /home/redis/redis4.0.14/redis4/bin/*
HISTCONTROL=ignorespace
sed -i 's/# requirepass foobared/requirepass test@haha123/g' /home/redis/redis4.0.14/redis4/redis.conf
su redis -c '/home/redis/redis4.0.14/redis4/bin/redis-server /home/redis/redis4.0.14/redis4/redis.conf'
##配置开机自启动
chmod +x /etc/rc.d/rc.local
grep "redis-server" /etc/rc.d/rc.local > /dev/null
echo "su redis -c '/home/redis/redis4.0.14/redis4/bin/redis-server /home/redis/redis4.0.14/redis4/redis.conf'" >> /etc/rc.d/rc.local
三、redis-slave部署:
运行下述命令部署——(slave1、slave2运行命令一样)
下述IP为redis--master对应IP
unzip redis4.0.14.zip
useradd redis
mv redis4.0.14 /home/redis/
mkdir -p /data/redis/redis6379
chown -R redis.redis /data/redis /home/redis/redis4.0.14
chmod 775 /home/redis/redis4.0.14/redis4/bin/*
HISTCONTROL=ignorespace
sed -i 's/# requirepass foobared/requirepass test@haha123/g' /home/redis/redis4.0.14/redis4/redis.conf
su redis -c 'sed -i "s/# masterauth <master-password>/masterauth test@haha123/g" /home/redis/redis4.0.14/redis4/redis.conf'
su redis -c '/home/redis/redis4.0.14/redis4/bin/redis-server /home/redis/redis4.0.14/redis4/redis.conf'
su redis -c "/home/redis/redis4.0.14/redis4/bin/redis-cli -a "test@haha123" slaveof 172.30.12.30 6379"
##配置开机自启动
chmod +x /etc/rc.d/rc.local
grep "redis-server" /etc/rc.d/rc.local > /dev/null
echo "su redis -c '/home/redis/redis4.0.14/redis4/bin/redis-server /home/redis/redis4.0.14/redis4/redis.conf'" >> /etc/rc.d/rc.local