centos7安装redis5.0.7集群

启动: cd /usr/local/redis-cluster        ./start-cluster.sh

cd /usr/locar/reds/src

redis-cli -p 7001 #连接

 ./redis-cli  --cluster help #查看帮助

cluster nodes   #节点查看

cluster info # 查看


 

yum -y install  gcc

yum  -y install  tcl

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

解压到/usr/local -> redis-5.0.7

cd redis-5.0.7

make

报错:

zmalloc.h:50:31: fatal error: jemalloc/jemalloc.h: No such file or directory
 #include <jemalloc/jemalloc.h>

使用:make MALLOC=libc

# 启动并指定配置文件 src/redis‐server redis.conf(注意要使用后台启动,所以修改redis.conf里的daemonize改为yes)
验证启动是否成功 ps ‐ef | grep redis
进入redis客户端  /usr/local/redis/src/redis‐cli
退出客户端   quit
 退出redis服务: (1)pkill redis‐server 28 (2)kill 进程号   (3)src/redis‐cli shutdown

集群安装

mkdir -p /usr/local/redis-cluster

mkdir 7001 7002 7003 7004 7005 7006

cd 7001 ,创建redis.conf

port 7001

#yes 设置后台运行
daemonize yes

#设置pidfile存放在 run目录下的文件名
pidfile  /var/run/redis_7001.pid

#指定数据文件存放位置,必须要指定不同的目录位置,不然会丢失数据
dir /usr/local/redis-cluster/7001/

#设置开启AOF模式
appendonly yes

#启动集群
cluster-enabled yes

#关联集群节点信息文件,这里700x好和port对应上
cluster-config-file "nodes-7001.conf"

#设置超时
cluster-node-timeout 5000

#关闭保护模式
protected-mode no

#日志信息,可有可无
logfile "redis.log"

#指定ip访问的地址,设置0.0.0.0 默认是全部地址,不设置,后面会连接不上的
bind 0.0.0.0

requirepass 123456
masterauth 123456

复制 修改端口->其他5个 。 这里万一修改错了,批量修改: sed -i "s/#bind/bind/g" 700*/redis.conf

sed -i "s/old/new/g" the path of the files
eg: sed -i "s/linux/Unix/g" text2.txt text3.txt

挨着启动6个redis

/usr/local/redis-5.0.7/src/redis-server  /usr/local/redis-cluster/7001/redis.conf

ps -ef | grep redis 检查

 

关闭防火墙:systemctl stop firewalld

systemctl stop firewalld.service            #停止firewall
systemctl disable firewalld.service        #禁止firewall开机启动

 

创建集群:

/usr/local/redis-5.0.7/src/redis-cli -a 123456 --cluster create --cluster-replicas 1 192.168.20.8:7001 192.168.20.8:7002 192.168.20.8:7003 192.168.20.8:7004 192.168.20.8:7005 192.168.20.8:7006

 

/usr/local/redis-5.0.7/src/redis-cli  --cluster create --cluster-replicas 1 192.168.20.8:7001 192.168.20.8:7002 192.168.20.8:7003 192.168.20.8:7004 192.168.20.8:7005 192.168.20.8:7006

 

 

还是参考之前的安装 ok

redis5.0版本集群移除节点 收藏里也能找到

https://blog.csdn.net/a826193310/article/details/102579395 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值