一 实验环境
二 实验步骤
2.1 Redis Cluster集群搭建
略
2.2 在Predixy服务器上安装Redis单实例
可点击这里下载shell安装脚本
2.3 安装Predixy
点击这里下载predixy安装包
2.3.1 安装依赖包
yum install libstdc++-static gcc-c++ automake autoconf -y
2.3.2 编译
cd /usr/local/src && tar -zxvf predixy-1.0.5.tar.gz
cd predixy-1.0.5
make -j4
cd src && cp predixy /usr/local/bin/
2.3.3 修改配置文件
cd /usr/local/src/predixy-1.0.5/conf
2.3.3.1 cluster.conf
添加:
ClusterServerPool {
Password 要连接的redis集群的密码
MasterReadPriority 60
StaticSlaveReadPriority 50
DynamicSlaveReadPriority 50
RefreshInterval 1
ServerTimeout 1
ServerFailureLimit 10
ServerRetryTimeout 1
KeepAlive 120
Servers {
+ 192.168.144.201:6379
+ 192.168.144.201:6380
+ 192.168.144.202:6379
+ 192.168.144.202:6380
+ 192.168.144.203:6379
+ 192.168.144.203:6380
}
}
2.3.3.2 predixy.conf
① 将LogNoticeSample改为0,否则日志文件会很大(会记录每个连接创建,连接退出等信息)
② 在最后添加:
Include /usr/local/src/predixy-1.0.5/conf/cluster.conf
Log /usr/local/src/predixy-1.0.5/predixy.log
2.3.3.3 auth.conf
mv auth.conf auth.conf_bak
vi auth.conf
添加:
Authority {
Auth 密码 {
Mode write
}
}
Authority {
Auth 密码 {
Mode admin
}
}
2.3.4 启动Predixy
#设置成以systemctl方式启动predixy
vi /usr/lib/systemd/system/predixy.service
添加:
[Unit]
Description=predixy
Documentation=https://github.com/joyieldInc/predixy
Wants=network-online.target
After=network-online.target
[Service]
PrivateTmp=true
User=root
Group=root
ExecStart=/usr/local/bin/predixy /usr/local/src/predixy-1.0.5/conf/predixy.conf
StandardOutput=journal
StandardError=inherit
[Install]
WantedBy=multi-user.target
#启动
chmod +x /usr/local/src/predixy-1.0.5/conf/predixy.conf
systemctl start predixy
#设置开机自启
systemctl enable predixy
#查看predixy状态
systemctl status predixy
#测试插入数据
/usr/local/redis/src/redis-cli -p 7617 -a 密码 set str 'hello,world'
--本篇文章主要参考自: