- 工信部备案号 滇ICP备05000110号-1
- 滇公安备案 滇53010302000111
- 增值电信业务经营许可证 B1.B2-20181647、滇B1.B2-20190004
- 云南互联网协会理事单位
- 安全联盟认证网站身份V标记
- 域名注册服务机构许可:滇D3-20230001
- 代理域名注册服务机构:新网数码
1. 下载安装redis:
(1)下载解压redis源码包
yum install -y gcc-c++
yum install -y wget
wget download.redis.io/releases/redis-5.0.5.tar.gz
tar -zxf redis-5.0.5.tar.gz
(2) 进入/redis-5.0.5/src/下安装redis
make install PREFIX=/redis/redis-cluster/3000
(3) 创建文件夹
cd /redis/redis-cluster
mkdir 3000; mkdir 3001; mkdir 3002; mkdir 3003; mkdir 3004; mkdir 3005;
(4)拷贝修改配置文件
cp /redis-5.0.5/redis.conf /redis/redis-cluster/3000/bin
(5)启动连接redis:
./redis-server redis.conf
./redis-cli -h 127.0.0.1 -p 3000
2. 集群搭建
(1)修改3000配置文件
(2)复制配置文件,然后记得进入每个配置文件修改端口
cp -r /redis/redis-cluster/3000/* /redis/redis-cluster/3001
cp -r /redis/redis-cluster/3000/* /redis/redis-cluster/3004
cp -r /redis/redis-cluster/3000/* /redis/redis-cluster/3002
cp -r /redis/redis-cluster/3000/* /redis/redis-cluster/3003
cp -r /redis/redis-cluster/3000/* /redis/redis-cluster/3005
(3)进入每个节点启动redis
./redis-server redis.conf
(4)创建redis集群,进去一个节点bin目录下执行:
./redis-cli --cluster create 192.168.13.17:3000 192.168.13.17:3001 192.168.13.17:3002 192.168.13.17:3003 192.168.13.17:3004 192.168.13.17:3005 --cluster-replicas 1
然后报错:
经过检查,发现是3000没加入集群
使用pkill redis关闭redis,再从新进入每个节点启动redis;
然后再创建redis集群后成功:
./redis-cli --cluster create 192.168.13.17:3000 192.168.13.17:3001 192.168.13.17:3002 192.168.13.17:3003 192.168.13.17:3004 192.168.13.17:3005 --cluster-replicas 1
(5)以集群方式连接:
./redis-cli -h 192.168.13.17 -p 3000 -c
cluster info查看集群状态
cluster info查看集群中的节点
添加数据set name:001 hello
读取数据get name:001
随意测试一下
售前咨询
售后咨询
备案咨询
二维码
TOP