其实Redis集群的搭建是比较简单的,比oracle,mysql,mongodb都简单.但是其中还是有很多坑.我搞了两天才把所有的坑填完,下面是遇到的几个错误,尤其是最后一个坑.搞了很久才解决:
1.ruby的版本过低,直接删除原来的ruby版本,下载最新的ruby重新编译安装.
2.#gem install redis的报错:
ERROR: Loading command: install (LoadError)
no such file to load -- zlib
ERROR: While executing gem ... (NameError)
uninitialized constant Gem::Commands::InstallCommand
解决办法是:
进入ruby源码文件夹
安装ruby自身提供的zlib包
#cd ext/zlib
#ruby ./extconf.rb
#make
#make install
3.配置群集,使用gem install 安装 ruby redis 接口时报:
[root@server zlib]# gem install redis
ERROR: While executing gem ... (Gem::Exception)
Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources
解决方法:
yum -y install openssl-devel
yum -y install openssl
进入ruby 源码目录下的ext/openssl 目录:
cd /usr/local/src/ruby-2.2.3/ext/openssl/
执行 ruby ./extconf.rb :
[root@server openssl]# ruby extconf.rb
checking for t_open() in -lnsl... no
checking for socket() in -lsocket... no
checking for assert.h... yes
checking for openssl/ssl.h... yes
..........................................................................中间略..........................................................................
checking for EVP_CTRL_GCM_GET_TAG in openssl/evp.h... yes
creating extconf.h
creating Makefile
将ruby 源码目录下的include 目录软链接到 / 目录下:
[root@server openssl]# ln -s /usr/local/src/ruby-2.2.3/include /
再编译安装:
make && make install
然后就好了!
再运行:
gem install redis
即可正常运行!!
4.在使用redis-trib.rb create --replicas 1 xxx来创建集群,在运行到下面的时候一直等待
>>> Nodes configuration updated
>>> Assign a different config epoch to each node
>>> Sending CLUSTER MEET messages to join the cluster
Waiting for the cluster to join.................................
这里一直等待join.
原因是在配置文件中的参数bind 写的有问题,
原来是bind 127.0.0.1 192.168.56.91
后来修改为bind 192.168.56.91 127.0.0.1
即将实际IP写在回环ip之前即可解决.