云服务器搭建redis集群(redis-6.0.5)
2020-07-13 05:05
134 查看
配置redis.conf
port xxx # bind 127.0.0.1 务必将 bind xxx 注释掉 protected-mode no daemonize yes requirepass xxxx pidfile /xxxx/redis_xxx.pid logfile "/xxxx/redis_xxx.log" dbfilename dump_xxx.rdb cluster-enabled yes cluster-config-file nodes_xxx.conf cluster-node-timeout 5000 appendonly yes
xxx根据实际情况随意修改
开放端口
注意!!!
确保放行以上端口及以上端口+10000的端口(列如:配置端口为6379,则放行6379与16379端口)
启动redis集群
1. 启动每个节点上的redis-server
../redis-server ./redis.conf
注意替换为自己实际的路径
2. 执行以下命令创建集群
redis-cli --cluster create -a password 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 \ --cluster-replicas 1
此处根据实际情况修改ip与端口。
注意!!!此处所有ip均使用公网ip
为了方便启动停止可编写shell脚本
以下内容仅供参考
start.sh
#!/bin/bash ssh jw@ip1 << EOF cd /home/jw/soft/redis/redis ./bin/redis-server ./50036/redis.conf ./bin/redis-server ./50037/redis.conf exit EOF ssh jw@ip2 << EOF cd /home/jw/soft/redis/redis ./bin/redis-server ./50036/redis.conf ./bin/redis-server ./50037/redis.conf exit EOF ssh jw@ip3 << EOF cd /home/jw/soft/redis/redis ./bin/redis-server ./50036/redis.conf ./bin/redis-server ./50037/redis.conf exit EOF cd /home/jw/soft/redis/redis ./bin/redis-cli --cluster create -a password ip1:50036 ip2:50036 ip3:50036 ip1:50037 ip2:50037 ip3:50037 --cluster-replicas 1
stop.sh
#!/bin/bash ssh jw@ip1 << EOF cd /home/jw/soft/redis/redis ./bin/redis-cli -p 50036 -a password shutdown ./bin/redis-cli -p 50037 -a password shutdown exit EOF ssh jw@ip2 << EOF cd /home/jw/soft/redis/redis ./bin/redis-cli -p 50036 -a password shutdown ./bin/redis-cli -p 50037 -a password shutdown exit EOF ssh jw@ip3 << EOF cd /home/jw/soft/redis/redis ./bin/redis-cli -p 50036 -a password shutdown ./bin/redis-cli -p 50037 -a password shutdown exit EOF
相关文章推荐
- 云服务器搭建redis集群
- 搭建Redis Sentinel集群
- 【详解】搭建redis集群服务的具体步骤和配置以及解决创建集群时会遇到的错误:Node X replied with error: ERR Invalid node address specified
- redis集群部署搭建
- redis集群搭建
- redis 学习笔记之集群搭建
- Redis服务器的搭建和集群
- redis在Windows下以后台服务一键搭建集群(单机--伪集群)
- 在window下搭建redis 集群
- redis集群搭建
- redis集群搭建
- 云服务器搭建hadoop集群
- Nginx+Tomcat搭建集群,Spring Session+Redis实现Session共享
- redis搭建集群ERROR: Could not find a valid gem 'redis-3.0.0' (>= 0) in any repository
- linux下postgresql 一主多从、redis集群、rabbitmq等环境搭建 (七) xa-rdmp-file 从数据库的安装...
- redis集群搭建及注意事项
- Ubuntu搭建Redis 集群
- Redis集群快速搭建
- Redis笔记整理(二):Java API使用与Redis分布式集群环境搭建
- redis4.0.6集群搭建