- 浏览: 7355 次
- 性别:
- 来自: 北京
最新评论
-
全站惟一:
Myeclipse不等于eclipse,很多人把Myeclip ...
struts2+Spring3+hibernate3零配置并且正式环境和开发环境不需要多大改动
现在项目上用redis的话,很少说不用集群的情况,毕竟如果生产上只有一台redis会有极大的风险,比如机器挂掉,或者内存爆掉,就比如我们生产环境
曾今也遭遇到这种情况,导致redis内存不够挂掉的情况,当然这些都是我们及其不能容忍的,第一个必须要做到高可靠,其次才是高性能,好了,下面我来
逐一搭建一下。
一:Redis集群搭建
1. 下载
首先去官网下载较新的3.2.0版本,下载方式还是非常简单的,比如官网介绍的这样。
$ wget http://download.redis.io/releases/redis-3.2.0.tar.gz
$ tar xzf redis-3.2.0.tar.gz
$ cd redis-3.2.0
$ make
2. redis配置
由于我们要做集群,而且还要redis自带的redis-trib.rb 能正常运行,我们需要在集群中开启三台master,三台slave,所以这里我需要建立6个文件夹,而且文件夹的名称就使用端口地址的名字,比如:6389. 6380....6384。
3. config配置。
现在directory的分布情况大致如上图,接下来要做的事情就是配置redis.conf了,在这里需要配置四个选项。。。
<1> port 端口地址,比如6380文件夹下面的port就是6380,
# Accept connections on the specified port, default is 6379 (IANA #815344).
# If port 0 is specified Redis will not listen on a TCP socket.
port 6379
<2> cluster-enabled 和 cluster-config-file
这个顾名思义,首先需要开启redis的cluster模式,然后配置一个cluster-config-file文件,这个文件用于存放redis的实时信息,redis会动态追加和修
改这个conf下面的内容信息,不过要记住,这个nodes-6379.conf 可以根据 端口文件夹依次配置,比如6380文件夹可以改成nodes-6380.conf这样。。。
复制代码
# Normal Redis instances can't be part of a Redis Cluster; only nodes that are
# started as cluster nodes can. In order to start a Redis instance as a
# cluster node enable the cluster support uncommenting the following:
#
cluster-enabled yes
# Every cluster node has a cluster configuration file. This file is not
# intended to be edited by hand. It is created and updated by Redis nodes.
# Every Redis Cluster node requires a different cluster configuration file.
# Make sure that instances running in the same system do not have
# overlapping cluster configuration file names.
#
cluster-config-file nodes-6379.conf
复制代码
<3> directory
为了方便管理,我这里配置的root目录取决于在哪个文件夹,比如6380下面我的dir就是: dir ./6380/
# Note that you must specify a directory here, not a file name.
dir ./6379/
<4> protected-mode
这个是redis 3.2 才追加的一个功能,从功能注释中,我们就可以发现,这个默认就是不让外界可以访问redis,所以这里我们就改为no,可以远程访问。
# By default protected mode is enabled. You should disable it only if
# you are sure you want clients from other hosts to connect to Redis
# even if no authentication is configured, nor a specific set of interfaces
# are explicitly listed using the "bind" directive.
protected-mode no
ok,到现在为止,我们的config就修改完毕了,其他端口的文件夹也可以依次配置之~
二:开启redis
到现在为止,各个端口文件夹都配置成功了,接下来准备开启了,真的好么么哒~~~,窗口太多,有点萌萌的。
接下来我们可以看一下,在6379下面是不是有生成node-6379.conf文件,比如下面:
三:配置redis-trib.rb
因为redis-trib.rb是ruby写的,而我们的电脑肯定是没有ruby和一些配置依赖项,不过没关系,有强大的yum安装,一切都不是问题。
1. 执行replicas命令
[jack@localhost ~]$ cluster/redis-trib.rb create --replicas 1 192.168.161.133:6379 192.168.161.133:6380 192.168.161.133:6381 192.168.161.133:6382 192.168.161.133:6383 192.168.161.133:6384
/usr/bin/env: ruby: No such file or directory
[jack@localhost ~]$
可以看到ruby是没有安装的,所以下一步我们要安装ruby了。。。
2. 安装ruby 【一定要是管理员权限哦】
复制代码
[jack@localhost ~]$ sudo
usage: sudo [-D level] -h | -K | -k | -V
usage: sudo -v [-AknS] [-D level] [-g groupname|#gid] [-p prompt] [-u user
name|#uid]
usage: sudo -l[l] [-AknS] [-D level] [-g groupname|#gid] [-p prompt] [-U user
name] [-u user name|#uid] [-g groupname|#gid] [command]
usage: sudo [-AbEHknPS] [-r role] [-t type] [-C fd] [-D level] [-g
groupname|#gid] [-p prompt] [-u user name|#uid] [-g groupname|#gid]
[VAR=value] [-i|-s] [<command>]
usage: sudo -e [-AknS] [-r role] [-t type] [-C fd] [-D level] [-g
groupname|#gid] [-p prompt] [-u user name|#uid] file ...
[jack@localhost ~]$ su
Password:
jacsu: incorrect password
[jack@localhost ~]$ yum install ruby
Loaded plugins: fastestmirror, refresh-packagekit, security
You need to be root to perform this command.
[jack@localhost ~]$ jack
bash: jack: command not found
[jack@localhost ~]$ su
Password:
[root@localhost jack]# yum install ruby
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: mirror.bit.edu.cn
* extras: mirror.bit.edu.cn
* updates: mirror.bit.edu.cn
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package ruby.x86_64 0:1.8.7.374-4.el6_6 will be installed
--> Processing Dependency: ruby-libs = 1.8.7.374-4.el6_6 for package: ruby-1.8.7.374-4.el6_6.x86_64
--> Processing Dependency: libruby.so.1.8()(64bit) for package: ruby-1.8.7.374-4.el6_6.x86_64
--> Running transaction check
---> Package ruby-libs.x86_64 0:1.8.7.374-4.el6_6 will be installed
--> Processing Dependency: libreadline.so.5()(64bit) for package: ruby-libs-1.8.7.374-4.el6_6.x86_64
--> Running transaction check
---> Package compat-readline5.x86_64 0:5.2-17.1.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
ruby x86_64 1.8.7.374-4.el6_6 base 538 k
Installing for dependencies:
compat-readline5 x86_64 5.2-17.1.el6 base 130 k
ruby-libs x86_64 1.8.7.374-4.el6_6 base 1.7 M
Transaction Summary
================================================================================
Install 3 Package(s)
Total download size: 2.3 M
Installed size: 7.8 M
Is this ok [y/N]: y
Downloading Packages:
(1/3): compat-readline5-5.2-17.1.el6.x86_64.rpm | 130 kB 00:00
(2/3): ruby-1.8.7.374-4.el6_6.x86_64.rpm | 538 kB 00:00
(3/3): ruby-libs-1.8.7.374-4.el6_6.x86_64.rpm | 1.7 MB 00:02
--------------------------------------------------------------------------------
Total 747 kB/s | 2.3 MB 00:03
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID c105b9de: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Importing GPG key 0xC105B9DE:
Userid : CentOS-6 Key (CentOS 6 Official Signing Key) <centos-6-key@centos.org>
Package: centos-release-6-5.el6.centos.11.1.x86_64 (@anaconda-CentOS-201311272149.x86_64/6.5)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : compat-readline5-5.2-17.1.el6.x86_64 1/3
Installing : ruby-libs-1.8.7.374-4.el6_6.x86_64 2/3
Installing : ruby-1.8.7.374-4.el6_6.x86_64 3/3
Verifying : compat-readline5-5.2-17.1.el6.x86_64 1/3
Verifying : ruby-libs-1.8.7.374-4.el6_6.x86_64 2/3
Verifying : ruby-1.8.7.374-4.el6_6.x86_64 3/3
Installed:
ruby.x86_64 0:1.8.7.374-4.el6_6
Dependency Installed:
compat-readline5.x86_64 0:5.2-17.1.el6 ruby-libs.x86_64 0:1.8.7.374-4.el6_6
Complete!
[root@localhost jack]#
复制代码
3. 安装rubygems
接着我们再次运行 replicas命令,看看会怎么样。。。
[root@localhost jack]# cluster/redis-trib.rb create --replicas 1 192.168.161.133:6379 192.168.161.133:6380 192.168.161.133:6381 192.168.161.133:6382 192.168.161.133:6383 192.168.161.133:6384
cluster/redis-trib.rb:24:in `require': no such file to load -- rubygems (LoadError)
from cluster/redis-trib.rb:24
[root@localhost jack]#
结果苦逼了,还是报错,看提示貌似是少了一个rubygems,这次我们还是通过yum安装。
复制代码
[root@localhost jack]# yum install -y rubygems
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: mirror.bit.edu.cn
* extras: mirror.bit.edu.cn
* updates: mirror.bit.edu.cn
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package rubygems.noarch 0:1.3.7-5.el6 will be installed
--> Processing Dependency: ruby-rdoc for package: rubygems-1.3.7-5.el6.noarch
--> Running transaction check
---> Package ruby-rdoc.x86_64 0:1.8.7.374-4.el6_6 will be installed
--> Processing Dependency: ruby-irb = 1.8.7.374-4.el6_6 for package: ruby-rdoc-1.8.7.374-4.el6_6.x86_64
--> Running transaction check
---> Package ruby-irb.x86_64 0:1.8.7.374-4.el6_6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
rubygems noarch 1.3.7-5.el6 base 207 k
Installing for dependencies:
ruby-irb x86_64 1.8.7.374-4.el6_6 base 317 k
ruby-rdoc x86_64 1.8.7.374-4.el6_6 base 381 k
Transaction Summary
================================================================================
Install 3 Package(s)
Total download size: 905 k
Installed size: 3.0 M
Downloading Packages:
(1/3): ruby-irb-1.8.7.374-4.el6_6.x86_64.rpm | 317 kB 00:00
(2/3): ruby-rdoc-1.8.7.374-4.el6_6.x86_64.rpm | 381 kB 00:00
(3/3): rubygems-1.3.7-5.el6.noarch.rpm | 207 kB 00:00
--------------------------------------------------------------------------------
Total 625 kB/s | 905 kB 00:01
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : ruby-irb-1.8.7.374-4.el6_6.x86_64 1/3
Installing : ruby-rdoc-1.8.7.374-4.el6_6.x86_64 2/3
Installing : rubygems-1.3.7-5.el6.noarch 3/3
Verifying : ruby-rdoc-1.8.7.374-4.el6_6.x86_64 1/3
Verifying : ruby-irb-1.8.7.374-4.el6_6.x86_64 2/3
Verifying : rubygems-1.3.7-5.el6.noarch 3/3
Installed:
rubygems.noarch 0:1.3.7-5.el6
Dependency Installed:
ruby-irb.x86_64 0:1.8.7.374-4.el6_6 ruby-rdoc.x86_64 0:1.8.7.374-4.el6_6
Complete!
[root@localhost jack]#
复制代码
4. 安装redis驱动
还是继续不死心,我们继续运行replicas命令命令。
[root@localhost jack]# cluster/redis-trib.rb create --replicas 1 192.168.161.133:6379 192.168.161.133:6380 192.168.161.133:6381 192.168.161.133:6382 192.168.161.133:6383 192.168.161.133:6384
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- redis (LoadError)
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from cluster/redis-trib.rb:25
[root@localhost jack]#
卧槽,还是有问题,这次貌似是一个gem_original_require没有安装,当然这个一般是说ruby版本太老了,所以现在亲要么升级ruby版本,要么直接安装
ruby的redis驱动。
[root@localhost jack]# gem install redis
Successfully installed redis-3.3.0
1 gem installed
Installing ri documentation for redis-3.3.0...
Installing RDoc documentation for redis-3.3.0...
6. 运行replicas命令
终于貌似所有的依赖我们都解决了,接下来就可以真的执行了,真是一把辛酸泪啊。。。操。。。
复制代码
[root@localhost jack]# cluster/redis-trib.rb create --replicas 1 192.168.161.133:6379 192.168.161.133:6380 192.168.161.133:6381 192.168.161.133:6382 192.168.161.133:6383 192.168.161.133:6384
>>> Creating cluster
>>> Performing hash slots allocation on 6 nodes...
Using 3 masters:
192.168.161.133:6379
192.168.161.133:6380
192.168.161.133:6381
Adding replica 192.168.161.133:6382 to 192.168.161.133:6379
Adding replica 192.168.161.133:6383 to 192.168.161.133:6380
Adding replica 192.168.161.133:6384 to 192.168.161.133:6381
M: fdae457e803e2e04a7c549c69b44a2beefdae3bc 192.168.161.133:6379
slots:0-5460 (5461 slots) master
M: 74285cee0fa65e64b443ecc630e447a8a65ee9f8 192.168.161.133:6380
slots:5461-10922 (5462 slots) master
M: 14ed067a1b85044325d5800fa8479a6b4e41a10c 192.168.161.133:6381
slots:10923-16383 (5461 slots) master
S: c50b1ff1fe3a00b16703f3b5705d2dafe046240b 192.168.161.133:6382
replicates fdae457e803e2e04a7c549c69b44a2beefdae3bc
S: 8f7bd92f7ffb48e327820693a5820b5be7ea5556 192.168.161.133:6383
replicates 74285cee0fa65e64b443ecc630e447a8a65ee9f8
S: 4a85ed078b4c99afad7f3a9a8df09082c681a649 192.168.161.133:6384
replicates 14ed067a1b85044325d5800fa8479a6b4e41a10c
Can I set the above configuration? (type 'yes' to accept): yes
>>> 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....
>>> Performing Cluster Check (using node 192.168.161.133:6379)
M: fdae457e803e2e04a7c549c69b44a2beefdae3bc 192.168.161.133:6379
slots:0-5460 (5461 slots) master
M: 74285cee0fa65e64b443ecc630e447a8a65ee9f8 192.168.161.133:6380
slots:5461-10922 (5462 slots) master
M: 14ed067a1b85044325d5800fa8479a6b4e41a10c 192.168.161.133:6381
slots:10923-16383 (5461 slots) master
M: c50b1ff1fe3a00b16703f3b5705d2dafe046240b 192.168.161.133:6382
slots: (0 slots) master
replicates fdae457e803e2e04a7c549c69b44a2beefdae3bc
M: 8f7bd92f7ffb48e327820693a5820b5be7ea5556 192.168.161.133:6383
slots: (0 slots) master
replicates 74285cee0fa65e64b443ecc630e447a8a65ee9f8
M: 4a85ed078b4c99afad7f3a9a8df09082c681a649 192.168.161.133:6384
slots: (0 slots) master
replicates 14ed067a1b85044325d5800fa8479a6b4e41a10c
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
[root@localhost jack]#
复制代码
从上面可以看到,trib程序告知我们是否用 6379,6380,6381 作为主, 6382,6383,6384作为从。。然后我就恩准了。。就这样我们的集群
就创建好了,好了,这篇就讲到这里,也不是特别复杂吧~~~
曾今也遭遇到这种情况,导致redis内存不够挂掉的情况,当然这些都是我们及其不能容忍的,第一个必须要做到高可靠,其次才是高性能,好了,下面我来
逐一搭建一下。
一:Redis集群搭建
1. 下载
首先去官网下载较新的3.2.0版本,下载方式还是非常简单的,比如官网介绍的这样。
$ wget http://download.redis.io/releases/redis-3.2.0.tar.gz
$ tar xzf redis-3.2.0.tar.gz
$ cd redis-3.2.0
$ make
2. redis配置
由于我们要做集群,而且还要redis自带的redis-trib.rb 能正常运行,我们需要在集群中开启三台master,三台slave,所以这里我需要建立6个文件夹,而且文件夹的名称就使用端口地址的名字,比如:6389. 6380....6384。
3. config配置。
现在directory的分布情况大致如上图,接下来要做的事情就是配置redis.conf了,在这里需要配置四个选项。。。
<1> port 端口地址,比如6380文件夹下面的port就是6380,
# Accept connections on the specified port, default is 6379 (IANA #815344).
# If port 0 is specified Redis will not listen on a TCP socket.
port 6379
<2> cluster-enabled 和 cluster-config-file
这个顾名思义,首先需要开启redis的cluster模式,然后配置一个cluster-config-file文件,这个文件用于存放redis的实时信息,redis会动态追加和修
改这个conf下面的内容信息,不过要记住,这个nodes-6379.conf 可以根据 端口文件夹依次配置,比如6380文件夹可以改成nodes-6380.conf这样。。。
复制代码
# Normal Redis instances can't be part of a Redis Cluster; only nodes that are
# started as cluster nodes can. In order to start a Redis instance as a
# cluster node enable the cluster support uncommenting the following:
#
cluster-enabled yes
# Every cluster node has a cluster configuration file. This file is not
# intended to be edited by hand. It is created and updated by Redis nodes.
# Every Redis Cluster node requires a different cluster configuration file.
# Make sure that instances running in the same system do not have
# overlapping cluster configuration file names.
#
cluster-config-file nodes-6379.conf
复制代码
<3> directory
为了方便管理,我这里配置的root目录取决于在哪个文件夹,比如6380下面我的dir就是: dir ./6380/
# Note that you must specify a directory here, not a file name.
dir ./6379/
<4> protected-mode
这个是redis 3.2 才追加的一个功能,从功能注释中,我们就可以发现,这个默认就是不让外界可以访问redis,所以这里我们就改为no,可以远程访问。
# By default protected mode is enabled. You should disable it only if
# you are sure you want clients from other hosts to connect to Redis
# even if no authentication is configured, nor a specific set of interfaces
# are explicitly listed using the "bind" directive.
protected-mode no
ok,到现在为止,我们的config就修改完毕了,其他端口的文件夹也可以依次配置之~
二:开启redis
到现在为止,各个端口文件夹都配置成功了,接下来准备开启了,真的好么么哒~~~,窗口太多,有点萌萌的。
接下来我们可以看一下,在6379下面是不是有生成node-6379.conf文件,比如下面:
三:配置redis-trib.rb
因为redis-trib.rb是ruby写的,而我们的电脑肯定是没有ruby和一些配置依赖项,不过没关系,有强大的yum安装,一切都不是问题。
1. 执行replicas命令
[jack@localhost ~]$ cluster/redis-trib.rb create --replicas 1 192.168.161.133:6379 192.168.161.133:6380 192.168.161.133:6381 192.168.161.133:6382 192.168.161.133:6383 192.168.161.133:6384
/usr/bin/env: ruby: No such file or directory
[jack@localhost ~]$
可以看到ruby是没有安装的,所以下一步我们要安装ruby了。。。
2. 安装ruby 【一定要是管理员权限哦】
复制代码
[jack@localhost ~]$ sudo
usage: sudo [-D level] -h | -K | -k | -V
usage: sudo -v [-AknS] [-D level] [-g groupname|#gid] [-p prompt] [-u user
name|#uid]
usage: sudo -l[l] [-AknS] [-D level] [-g groupname|#gid] [-p prompt] [-U user
name] [-u user name|#uid] [-g groupname|#gid] [command]
usage: sudo [-AbEHknPS] [-r role] [-t type] [-C fd] [-D level] [-g
groupname|#gid] [-p prompt] [-u user name|#uid] [-g groupname|#gid]
[VAR=value] [-i|-s] [<command>]
usage: sudo -e [-AknS] [-r role] [-t type] [-C fd] [-D level] [-g
groupname|#gid] [-p prompt] [-u user name|#uid] file ...
[jack@localhost ~]$ su
Password:
jacsu: incorrect password
[jack@localhost ~]$ yum install ruby
Loaded plugins: fastestmirror, refresh-packagekit, security
You need to be root to perform this command.
[jack@localhost ~]$ jack
bash: jack: command not found
[jack@localhost ~]$ su
Password:
[root@localhost jack]# yum install ruby
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: mirror.bit.edu.cn
* extras: mirror.bit.edu.cn
* updates: mirror.bit.edu.cn
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package ruby.x86_64 0:1.8.7.374-4.el6_6 will be installed
--> Processing Dependency: ruby-libs = 1.8.7.374-4.el6_6 for package: ruby-1.8.7.374-4.el6_6.x86_64
--> Processing Dependency: libruby.so.1.8()(64bit) for package: ruby-1.8.7.374-4.el6_6.x86_64
--> Running transaction check
---> Package ruby-libs.x86_64 0:1.8.7.374-4.el6_6 will be installed
--> Processing Dependency: libreadline.so.5()(64bit) for package: ruby-libs-1.8.7.374-4.el6_6.x86_64
--> Running transaction check
---> Package compat-readline5.x86_64 0:5.2-17.1.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
ruby x86_64 1.8.7.374-4.el6_6 base 538 k
Installing for dependencies:
compat-readline5 x86_64 5.2-17.1.el6 base 130 k
ruby-libs x86_64 1.8.7.374-4.el6_6 base 1.7 M
Transaction Summary
================================================================================
Install 3 Package(s)
Total download size: 2.3 M
Installed size: 7.8 M
Is this ok [y/N]: y
Downloading Packages:
(1/3): compat-readline5-5.2-17.1.el6.x86_64.rpm | 130 kB 00:00
(2/3): ruby-1.8.7.374-4.el6_6.x86_64.rpm | 538 kB 00:00
(3/3): ruby-libs-1.8.7.374-4.el6_6.x86_64.rpm | 1.7 MB 00:02
--------------------------------------------------------------------------------
Total 747 kB/s | 2.3 MB 00:03
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID c105b9de: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Importing GPG key 0xC105B9DE:
Userid : CentOS-6 Key (CentOS 6 Official Signing Key) <centos-6-key@centos.org>
Package: centos-release-6-5.el6.centos.11.1.x86_64 (@anaconda-CentOS-201311272149.x86_64/6.5)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : compat-readline5-5.2-17.1.el6.x86_64 1/3
Installing : ruby-libs-1.8.7.374-4.el6_6.x86_64 2/3
Installing : ruby-1.8.7.374-4.el6_6.x86_64 3/3
Verifying : compat-readline5-5.2-17.1.el6.x86_64 1/3
Verifying : ruby-libs-1.8.7.374-4.el6_6.x86_64 2/3
Verifying : ruby-1.8.7.374-4.el6_6.x86_64 3/3
Installed:
ruby.x86_64 0:1.8.7.374-4.el6_6
Dependency Installed:
compat-readline5.x86_64 0:5.2-17.1.el6 ruby-libs.x86_64 0:1.8.7.374-4.el6_6
Complete!
[root@localhost jack]#
复制代码
3. 安装rubygems
接着我们再次运行 replicas命令,看看会怎么样。。。
[root@localhost jack]# cluster/redis-trib.rb create --replicas 1 192.168.161.133:6379 192.168.161.133:6380 192.168.161.133:6381 192.168.161.133:6382 192.168.161.133:6383 192.168.161.133:6384
cluster/redis-trib.rb:24:in `require': no such file to load -- rubygems (LoadError)
from cluster/redis-trib.rb:24
[root@localhost jack]#
结果苦逼了,还是报错,看提示貌似是少了一个rubygems,这次我们还是通过yum安装。
复制代码
[root@localhost jack]# yum install -y rubygems
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
* base: mirror.bit.edu.cn
* extras: mirror.bit.edu.cn
* updates: mirror.bit.edu.cn
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package rubygems.noarch 0:1.3.7-5.el6 will be installed
--> Processing Dependency: ruby-rdoc for package: rubygems-1.3.7-5.el6.noarch
--> Running transaction check
---> Package ruby-rdoc.x86_64 0:1.8.7.374-4.el6_6 will be installed
--> Processing Dependency: ruby-irb = 1.8.7.374-4.el6_6 for package: ruby-rdoc-1.8.7.374-4.el6_6.x86_64
--> Running transaction check
---> Package ruby-irb.x86_64 0:1.8.7.374-4.el6_6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
rubygems noarch 1.3.7-5.el6 base 207 k
Installing for dependencies:
ruby-irb x86_64 1.8.7.374-4.el6_6 base 317 k
ruby-rdoc x86_64 1.8.7.374-4.el6_6 base 381 k
Transaction Summary
================================================================================
Install 3 Package(s)
Total download size: 905 k
Installed size: 3.0 M
Downloading Packages:
(1/3): ruby-irb-1.8.7.374-4.el6_6.x86_64.rpm | 317 kB 00:00
(2/3): ruby-rdoc-1.8.7.374-4.el6_6.x86_64.rpm | 381 kB 00:00
(3/3): rubygems-1.3.7-5.el6.noarch.rpm | 207 kB 00:00
--------------------------------------------------------------------------------
Total 625 kB/s | 905 kB 00:01
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : ruby-irb-1.8.7.374-4.el6_6.x86_64 1/3
Installing : ruby-rdoc-1.8.7.374-4.el6_6.x86_64 2/3
Installing : rubygems-1.3.7-5.el6.noarch 3/3
Verifying : ruby-rdoc-1.8.7.374-4.el6_6.x86_64 1/3
Verifying : ruby-irb-1.8.7.374-4.el6_6.x86_64 2/3
Verifying : rubygems-1.3.7-5.el6.noarch 3/3
Installed:
rubygems.noarch 0:1.3.7-5.el6
Dependency Installed:
ruby-irb.x86_64 0:1.8.7.374-4.el6_6 ruby-rdoc.x86_64 0:1.8.7.374-4.el6_6
Complete!
[root@localhost jack]#
复制代码
4. 安装redis驱动
还是继续不死心,我们继续运行replicas命令命令。
[root@localhost jack]# cluster/redis-trib.rb create --replicas 1 192.168.161.133:6379 192.168.161.133:6380 192.168.161.133:6381 192.168.161.133:6382 192.168.161.133:6383 192.168.161.133:6384
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- redis (LoadError)
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from cluster/redis-trib.rb:25
[root@localhost jack]#
卧槽,还是有问题,这次貌似是一个gem_original_require没有安装,当然这个一般是说ruby版本太老了,所以现在亲要么升级ruby版本,要么直接安装
ruby的redis驱动。
[root@localhost jack]# gem install redis
Successfully installed redis-3.3.0
1 gem installed
Installing ri documentation for redis-3.3.0...
Installing RDoc documentation for redis-3.3.0...
6. 运行replicas命令
终于貌似所有的依赖我们都解决了,接下来就可以真的执行了,真是一把辛酸泪啊。。。操。。。
复制代码
[root@localhost jack]# cluster/redis-trib.rb create --replicas 1 192.168.161.133:6379 192.168.161.133:6380 192.168.161.133:6381 192.168.161.133:6382 192.168.161.133:6383 192.168.161.133:6384
>>> Creating cluster
>>> Performing hash slots allocation on 6 nodes...
Using 3 masters:
192.168.161.133:6379
192.168.161.133:6380
192.168.161.133:6381
Adding replica 192.168.161.133:6382 to 192.168.161.133:6379
Adding replica 192.168.161.133:6383 to 192.168.161.133:6380
Adding replica 192.168.161.133:6384 to 192.168.161.133:6381
M: fdae457e803e2e04a7c549c69b44a2beefdae3bc 192.168.161.133:6379
slots:0-5460 (5461 slots) master
M: 74285cee0fa65e64b443ecc630e447a8a65ee9f8 192.168.161.133:6380
slots:5461-10922 (5462 slots) master
M: 14ed067a1b85044325d5800fa8479a6b4e41a10c 192.168.161.133:6381
slots:10923-16383 (5461 slots) master
S: c50b1ff1fe3a00b16703f3b5705d2dafe046240b 192.168.161.133:6382
replicates fdae457e803e2e04a7c549c69b44a2beefdae3bc
S: 8f7bd92f7ffb48e327820693a5820b5be7ea5556 192.168.161.133:6383
replicates 74285cee0fa65e64b443ecc630e447a8a65ee9f8
S: 4a85ed078b4c99afad7f3a9a8df09082c681a649 192.168.161.133:6384
replicates 14ed067a1b85044325d5800fa8479a6b4e41a10c
Can I set the above configuration? (type 'yes' to accept): yes
>>> 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....
>>> Performing Cluster Check (using node 192.168.161.133:6379)
M: fdae457e803e2e04a7c549c69b44a2beefdae3bc 192.168.161.133:6379
slots:0-5460 (5461 slots) master
M: 74285cee0fa65e64b443ecc630e447a8a65ee9f8 192.168.161.133:6380
slots:5461-10922 (5462 slots) master
M: 14ed067a1b85044325d5800fa8479a6b4e41a10c 192.168.161.133:6381
slots:10923-16383 (5461 slots) master
M: c50b1ff1fe3a00b16703f3b5705d2dafe046240b 192.168.161.133:6382
slots: (0 slots) master
replicates fdae457e803e2e04a7c549c69b44a2beefdae3bc
M: 8f7bd92f7ffb48e327820693a5820b5be7ea5556 192.168.161.133:6383
slots: (0 slots) master
replicates 74285cee0fa65e64b443ecc630e447a8a65ee9f8
M: 4a85ed078b4c99afad7f3a9a8df09082c681a649 192.168.161.133:6384
slots: (0 slots) master
replicates 14ed067a1b85044325d5800fa8479a6b4e41a10c
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
[root@localhost jack]#
复制代码
从上面可以看到,trib程序告知我们是否用 6379,6380,6381 作为主, 6382,6383,6384作为从。。然后我就恩准了。。就这样我们的集群
就创建好了,好了,这篇就讲到这里,也不是特别复杂吧~~~
相关推荐
对于Redis-Cluster到Redis-Cluster的迁移,你需要确保源和目标集群的版本兼容,并且节点配置正确。迁移过程中,可以监控迁移进度和状态,以确保数据一致性。对于从Redis-Cluster到单个Redis实例的迁移,可能需要额外...
### Spark Standalone 分布式集群搭建详解 #### Spark Standalone 运行模式概述 Spark Standalone 是 Apache Spark 提供的一种自带的集群管理模式,主要用于管理 Spark 应用程序的执行环境。这种模式简单易用,适合...
1. 实验描述:本实验旨在搭建一个基于Standalone模式的Spark集群,包括解压安装包、配置环境变量、启动集群及验证安装效果。 2. 实验环境:使用3台虚拟机,操作系统为Centos 7.5,Hadoop版本为2.7.3,Spark版本为...
1.进行相应的解压操作之后,...4.进入bin目录执行 ./start-cluster.sh启动集群 (之前要做好ssh免密设置,可以省去输密码的麻烦) 5.查看Web UI 输入通过浏览器访问flink主节点的8081端口 http://192.168.198.129:8081
这篇博客,Alice为大家带来的是Spark集群环境搭建之——standalone集群模式。 文章目录集群角色介绍集群规划修改配置并分发启动和停止查看web界面测试 集群角色介绍 Spark是基于内存计算的大数据并行计算框架,...
在搭建Apache Flink的standalone高可用(HA)模式时,理解相关概念和技术要点至关重要。高可用性确保了Flink集群在面临硬件故障或其他异常情况时仍能保持服务连续性,保证数据处理不中断。本篇文章将深入探讨如何配置...
搜狐视频(sohu tv)Redis私有云平台 :支持Redis多种架构(Standalone、Sentinel、Cluster)高效管理、有效降低大规模redis运维成本,提升资源管控能力和利用率。平台提供快速搭建/迁移,运维管理,弹性伸缩,统计监控...
redis-standalone.yml redis k8s单点部署
在现代大数据处理领域,Spark作为一个高性能的分布式计算框架,被广泛应用。Spring Boot作为Java开发的轻量级框架,简化了微服务的构建。当需要在Spring Boot应用中整合Spark进行远程服务计算时,通常会采用Spark的...
startup_nacos_by_standalone.bat,windows下nacos的standalone模式启动
Redis私有云管理平台 :支持Redis多种架构(Standalone、Sentinel、Cluster)高效管理、有效降低大规模redis运维成本,提升资源管控能力和利用率。平台提供快速搭建/迁移,运维管理,弹性伸缩,统计监控,客户端整合接...
在实际应用中,为了实现高可用和容错性,通常需要将Nacos配置为集群模式。 **Nacos核心功能:** 1. **服务注册与发现**:Nacos作为服务注册中心,支持微服务之间的互相发现,提供健康检查功能,确保服务的稳定运行...
通过阅读和分析"Redis-standalone"源代码,开发者不仅可以了解Redis的工作原理,还能学习如何在实际应用中优化性能、实现高可用和扩展性。对于想深入理解Redis或者开发基于Redis的应用的开发者来说,这是一个宝贵的...
- 启动Nacos服务,使用`bin/startup.sh -m standalone`或`cluster`(取决于你的集群模式)。 - **配置Nginx** - 解压`nginx-1.20.1.tar.gz`,编译并安装Nginx。 - 编写Nginx配置文件,设置反向代理规则,将请求...
其中 Standalone 为 spark 本身提供的集群模式,Mesos 是一款开源的集群管理器,Yarn 是 Hadoop 的资源管理层。 知识点8:Spark 集群搭建的软件环境 Spark 集群搭建的软件环境包括 Ubuntu 16.04 LTS、CentOS 7、...
启动Flink集群,可以使用bin目录下的`start-cluster.sh`脚本启动standalone模式,或者`start-yarn-session.sh`启动YARN模式。 对于开发者而言,理解Flink的数据模型(DataStream和DataSet)和API是非常关键的。...
在Linux环境下,搭建JBoss Enterprise Application Platform (EAP)的集群能够提高应用程序的可用性和可扩展性。JBoss EAP 6.4.0提供了两种运行模式:standalone(独立运行模式)和domain(域模式)。standalone模式...
spark的Standalone模式安装 一、安装流程 1、将spark-2.2.0-bin-hadoop2.7.tgz 上传到 /usr/local/spark/ 下,然后解压 2、进入到conf中修改名字 改为 .sh 结尾的 3、编辑 spark-env.sh 4、修改slaves 的...
在 Standalone 模式下,Spark 可以在本地或远程机器上运行,且可以使用 ZooKeeper 实现高可用性。 准备工作 在部署 Spark 之前,需要进行以下准备工作: 1. 下载 Spark 的编译版本或自行编译 Spark。 2. 安装 ...
standalone模式是Hadoop的一种运行模式,适合开发者进行本地测试和学习,因为它不需要集群环境,可以在单机上模拟Hadoop的运行情况。 在standalone模式下,Hadoop的所有组件(如HDFS和MapReduce)都在同一个JVM进程...