安装:
tar -zxvf redis-3.2.6.tar.gz
cd redis-3.2.6
make
make install
cd utils/
sh install_server.sh
自定义路径安装:
解压
cd redis-3.2.6
make
cd src
make install PREFIX=/opt/redis
mkdir /opt/redis/etc
cp redis.conf /opt/redis/etc
vim /opt/redis/etc/redis.conf
将daemonize的值改为yes 让其在后台运行
启动:/opt/redis/bin/redis-server /opt/redis/etc/redis.conf
修改密码参考下面
主:
配置密码:
vim /etc/redis/6379.conf
requirepass root123456.
从:
配置密码、配置主地址端口、配置连接密码:
vim /etc/redis/6379.conf
requirepass root123456.
slaveof 192.168.0.250 6379
masterauth root123456.
设置密码后需要修改stop的脚本,不然无法stop redis服务
注意防火墙端口是否开放或者是否关闭防火墙,否则会影响数据同步
主从都一定要设置密码,不然存在很大的安全隐患