本篇内容介绍了“centos7.6下redis5.0集群的搭建过程”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
# 永久关闭 vim /etc/selinux/config SELINUX=disabled # 临时关闭 setenforce 0 # 查看selinux状态 sestatus # 关闭防火墙 systemctl stop firewalld.service # 永久关闭防火墙 systemctl disable firewalld # 重启docker service docker restart ================================================ # 创建目录 mkdir -p /redis-cluster/700{1,2,3,4,5,6}/{data,conf} # 创建模板文件 cat > /redis-cluster/redis.conf <<EOF port {port} requirepass {这里写密码} protected-mode no cluster-enabled yes cluster-config-file nodes.conf cluster-node-timeout 5000 cluster-announce-ip {ip} cluster-announce-port {port} cluster-announce-bus-port 1{port} appendonly yes EOF # 拷贝配置文件 cp /redis-cluster/redis.conf /redis-cluster/7001/conf/ cp /redis-cluster/redis.conf /redis-cluster/7002/conf/ cp /redis-cluster/redis.conf /redis-cluster/7003/conf/ cp /redis-cluster/redis.conf /redis-cluster/7004/conf/ cp /redis-cluster/redis.conf /redis-cluster/7005/conf/ cp /redis-cluster/redis.conf /redis-cluster/7006/conf/ # 创建redis-net网络 docker network create --driver bridge --subnet 172.18.0.0/16 redis-net # 查看网络 docker network ls # 修改端口 sed -i 's/{port}/7001/g' /redis-cluster/7001/conf/redis.conf sed -i 's/{port}/7002/g' /redis-cluster/7002/conf/redis.conf sed -i 's/{port}/7003/g' /redis-cluster/7003/conf/redis.conf sed -i 's/{port}/7004/g' /redis-cluster/7004/conf/redis.conf sed -i 's/{port}/7005/g' /redis-cluster/7005/conf/redis.conf sed -i 's/{port}/7006/g' /redis-cluster/7006/conf/redis.conf # 修改ip sed -i 's/{ip}/172.18.0.2/g' /redis-cluster/7001/conf/redis.conf sed -i 's/{ip}/172.18.0.3/g' /redis-cluster/7002/conf/redis.conf sed -i 's/{ip}/172.18.0.4/g' /redis-cluster/7003/conf/redis.conf sed -i 's/{ip}/172.18.0.5/g' /redis-cluster/7004/conf/redis.conf sed -i 's/{ip}/172.18.0.6/g' /redis-cluster/7005/conf/redis.conf sed -i 's/{ip}/172.18.0.7/g' /redis-cluster/7006/conf/redis.conf # 创建容器 docker run -d --restart=always --name redis-7001 --net redis-net -p 7001:7001 -p 17001:17001 -v /redis-cluster/7001/conf/redis.conf:/usr/local/etc/redis/redis.conf -v /redis-cluster/7001/data:/data --sysctl net.core.somaxconn=1024 redis redis-server /usr/local/etc/redis/redis.conf docker run -d --restart=always --name redis-7002 --net redis-net -p 7002:7002 -p 17002:17002 -v /redis-cluster/7002/conf/redis.conf:/usr/local/etc/redis/redis.conf -v /redis-cluster/7002/data:/data --sysctl net.core.somaxconn=1024 redis redis-server /usr/local/etc/redis/redis.conf docker run -d --restart=always --name redis-7003 --net redis-net -p 7003:7003 -p 17003:17003 -v /redis-cluster/7003/conf/redis.conf:/usr/local/etc/redis/redis.conf -v /redis-cluster/7003/data:/data --sysctl net.core.somaxconn=1024 redis redis-server /usr/local/etc/redis/redis.conf docker run -d --restart=always --name redis-7004 --net redis-net -p 7004:7004 -p 17004:17004 -v /redis-cluster/7004/conf/redis.conf:/usr/local/etc/redis/redis.conf -v /redis-cluster/7004/data:/data --sysctl net.core.somaxconn=1024 redis redis-server /usr/local/etc/redis/redis.conf docker run -d --restart=always --name redis-7005 --net redis-net -p 7005:7005 -p 17005:17005 -v /redis-cluster/7005/conf/redis.conf:/usr/local/etc/redis/redis.conf -v /redis-cluster/7005/data:/data --sysctl net.core.somaxconn=1024 redis redis-server /usr/local/etc/redis/redis.conf docker run -d --restart=always --name redis-7006 --net redis-net -p 7006:7006 -p 17006:17006 -v /redis-cluster/7006/conf/redis.conf:/usr/local/etc/redis/redis.conf -v /redis-cluster/7006/data:/data --sysctl net.core.somaxconn=1024 redis redis-server /usr/local/etc/redis/redis.conf # 查看节点服务IP docker inspect redis-7001 redis-7002 redis-7003 redis-7004 redis-7005 redis-7006 | grep IPAddress # 连接第一个节点服务 docker exec -it redis-7001 /bin/bash -- 建立集群关系 redis-cli --cluster create -a {密码} \ 172.18.0.2:7001 \ 172.18.0.3:7002 \ 172.18.0.4:7003 \ 172.18.0.5:7004 \ 172.18.0.6:7005 \ 172.18.0.7:7006 \ --cluster-replicas 1 -- 测试集群 redis-cli -h {服务器IP} -p 7001 {密码} -c > set name hnatao > get name
“centos7.6下redis5.0集群的搭建过程”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注亿速云网站,小编将为大家输出更多高质量的实用文章!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。