美文网首页
Redis 实战搭建集群

Redis 实战搭建集群

作者: andrewkk | 来源:发表于2020-06-08 11:00 被阅读0次

实验环境信息

Linux 版本:CentOS Linux release 7.8.2003 (Core)

Redis 版本:redis-5.0.5

实现单个机器下创建redis集群3主3从模式

mkdir -p /root/software

wget http://download.redis.io/releases/redis-5.0.5.tar.gz

tar -xvzf redis-5.0.5.tar.gz

cd redis-5.0.5

make && make install

yum -y install gcc

make distclean

make && make install

cd /usr/local/bin && ls -l

mkdir -p /root/software/redis-5.0/redis_cluster

cd redis_cluster

mkdir -p 7001/ 7002/ 7003/ 7004/ 7005/ 7006/

cd /root/software/redis-5.0/

cp redis.conf /root/software/redis-5.0/redis_cluster/7001/

cp redis.conf /root/software/redis-5.0/redis_cluster/7002/

cp redis.conf /root/software/redis-5.0/redis_cluster/7003/

cp redis.conf /root/software/redis-5.0/redis_cluster/7004/

cp redis.conf /root/software/redis-5.0/redis_cluster/7005/

cp redis.conf /root/software/redis-5.0/redis_cluster/7006/

#需要修改对应参数

bind 192.168.180.128                    # 设置当前节点主机地址     

port 7001                              # 设置客户端连接监听端口   

pidfile /var/run/redis_7001.pid        # 设置 Redis 实例 pid 文件     

daemonize yes                          # 以守护进程运行 Redis 实例   

cluster-enabled yes                    # 启用集群模式

cluster-node-timeout 15000            # 设置当前节点连接超时毫秒数

cluster-config-file nodes-7001.conf    # 设置当前节点集群配置文件路径

/root/software/redis-5.0/redis-server /root/software/redis-5.0/redis-cluster/7001/redis.conf

/root/software/redis-5.0/redis-server /root/software/redis-5.0/redis-cluster/7002/redis.conf

/root/software/redis-5.0/redis-server /root/software/redis-5.0/redis-cluster/7003/redis.conf

/root/software/redis-5.0/redis-server /root/software/redis-5.0/redis-cluster/7004/redis.conf

/root/software/redis-5.0/redis-server /root/software/redis-5.0/redis-cluster/7005/redis.conf

/root/software/redis-5.0/redis-server /root/software/redis-5.0/redis-cluster/7006/redis.conf

yum install net-tools

ps -ef|grep redis

netstat -tulnp| grep redis

redis-cli --cluster create 192.168.180.128:7001 192.168.180.128:7002 192.168.180.128:7003 192.168.180.128:7004 192.168.180.128:7005 192.168.180.128:7006 --cluster-replicas 1

redis-cli --cluster check 192.168.180.128:7001 #检查集群

redis-cli -h 192.168.180.128 -c -p 7001 #进入集群

cluster info

set hello world

redis-cli -h 192.168.180.128 -c -p 7002 #切换集群端口

get hello

相关文章

网友评论

      本文标题:Redis 实战搭建集群

      本文链接:https://www.haomeiwen.com/subject/zlpazhtx.html