centos7.3安装redis4.0.8主3从集群

配置域名

192.168.241.101 paascloud-redis-001
192.168.241.102 paascloud-redis-002
192.168.241.103 paascloud-redis-003
centos7.3安装redis4.0.8主3从集群_第1张图片这里写图片描述

下载

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

解压

 
      
1
2
 
      
# tar -zxvf redis-4.0.8.tar.gz -C /usr/local
# mv redis-4.0.8 redis

创建集群配置文件夹

 
      
1
2
3
4
 
      
# mkdir -p /usr/local/redis/cluster-conf/7001
# mkdir -p /usr/local/redis/cluster-conf/7002
# cp /usr/local/redis/redis.conf /usr/local/redis/cluster-conf/7001
# cp /usr/local/redis/redis.conf /usr/local/redis/cluster-conf/7002

修改集群配置

vim /usr/local/redis/cluster-conf/7001/redis.conf

 
      
1
2
3
4
5
6
7
8
9
10
 
      
port 7001
daemonize yes
/var/run/redis-7001.pid
logfile "/usr/local/redis/cluster-conf/7001/redis.log"
dir /usr/local/redis/cluster-conf/7002/
cluster-enabled yes
cluster-config-file /usr/local/redis/cluster-conf/7001/nodes.conf
cluster-node-timeout 15000
appendonly yes
bind 0.0.0.0

vim /usr/local/redis/cluster-conf/7002/redis.conf

 
      
1
2
3
4
5
6
7
8
9
10
 
      
port 7002
daemonize yes
pidfile /var/run/redis-7002.pid
logfile "/usr/local/redis/cluster-conf/7002/redis.log"
dir /usr/local/redis/cluster-conf/7002/
cluster-enabled yes
cluster-config-file /usr/local/redis/cluster-conf/7002/nodes.conf
cluster-node-timeout 15000
appendonly yes
bind 0.0.0.0

远程拷贝redis

 
      
1
2
 
      
scp -r /usr/local/redis/ [email protected]:/usr/local/
scp -r /usr/local/redis/ [email protected]:/usr/local/

安装依赖

 
      
1
 
      
yum install -y gcc tcl ruby rubygems

安装redis

 
      
1
 
      
make install PREFIX=/usr/local/redis

错误

  • redis编译报致命错误:jemalloc/jemalloc.h:没有那个文件或目录
 
      
1
 
      
make MALLOC=libc
  • redis requires Ruby version >= 2.2.2的报错
 
      
1
 
      
http://blog.csdn.net/liu_zhaoming/article/details/79354420

启动服务

 
      
1
2
 
      
/usr/local/redis/bin/redis-server /usr/local/redis/cluster-conf/7001/redis.conf &
/usr/local/redis/bin/redis-server /usr/local/redis/cluster-conf/7002/redis.conf &

centos7.3安装redis4.0.8主3从集群_第2张图片这里写图片描述

gem 安装 redis ruby 接口

 
      
1
 
      
# gem install redis

创建集群

 
      
1
 
      
# /usr/local/redis/src/redis-trib.rb create --replicas 1 192.168.241.101:7001 192.168.241.102:7001 192.168.241.103:7001 192.168.241.101:7002 192.168.241.102:7002 192.168.241.103:7002

centos7.3安装redis4.0.8主3从集群_第3张图片这里写图片描述

查看节点信息

 
      
1
2
 
      
# /usr/loca/redis/bin/redis-cli -c -p 7001
127.0.0.1:7001> cluster nodes

这里写图片描述这里写图片描述

配置选项 选项值 说明
daemonize yes 是否作为守护进程运行
pidfile /var/run/redis-7001.pid 如以后台进程运行,则需指定一个pid 默认为/var/run/redis.pid
port 7001 监听端口,默认为6379注意:集群通讯端口值默认为此端口值+10000,如17111
cluster-config-file /usr/local/redis/cluster-conf/7001/nodes.conf 集群配置文件(启动自动生成),不用人为干涉
cluster-node-timeout 15000 节点互连超时时间。毫秒
appendonly yes 启用aof持久化方式
dir yes 打开redis集群
cluster-enabled /usr/local/redis/cluster-conf/7001 节点数据持久化存放目录

你可能感兴趣的:(centos7.3安装redis4.0.8主3从集群)