[置顶] Redis集群安装
2017-04-19 09:46
459 查看
注:官方给出的安装文档是在一台物理机安装多个Redis实例,https://redis.io/topics/cluster-tutorial,我的生产环境是多台物理机,安装起来就更简单
环境:
6台物理机 CentOS7.2-1511-minimal
ip:192.168.1.101-192.168.1.106
网络环境:内网 挂载Everything.iso作为本地yum源 ,可参考我的一篇文章 http://blog.csdn.net/github_38358734/article/details/70212412
Redis版本:Redis-3.2.5.zip
gem版本:redis-3.3.2.gem
pip版本:pip-8.1.2
python版本:2.7.5
其他环境需要:gcc make
具体步骤如下:
1、在6个节点上解压redis-3.2.5.zip 并 编译安装
# unzip redis-3.2.5.zip
# cd redis-3.2.5
# make && make install
2、检查安装过程
(1)、在redis-3.2.5目录下执行 make test 报错 tcl问题
(2)解决报错: yum install tcl (内网 yum --disablerepo=* --enablerepo=CentOS7-media install tcl 基于搭建好本地yum源;也可以通过yum install --dwonloadonly --downloaddir=...的方式下载安装),重装执行make tesst 显示所有正常
(3)
zmalloc.h:50:31: error: jemalloc/jemalloc.h: No such file or directory
zmalloc.h:55:2: error: #error "Newer version of jemalloc required"
make[1]: *** [adlist.o] Error 1
make[1]: Leaving directory `/data0/src/redis-2.6.2/src'
make: *** [all] Error 2
解决:
make MALLOC=libc
3、部署安装cluster
1、修改配置文件
appendonly yes
appendfilename "appendonly-6379.aof" 去掉注释
cluster-enabled yes
cluster-config-file /opt/nodes-6379.conf 去掉注释
cluster-node-timeout 5000 去掉注释
其中
bind 127.0.0.1 可以注释掉
protected-mode no 默认yes
使用默认值时,启动集群提示connection refused 没有详细找原因,配置文件参数说明很详细
4、分别启动每一个节点
# cd /redis-3.2.5
#./src/redis-server redis.conf > redis.log 2>&1 & 输出Log
如果正常启动的话 cat redis.log
格式如下:
[root@localhost opt]# cat redis-6379.log
6115:M 31 Aug 12:34:28.904 * Increased maximum number of open files to 10032 (it was originally set to 1024).
6115:M 31 Aug 12:34:28.906 * No cluster configuration found, I'm 92999f9840418a848f7b10c5bca0119e3b515fa4
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 2.9.57 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in cluster mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6380
| `-._ `._ / _.-' | PID: 6115
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
6115:M 31 Aug 12:34:28.924 # Server started, Redis version 2.9.57
6115:M 31 Aug 12:34:28.924 * The server is now ready to accept connections on port 6379
5、在每个节点上执行 ps aux | grep redis
如果有
root 6109 0.6 0.9 137408 9740 pts/1 Sl 12:33 0:52 redis-server *:6379 [cluster]
说明服务正常启动
6、集群的安装:需要安装ruby gem
(1)yum install ruby ruby-rdoc
(2)gem install redis (内网可以下载安装redis-3.3.2.gem)
(3)在其中一个节点上执行(如192.168.1.101)
#cd /redis-3.2.5
./src/redis-trib.rb create --replicas 1 192.168.1.101:6379 192.168.1.102:6379 192.168.1.103:6379 192.168.1.104:6379 192.168.1.105:6379 192.168.1.106:6379
(4)出现
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
说明集群安装完成
测试信息:./src/redis-trib.rb check 192.168.1.101:6379
出现的问题及解决:
0、缺少依赖openssl
1、不同Linux系统版本所安装的ruby版本不同(或者Yum list中的ruby版本不同),版本较新的redis需要的ruby版本较高,比如Redis-4.0.2 所使用的redis-4.0.1.gem 依赖ruby版本必须大于2.2,这时通常需要源码编译安装Ruby,安装完ruby后,需要建立ruby和gem的软连接。
2、源码安装完ruby后,执行gem install redis-4.0.1.gem ,抛出异常:
ERROR: Loading command: install (LoadError)
cannot load such file -- zlib
ERROR: While executing gem ... (NameError)
uninitialized constant Gem::Commands::InstallCommand
原因是gem运行缺少zlib库支持,解决方法是:
进入ruby源码文件夹
安装ruby自身提供的zlib包
#cd ext/zlib
#ruby ./extconf.rb
#make
#make install
3、再次安装依然报错:
make的输出中有 configuring openssl Failed to configure openssl. It will not be installed. 如上字样。
然后重新配置, 在运行configure时加上了openssl路径信息即可。
解决方式是:
cd ruby-2.3.0$
./configure --with-openssl-dir=/software/redis-3.2.6/ext/openssl
$ make$ sudo
make install
再次安装,成功。
环境:
6台物理机 CentOS7.2-1511-minimal
ip:192.168.1.101-192.168.1.106
网络环境:内网 挂载Everything.iso作为本地yum源 ,可参考我的一篇文章 http://blog.csdn.net/github_38358734/article/details/70212412
Redis版本:Redis-3.2.5.zip
gem版本:redis-3.3.2.gem
pip版本:pip-8.1.2
python版本:2.7.5
其他环境需要:gcc make
具体步骤如下:
1、在6个节点上解压redis-3.2.5.zip 并 编译安装
# unzip redis-3.2.5.zip
# cd redis-3.2.5
# make && make install
2、检查安装过程
(1)、在redis-3.2.5目录下执行 make test 报错 tcl问题
(2)解决报错: yum install tcl (内网 yum --disablerepo=* --enablerepo=CentOS7-media install tcl 基于搭建好本地yum源;也可以通过yum install --dwonloadonly --downloaddir=...的方式下载安装),重装执行make tesst 显示所有正常
(3)
zmalloc.h:50:31: error: jemalloc/jemalloc.h: No such file or directory
zmalloc.h:55:2: error: #error "Newer version of jemalloc required"
make[1]: *** [adlist.o] Error 1
make[1]: Leaving directory `/data0/src/redis-2.6.2/src'
make: *** [all] Error 2
解决:
make MALLOC=libc
3、部署安装cluster
1、修改配置文件
appendonly yes
appendfilename "appendonly-6379.aof" 去掉注释
cluster-enabled yes
cluster-config-file /opt/nodes-6379.conf 去掉注释
cluster-node-timeout 5000 去掉注释
其中
bind 127.0.0.1 可以注释掉
protected-mode no 默认yes
使用默认值时,启动集群提示connection refused 没有详细找原因,配置文件参数说明很详细
4、分别启动每一个节点
# cd /redis-3.2.5
#./src/redis-server redis.conf > redis.log 2>&1 & 输出Log
如果正常启动的话 cat redis.log
格式如下:
[root@localhost opt]# cat redis-6379.log
6115:M 31 Aug 12:34:28.904 * Increased maximum number of open files to 10032 (it was originally set to 1024).
6115:M 31 Aug 12:34:28.906 * No cluster configuration found, I'm 92999f9840418a848f7b10c5bca0119e3b515fa4
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 2.9.57 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in cluster mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6380
| `-._ `._ / _.-' | PID: 6115
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
6115:M 31 Aug 12:34:28.924 # Server started, Redis version 2.9.57
6115:M 31 Aug 12:34:28.924 * The server is now ready to accept connections on port 6379
5、在每个节点上执行 ps aux | grep redis
如果有
root 6109 0.6 0.9 137408 9740 pts/1 Sl 12:33 0:52 redis-server *:6379 [cluster]
说明服务正常启动
6、集群的安装:需要安装ruby gem
(1)yum install ruby ruby-rdoc
(2)gem install redis (内网可以下载安装redis-3.3.2.gem)
(3)在其中一个节点上执行(如192.168.1.101)
#cd /redis-3.2.5
./src/redis-trib.rb create --replicas 1 192.168.1.101:6379 192.168.1.102:6379 192.168.1.103:6379 192.168.1.104:6379 192.168.1.105:6379 192.168.1.106:6379
(4)出现
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
说明集群安装完成
测试信息:./src/redis-trib.rb check 192.168.1.101:6379
出现的问题及解决:
0、缺少依赖openssl
1、不同Linux系统版本所安装的ruby版本不同(或者Yum list中的ruby版本不同),版本较新的redis需要的ruby版本较高,比如Redis-4.0.2 所使用的redis-4.0.1.gem 依赖ruby版本必须大于2.2,这时通常需要源码编译安装Ruby,安装完ruby后,需要建立ruby和gem的软连接。
2、源码安装完ruby后,执行gem install redis-4.0.1.gem ,抛出异常:
ERROR: Loading command: install (LoadError)
cannot load such file -- zlib
ERROR: While executing gem ... (NameError)
uninitialized constant Gem::Commands::InstallCommand
原因是gem运行缺少zlib库支持,解决方法是:
进入ruby源码文件夹
安装ruby自身提供的zlib包
#cd ext/zlib
#ruby ./extconf.rb
#make
#make install
3、再次安装依然报错:
make的输出中有 configuring openssl Failed to configure openssl. It will not be installed. 如上字样。
然后重新配置, 在运行configure时加上了openssl路径信息即可。
解决方式是:
cd ruby-2.3.0$
./configure --with-openssl-dir=/software/redis-3.2.6/ext/openssl
$ make$ sudo
make install
再次安装,成功。
相关文章推荐
- [置顶] CentOS7.0安装配置redis集群
- [置顶] CentOs6.5单台安装redis集群与ruby-2.2.9安装
- windows本地安装redis单机和集群配置
- 分布式业务Redis安装与集群配置
- redis4.0.1集群安装部署
- 分布式架构高可用架构篇_03-redis3集群的安装高可用测试
- Redis3.0.7 cluster/集群 安装配置教程
- Redis在Centos7下的集群安装
- redis3.2.5 分布式集群安装+错误解决过程
- 王高利:CentOS6.5下redis安装部署配置指南、常用命令、主从同步集群、redis-php学习资料整合详解
- Springboot Redis分布式集群(3)- redis集群安装与配置
- Redis-3.2.8的集群安装部署
- [置顶] 搭建redis集群
- redis安装+redis集群配置+phpredis扩展安装
- Redis集群的安装测试(伪分布模式 - 主从复制)
- Redis集群(二):Redis的安装
- Windows下Redis安装(非集群)
- redis安装与集群方式安装
- windows 下安装redis集群
- Redis的安装及集群配置