码迷,mamicode.com
首页 > 其他好文 > 详细

redis 集群安装(二)

时间:2017-11-02 01:03:07      阅读:238      评论:0      收藏:0      [点我收藏+]

标签:.gz   报错   ruby   redis   tar   error   not   gre   yum   

版本:redis-4.0.2.tar.g

(一)创建reids节点

             我们使用3台服务器,分别为192.168.99.129,192.168.99.153,192.168.99.171三台服务器。

              192.168.99.129装 7001,7002两个节点,192.168.99.153装 7003,7004两个节点,192.168.99.171装 7005,7006两个节点.

               在192.168.99.129的 /usr/local/rediscluster 下创建 7001和7002文件夹,并且将要安装的redis拷到此两个文件夹下。其余的俩台机子也这样:

[root@docker3 rediscluster]# pwd
/usr/local/rediscluster
[root@docker3 rediscluster]# ls -al
total 4
drwxr-xr-x.  4 root root   28 Nov  1 08:51 .
drwxr-xr-x. 14 root root 4096 Nov  1 08:47 ..
drwxr-xr-x.  2 root root   31 Nov  1 08:49 7001
drwxr-xr-x.  2 root root    6 Nov  1 08:51 7002

(二)编译redis

(三)配置redis.conf,以7001节点为例。

port 7001
cluster-enabled yes
bind 192.168.99.129
daemonize yes
cluster-config-file 7001.conf
appendonly yes

(四)依次启动各个redis

[root@docker3 src]# ./redis-server ../redis.conf 
17620:C 01 Nov 10:02:59.106 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
17620:C 01 Nov 10:02:59.106 # Redis version=4.0.2, bits=64, commit=00000000, modified=0, pid=17620, just started
17620:C 01 Nov 10:02:59.106 # Configuration loaded
[root@docker3 src]# 
[root@docker3 src]# 
[root@docker3 src]# ps -ef|grep redis
root      17614      1  0 10:01 ?        00:00:00 ./redis-server 192.168.99.129:7001 [cluster]
root      17621      1  0 10:02 ?        00:00:00 ./redis-server 192.168.99.129:7002 [cluster]

(五)执行下面命令,由于centos 7中安装的 ruby版本太低,会报错

[root@docker1 redis-4.0.2]#  yum install ruby
[root@docker1 redis-4.0.2]# yum install rubygems

[root@docker1 redis-4.0.2]# gem install redis

   Fetching: redis-4.0.1.gem (100%)
   ERROR: Error installing redis:
  redis requires Ruby version >= 2.2.2.

 升级ruby版本

安装curl

[root@docker1 redis-4.0.2]# yum install curl

 

安装rvm

[root@docker1 redis-4.0.2]# curl -L get.rvm.io | bash -s stable 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   194  100   194    0     0    246      0 --:--:-- --:--:-- --:--:--   246
100 24090  100 24090    0     0   8210      0  0:00:02  0:00:02 --:--:-- 50503
Downloading https://github.com/rvm/rvm/archive/1.29.3.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.29.3/1.29.3.tar.gz.asc
gpg: directory `/root/.gnupg created
gpg: new configuration file `/root/.gnupg/gpg.conf created
gpg: WARNING: options in `/root/.gnupg/gpg.conf are not yet active during this run
gpg: keyring `/root/.gnupg/pubring.gpg created
gpg: Signature made Sun 10 Sep 2017 04:59:21 PM EDT using RSA key ID BF04FF17
gpg: Cant check signature: No public key
Warning, RVM 1.26.0 introduces signed releases and automated check of signatures when GPG software found. Assuming you trust Michal Papis import the mpapis public key (downloading the signatures).

GPG signature verification failed for /usr/local/rvm/archives/rvm-1.29.3.tgz - https://github.com/rvm/rvm/releases/download/1.29.3/1.29.3.tar.gz.asc! Try to install GPG v2 and then fetch the public key:

    gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3

or if it fails:

    command curl -sSL https://rvm.io/mpapis.asc | gpg2 --import -

the key can be compared with:

    https://rvm.io/mpapis.asc
    https://keybase.io/mpapis

 

 

根据上面的提示执行命令:

[root@docker1 redis-4.0.2]# curl -sSL https://rvm.io/mpapis.asc | gpg2 --import -
[root@docker1 redis-4.0.2]# curl -L get.rvm.io | bash -s stable

[root@docker1 redis-4.0.2]# rvm install 2.3.3
[root@docker1 redis-4.0.2]# gem install redis

 

启动集群:

./redis-trib.rb create --replicas 1 192.168.99.129:7001 192.168.99.129:7002 192.168.99.153:7003 192.168.99.153:7004 192.168.99.171:7005 192.168.99.171:7006

 

 

 进入集群进行测试:

[root@docker3 src]# ./redis-cli -c -h 192.168.99.129 -p 7001   //注意必须加-c

192.168.99.129:7001> set zhang "zhang"

 

 去别的机子查看

[root@docker2 src]# ./redis-cli -c -h 192.168.99.171 -p 7005
192.168.99.171:7005> get zhang
-> Redirected to slot [7942] located at 192.168.99.153:7003

 参考文章:http://www.cnblogs.com/hjwublog/p/5681700.html

redis 集群安装(二)

标签:.gz   报错   ruby   redis   tar   error   not   gre   yum   

原文地址:http://www.cnblogs.com/zhangjunqing/p/7769010.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!