redis集群代建
1:解压redis目录到 /usr/local 目录下
2: ps -ef|grep redis 查看有没有redis进程,有的话关闭redis
3:搭建集群准备 (三主三从,伪集群)
3.1 进入 cd /usr/local/
3.2 mkdir redis_cluster
3.3 cd redis_cluster
mkdir 7000 7001 7002 7003 7004 7005
4: 拷贝 redis 文件
cp /usr/local/redis-4.0.6/redis.conf /usr/local/redis_cluster/7000
5:进入 /usr/local/redis_cluster/7000 修改 redis,conf 文件. 输入 / 查询 小写 n 下一个
daemonize yes //后台启动
port 7000 //端口号 7000 7001 ......
cluster-enabled yes //去掉注释,改成集群模式
cluster-config-file nodes.conf //集群的配置 配置?件?次启动?动?成
cluster-node-timeout 5000 //请求超时 设置5秒够了
appendonly yes //aof?志开启 有需要就开启,它会每次写操作都记录?条?志
bind 127.0.0.1 172.16.244.144(此处为??内?的ip地址,centos7下?采?ip addr来查看,
其他系统试?下ifconfig查看,ip为)
6:修改完后 wq 保存 输入 cd ../7001
复制到其他文件
cp /usr/local/redis_cluster/7000/redis.conf /usr/local/redis_cluster/7001
cp /usr/local/redis_cluster/7000/redis.conf /usr/local/redis_cluster/7002
cp /usr/local/redis_cluster/7000/redis.conf /usr/local/redis_cluster/7003
cp /usr/local/redis_cluster/7000/redis.conf /usr/local/redis_cluster/7004
cp /usr/local/redis_cluster/7000/redis.conf /usr/local/redis_cluster/7005
各自修改端口号
修改完成后 输入
cp /usr/local/redis-4.0.6/src/redis-server /usr/local/redis_cluster 拷贝文件
7: 进入每个目录启动redis
cd /usr/local/redis_cluster/7000
../redis-server ./redis.conf
cd /usr/local/redis-cluster/7001
../redis-server ./redis.conf
cd /usr/local/redis-cluster/7002
../redis-server ./redis.conf
cd /usr/local/redis-cluster/7003
../redis-server ./redis.conf
cd /usr/local/redis-cluster/7004
../redis-server ./redis.conf
cd /usr/local/redis-cluster/7005
../redis-server ./redis.conf
每个节点启动成功
8:安装ruby
yum -y install ruby ruby-devel rubygems rpm-build
编译
gem install redis
9:进入
cd /usr/local/redis-4.0.6/src
启动集群
./redis-trib.rb create --replicas 1 127.0.0.1:7000 127.0.0.1:7001 \127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005
10: 测试集群是否正常
./redis-cli -p 7000 shutdown 关闭redis
相关推荐
zhouminit 2020-09-23
soyo 2020-08-31
王道革 2020-11-25
wangdonghello 2020-11-03
Langeldep 2020-11-16
chenhualong0 2020-11-16
聚合室 2020-11-16
koushr 2020-11-12
MRFENGG 2020-11-11
guoyanga 2020-11-10
fackyou00 2020-11-10
Orangesss 2020-11-03
dongCSDN 2020-10-31
rainandtear 2020-10-30
Quietboy 2020-10-30
liuyulong 2020-10-29
fansili 2020-10-29
温攀峰 2020-10-23