Redis集群

(要让集群正常工作至少需要3个主节点,在这里我们要创建6个redis节点,其中三个为主节点,三个为从节点,对应的redis节点的ip和端口对应关系如下)

127.0.0.1:6379
127.0.0.1:6380

127.0.0.1:6381

127.0.0.1:6382

127.0.0.1:6383

127.0.0.1:6384

1:下载redis。官网下载3.0.7版本

下载地址:http://download.redis.io/releases/redis-3.0.7.tar.gz

2:上传服务器,解压,编译

tar -zxvf redis-3.0.7.tar.gz

mv redis-3.0.7.tar.gz redis3.0

cd /usr/local/redis3.0

make

make instal

3:配置集群环境

vi redis.conf

##修改配置文件中的下面选项

port 6379

daemonize yes

appendonly yes

cluster-enabled yes

cluster-config-file  nodes-6379.conf

cluster-node-timeout 15000

6:执行redis的创建集群命令创建集群

分别启动这6个redis实例

./redis-trib.rb  create --replicas 1 127.0.0.1:6379 127.0.0.1:6380 127.0.0.1:6381 127.0.0.1:6382  127.0.0.1:6383 127.0.0.1:6384

错误内容:/usr/bin/env: ruby: No such file or directory6.1执行上面的命令的时候会报错,因为是执行的ruby的脚本,需要ruby的环境

所以需要安装ruby的环境,这里推荐使用yum install ruby安装

yum install ruby

6.2然后再执行第6步的创建集群命令,还会报错,提示缺少rubygems组件,使用yum安装

yum install rubygems

错误内容:

./redis-trib.rb:24:in `require': no such file to load -- rubygems (LoadError)

from ./redis-trib.rb:24

6.3再次执行第6步的命令,还会报错,提示不能加载redis,是因为缺少redis和ruby的接口,使用gem 安装

gem install redis

错误内容:

/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 ./redis-trib.rb:25

6.4 再次执行第6步的命令,正常执行

[root@iZ28afos96aZ src]# ./redis-trib.rb create --replicas 1 127.0.0.1:6384 127.0.0.1:6383 127.0.0.1:6382 127.0.0.1:6381 127.0.0.1:6380 127.0.0.1:6379
>>> Creating cluster
>>> Performing hash slots allocation on nodes...
Using masters:
127.0.0.1:
127.0.0.1:
127.0.0.1:
Adding replica 127.0.0.1: to 127.0.0.1:
Adding replica 127.0.0.1: to 127.0.0.1:
Adding replica 127.0.0.1: to 127.0.0.1:
M: d75e3842921a04d2e530a899194fb5ee92b6fa91 127.0.0.1:
slots:- ( slots) master
M: a74e0aa159bcec51dfc94dd52d13f93f1c45ca1a 127.0.0.1:
slots:- ( slots) master
M: cafe8b69992c2171ad2d1119f65b242e315a68e2 127.0.0.1:
slots:- ( slots) master
S: d3826c34d09550a4d56d1569eb5bd652548f7a91 127.0.0.1:
replicates d75e3842921a04d2e530a899194fb5ee92b6fa91
S: 0d78e8b3bff995b41c18b2edbbc9ea870f9c1c4a 127.0.0.1:
replicates a74e0aa159bcec51dfc94dd52d13f93f1c45ca1a
S: fdacca0da5627679ad3e22ee49efc4611e584fae 127.0.0.1:
replicates cafe8b69992c2171ad2d1119f65b242e315a68e2
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 127.0.0.1:)
M: d75e3842921a04d2e530a899194fb5ee92b6fa91 127.0.0.1:
slots:- ( slots) master
M: a74e0aa159bcec51dfc94dd52d13f93f1c45ca1a 127.0.0.1:
slots:- ( slots) master
M: cafe8b69992c2171ad2d1119f65b242e315a68e2 127.0.0.1:
slots:- ( slots) master
M: d3826c34d09550a4d56d1569eb5bd652548f7a91 127.0.0.1:
slots: ( slots) master
replicates d75e3842921a04d2e530a899194fb5ee92b6fa91
M: 0d78e8b3bff995b41c18b2edbbc9ea870f9c1c4a 127.0.0.1:
slots: ( slots) master
replicates a74e0aa159bcec51dfc94dd52d13f93f1c45ca1a
M: fdacca0da5627679ad3e22ee49efc4611e584fae 127.0.0.1:
slots: ( slots) master
replicates cafe8b69992c2171ad2d1119f65b242e315a68e2
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All slots covered.

输入yes,然后配置完成。

至此redis集群即搭建成功!

7:使用redis-cli命令进入集群环境

redis-cli -c -p 6379

附上信息:

[root@iZ28afos96aZ home]# yum install ruby
Loaded plugins: security
base | 3.7 kB 00:00
epel | 4.3 kB 00:00
epel/primary_db | 5.9 MB 00:06
extras | 3.4 kB 00:00
puppetlabs-deps | 2.5 kB 00:00
puppetlabs-deps/primary_db | 47 kB 00:04
puppetlabs-products | 2.5 kB 00:00
puppetlabs-products/primary_db | 154 kB 00:08
updates | 3.4 kB 00:00
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:01
--------------------------------------------------------------------------------
Total 1.0 MB/s | 2.3 MB 00:02
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
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@iZ28afos96aZ home]# ls
apache-tomcat-8.0.33 redis-3.0.7_2 redis-3.0.7_6 softs
hadoop redis-3.0.7_3 redis-3.0.7_7 svnrepos
redis redis-3.0.7_4 reids zlib-1.2.8
redis-3.0.7_1 redis-3.0.7_5 ruby-2.3.1 zlib-1.2.8.tar.gz
[root@iZ28afos96aZ home]# ruby -v
ruby 1.8.7 (2013-06-27 patchlevel 374) [x86_64-
linux]
[root@iZ28afos96aZ home]# cd redis-3.0.7_1
[root@iZ28afos96aZ redis-3.0.7_1]# ls
00-RELEASENOTES COPYING Makefile redis.conf runtest-sentinel tests
BUGS deps MANIFESTO runtest sentinel.conf utils
CONTRIBUTING INSTALL README runtest-cluster src
[root@iZ28afos96aZ redis-3.0.7_1]# cd src
[root@iZ28afos96aZ src]# ls
adlist.c crc64.h memtest.o redis-cli sort.c
adlist.h crc64.o mkreleasehdr.sh redis-cli.c sort.o
adlist.o db.c multi.c redis-cli.o sparkline.c
ae.c db.o multi.o redis.h sparkline.h
ae_epoll.c debug.c networking.c redis.o sparkline.o
ae_evport.c debug.o networking.o redis-sentinel syncio.c
ae.h dict.c notify.c redis-server syncio.o
ae_kqueue.c dict.h notify.o redis-trib.rb testhelp.h
ae.o dict.o object.c release.c t_hash.c
ae_select.c dump.rdb object.o release.h t_hash.o
anet.c endianconv.c pqsort.c release.o t_list.c
anet.h endianconv.h pqsort.h replication.c t_list.o
anet.o endianconv.o pqsort.o replication.o t_set.c
aof.c fmacros.h pubsub.c rio.c t_set.o
aof.o help.h pubsub.o rio.h t_string.c
asciilogo.h hyperloglog.c rand.c rio.o t_string.o
bio.c hyperloglog.o rand.h scripting.c t_zset.c
bio.h intset.c rand.o scripting.o t_zset.o
bio.o intset.h rdb.c sds.c util.c
bitops.c intset.o rdb.h sds.h util.h
bitops.o latency.c rdb.o sds.o util.o
blocked.c latency.h redisassert.h sentinel.c valgrind.sup
blocked.o latency.o redis-benchmark sentinel.o version.h
cluster.c lzf_c.c redis-benchmark.c setproctitle.c ziplist.c
cluster.h lzf_c.o redis-benchmark.o setproctitle.o ziplist.h
cluster.o lzf_d.c redis.c sha1.c ziplist.o
config.c lzf_d.o redis-check-aof sha1.h zipmap.c
config.h lzf.h redis-check-aof.c sha1.o zipmap.h
config.o lzfP.h redis-check-aof.o slowlog.c zipmap.o
crc16.c Makefile redis-check-dump slowlog.h zmalloc.c
crc16.o Makefile.dep redis-check-dump.c slowlog.o zmalloc.h
crc64.c memtest.c redis-check-dump.o solarisfixes.h zmalloc.o
[root@iZ28afos96aZ src]# ./redis-server ../redis.conf
[root@iZ28afos96aZ src]# cd..
-bash: cd..: command not found
[root@iZ28afos96aZ src]# cd ..
[root@iZ28afos96aZ redis-3.0.7_1]# ls
00-RELEASENOTES COPYING Makefile redis.conf runtest-sentinel tests
BUGS deps MANIFESTO runtest sentinel.conf utils
CONTRIBUTING INSTALL README runtest-cluster src
[root@iZ28afos96aZ redis-3.0.7_1]# cd ..
[root@iZ28afos96aZ home]# cd re
-bash: cd: re: No such file or directory
[root@iZ28afos96aZ home]# cd redis
[root@iZ28afos96aZ redis]# ls
cluser data logs
[root@iZ28afos96aZ redis]# cd logs
[root@iZ28afos96aZ logs]# ls
redis-6379.log redis-6380.log redis-6382.log
[root@iZ28afos96aZ logs]# more redis-6379.log
4001:M 05 May 23:33:28.240 # Creating Server TCP listening socket *:6379: bind:
Address already in use
[root@iZ28afos96aZ logs]# ps -aux|grep redis
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
root 4012 0.0 0.0 103252 840 pts/8 S+ 23:35 0:00 grep redis
root 22201 0.0 0.3 137448 7524 ? Sl 13:04 0:20 ./redis-server *:6379
root 22383 0.0 0.4 137444 7800 ? Sl 13:16 0:22 ./redis-server *:6380 [cluster]
root 22417 0.0 0.4 137448 7812 ? Sl 13:18 0:22 ./redis-server *:6381 [cluster]
root 22480 0.0 0.3 137444 7464 ? Sl 13:22 0:22 ./redis-server *:6383 [cluster]
root 22507 0.0 0.4 137448 7812 ? Sl 13:23 0:22 ./redis-server *:6384 [cluster]
root 22515 0.0 0.3 137444 7484 ? Sl 13:24 0:21 ./redis-server *:6382 [cluster]
[root@iZ28afos96aZ logs]# ls
redis-6379.log redis-6380.log redis-6382.log
[root@iZ28afos96aZ logs]# ls
redis-6379.log redis-6380.log redis-6382.log
[root@iZ28afos96aZ logs]# cd ..
[root@iZ28afos96aZ redis]# ls
cluser data logs
[root@iZ28afos96aZ redis]# cd ..
[root@iZ28afos96aZ home]# cd redis-3.0.7_1
[root@iZ28afos96aZ redis-3.0.7_1]# ls
00-RELEASENOTES COPYING Makefile redis.conf runtest-sentinel tests
BUGS deps MANIFESTO runtest sentinel.conf utils
CONTRIBUTING INSTALL README runtest-cluster src
[root@iZ28afos96aZ redis-3.0.7_1]# cd src
[root@iZ28afos96aZ src]# ls
adlist.c crc64.h memtest.o redis-cli sort.c
adlist.h crc64.o mkreleasehdr.sh redis-cli.c sort.o
adlist.o db.c multi.c redis-cli.o sparkline.c
ae.c db.o multi.o redis.h sparkline.h
ae_epoll.c debug.c networking.c redis.o sparkline.o
ae_evport.c debug.o networking.o redis-sentinel syncio.c
ae.h dict.c notify.c redis-server syncio.o
ae_kqueue.c dict.h notify.o redis-trib.rb testhelp.h
ae.o dict.o object.c release.c t_hash.c
ae_select.c dump.rdb object.o release.h t_hash.o
anet.c endianconv.c pqsort.c release.o t_list.c
anet.h endianconv.h pqsort.h replication.c t_list.o
anet.o endianconv.o pqsort.o replication.o t_set.c
aof.c fmacros.h pubsub.c rio.c t_set.o
aof.o help.h pubsub.o rio.h t_string.c
asciilogo.h hyperloglog.c rand.c rio.o t_string.o
bio.c hyperloglog.o rand.h scripting.c t_zset.c
bio.h intset.c rand.o scripting.o t_zset.o
bio.o intset.h rdb.c sds.c util.c
bitops.c intset.o rdb.h sds.h util.h
bitops.o latency.c rdb.o sds.o util.o
blocked.c latency.h redisassert.h sentinel.c valgrind.sup
blocked.o latency.o redis-benchmark sentinel.o version.h
cluster.c lzf_c.c redis-benchmark.c setproctitle.c ziplist.c
cluster.h lzf_c.o redis-benchmark.o setproctitle.o ziplist.h
cluster.o lzf_d.c redis.c sha1.c ziplist.o
config.c lzf_d.o redis-check-aof sha1.h zipmap.c
config.h lzf.h redis-check-aof.c sha1.o zipmap.h
config.o lzfP.h redis-check-aof.o slowlog.c zipmap.o
crc16.c Makefile redis-check-dump slowlog.h zmalloc.c
crc16.o Makefile.dep redis-check-dump.c slowlog.o zmalloc.h
crc64.c memtest.c redis-check-dump.o solarisfixes.h zmalloc.o
[root@iZ28afos96aZ src]# ./redis-trib.rb create --replicas 1 127.0.0.1:6384 127.0.0.1:6383 127.0.0.1:6382 127.0.0.1:6381 127.0.0.1:6380 127.0.0.1:6379
./redis-trib.rb:24:in `require': no such file to load -- rubygems (LoadError)
from ./redis-trib.rb:24

[root@iZ28afos96aZ src]# yum install rubygems
Loaded plugins: security

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
Is this ok [y/N]: y
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 1.3 MB/s | 905 kB 00:00
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@iZ28afos96aZ src]# ./redis-trib.rb create --replicas 1 127.0.0.1:6384 127.0.0.1:6383 127.0.0.1:6382 127.0.0.1:6381 127.0.0.1:6380 127.0.0.1:6379

/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 ./redis-trib.rb:25
[root@iZ28afos96aZ src]# 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...
[root@iZ28afos96aZ src]# ./redis-trib.rb create --replicas 1 127.0.0.1:6384 127.0.0.1:6383 127.0.0.1:6382 127.0.0.1:6381 127.0.0.1:6380 127.0.0.1:6379
>>> Creating cluster
[ERR] Node 127.0.0.1:6379 is not configured as a cluster node.
[root@iZ28afos96aZ src]# ps -aux|grep redis
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
root 4288 0.0 0.0 103252 840 pts/8 S+ 23:44 0:00 grep redis
root 22201 0.0 0.3 137448 7532 ? Sl 13:04 0:20 ./redis-server *:6379
root 22383 0.0 0.4 137444 7836 ? Sl 13:16 0:23 ./redis-server *:6380 [cluster]
root 22417 0.0 0.4 137448 7844 ? Sl 13:18 0:23 ./redis-server *:6381 [cluster]
root 22480 0.0 0.3 137444 7624 ? Sl 13:22 0:23 ./redis-server *:6383 [cluster]
root 22507 0.0 0.4 137448 7844 ? Sl 13:23 0:22 ./redis-server *:6384 [cluster]
root 22515 0.0 0.3 137444 7628 ? Sl 13:24 0:22 ./redis-server *:6382 [cluster]
[root@iZ28afos96aZ src]# ./redis-trib.rb create --replicas 1 127.0.0.1:6384 127.0.0.1:6383 127.0.0.1:6382 127.0.0.1:6381 127.0.0.1:6380
>>> Creating cluster
*** ERROR: Invalid configuration for cluster creation.
*** Redis Cluster requires at least 3 master nodes.
*** This is not possible with 5 nodes and 1 replicas per node.
*** At least 6
nodes are required.
[root@iZ28afos96aZ src]# ls
adlist.c crc64.h memtest.o redis-cli sort.c
adlist.h crc64.o mkreleasehdr.sh redis-cli.c sort.o
adlist.o db.c multi.c redis-cli.o sparkline.c
ae.c db.o multi.o redis.h sparkline.h
ae_epoll.c debug.c networking.c redis.o sparkline.o
ae_evport.c debug.o networking.o redis-sentinel syncio.c
ae.h dict.c notify.c redis-server syncio.o
ae_kqueue.c dict.h notify.o redis-trib.rb testhelp.h
ae.o dict.o object.c release.c t_hash.c
ae_select.c dump.rdb object.o release.h t_hash.o
anet.c endianconv.c pqsort.c release.o t_list.c
anet.h endianconv.h pqsort.h replication.c t_list.o
anet.o endianconv.o pqsort.o replication.o t_set.c
aof.c fmacros.h pubsub.c rio.c t_set.o
aof.o help.h pubsub.o rio.h t_string.c
asciilogo.h hyperloglog.c rand.c rio.o t_string.o
bio.c hyperloglog.o rand.h scripting.c t_zset.c
bio.h intset.c rand.o scripting.o t_zset.o
bio.o intset.h rdb.c sds.c util.c
bitops.c intset.o rdb.h sds.h util.h
bitops.o latency.c rdb.o sds.o util.o
blocked.c latency.h redisassert.h sentinel.c valgrind.sup
blocked.o latency.o redis-benchmark sentinel.o version.h
cluster.c lzf_c.c redis-benchmark.c setproctitle.c ziplist.c
cluster.h lzf_c.o redis-benchmark.o setproctitle.o ziplist.h
cluster.o lzf_d.c redis.c sha1.c ziplist.o
config.c lzf_d.o redis-check-aof sha1.h zipmap.c
config.h lzf.h redis-check-aof.c sha1.o zipmap.h
config.o lzfP.h redis-check-aof.o slowlog.c zipmap.o
crc16.c Makefile redis-check-dump slowlog.h zmalloc.c
crc16.o Makefile.dep redis-check-dump.c slowlog.o zmalloc.h
crc64.c memtest.c redis-check-dump.o solarisfixes.h zmalloc.o
[root@iZ28afos96aZ src]# cd ..
[root@iZ28afos96aZ redis-3.0.7_1]# ls
00-RELEASENOTES COPYING Makefile redis.conf runtest-sentinel tests
BUGS deps MANIFESTO runtest sentinel.conf utils
CONTRIBUTING INSTALL README runtest-cluster src
[root@iZ28afos96aZ redis-3.0.7_1]# cd src
[root@iZ28afos96aZ src]# ls
adlist.c crc64.h memtest.o redis-cli sort.c
adlist.h crc64.o mkreleasehdr.sh redis-cli.c sort.o
adlist.o db.c multi.c redis-cli.o sparkline.c
ae.c db.o multi.o redis.h sparkline.h
ae_epoll.c debug.c networking.c redis.o sparkline.o
ae_evport.c debug.o networking.o redis-sentinel syncio.c
ae.h dict.c notify.c redis-server syncio.o
ae_kqueue.c dict.h notify.o redis-trib.rb testhelp.h
ae.o dict.o object.c release.c t_hash.c
ae_select.c dump.rdb object.o release.h t_hash.o
anet.c endianconv.c pqsort.c release.o t_list.c
anet.h endianconv.h pqsort.h replication.c t_list.o
anet.o endianconv.o pqsort.o replication.o t_set.c
aof.c fmacros.h pubsub.c rio.c t_set.o
aof.o help.h pubsub.o rio.h t_string.c
asciilogo.h hyperloglog.c rand.c rio.o t_string.o
bio.c hyperloglog.o rand.h scripting.c t_zset.c
bio.h intset.c rand.o scripting.o t_zset.o
bio.o intset.h rdb.c sds.c util.c
bitops.c intset.o rdb.h sds.h util.h
bitops.o latency.c rdb.o sds.o util.o
blocked.c latency.h redisassert.h sentinel.c valgrind.sup
blocked.o latency.o redis-benchmark sentinel.o version.h
cluster.c lzf_c.c redis-benchmark.c setproctitle.c ziplist.c
cluster.h lzf_c.o redis-benchmark.o setproctitle.o ziplist.h
cluster.o lzf_d.c redis.c sha1.c ziplist.o
config.c lzf_d.o redis-check-aof sha1.h zipmap.c
config.h lzf.h redis-check-aof.c sha1.o zipmap.h
config.o lzfP.h redis-check-aof.o slowlog.c zipmap.o
crc16.c Makefile redis-check-dump slowlog.h zmalloc.c
crc16.o Makefile.dep redis-check-dump.c slowlog.o zmalloc.h
crc64.c memtest.c redis-check-dump.o solarisfixes.h zmalloc.o
[root@iZ28afos96aZ src]# ./re
-bash: ./re: No such file or directory
[root@iZ28afos96aZ src]# ./redis-cli
127.0.0.1:6379> get
(error) ERR wrong number of arguments for 'get' command
127.0.0.1:6379> exit
[root@iZ28afos96aZ src]# ./redis-cli shutdown
[root@iZ28afos96aZ src]# ./redis-server ../redis.conf
[root@iZ28afos96aZ src]# ps -aux|grep redis
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
root 4327 0.0 0.3 137444 7508 ? Ssl 23:50 0:00 ./redis-server *:6379 [cluster]
root 4335 0.0 0.0 103252 840 pts/8 S+ 23:50 0:00 grep redis
root 22383 0.0 0.4 137444 7836 ? Sl 13:16 0:23 ./redis-server *:6380 [cluster]
root 22417 0.0 0.4 137448 7848 ? Sl 13:18 0:23 ./redis-server *:6381 [cluster]
root 22480 0.0 0.3 137444 7624 ? Sl 13:22 0:23 ./redis-server *:6383 [cluster]
root 22507 0.0 0.4 137448 7844 ? Sl 13:23 0:23 ./redis-server *:6384 [cluster]
root 22515 0.0 0.3 137444 7628 ? Sl 13:24 0:22 ./redis-server *:6382 [cluster]
[root@iZ28afos96aZ src]# ./redis-trib.rb create --replicas 1 127.0.0.1:6384 127.0.0.1:6383 127.0.0.1:6382 127.0.0.1:6381 127.0.0.1:6380 127.0.0.1:6379
>>> Creating cluster
>>> Performing hash slots allocation on 6 nodes...
Using 3 masters:
127.0.0.1:6384
127.0.0.1:6383
127.0.0.1:6382
Adding replica 127.0.0.1:6381 to 127.0.0.1:6384
Adding replica 127.0.0.1:6380 to 127.0.0.1:6383
Adding replica 127.0.0.1:6379 to 127.0.0.1:6382
M: d75e3842921a04d2e530a899194fb5ee92b6fa91 127.0.0.1:6384
slots:0-5460 (5461 slots) master
M: a74e0aa159bcec51dfc94dd52d13f93f1c45ca1a 127.0.0.1:6383
slots:5461-10922 (5462 slots) master
M: cafe8b69992c2171ad2d1119f65b242e315a68e2 127.0.0.1:6382
slots:10923-16383 (5461 slots) master
S: d3826c34d09550a4d56d1569eb5bd652548f7a91 127.0.0.1:6381
replicates d75e3842921a04d2e530a899194fb5ee92b6fa91
S: 0d78e8b3bff995b41c18b2edbbc9ea870f9c1c4a 127.0.0.1:6380
replicates a74e0aa159bcec51dfc94dd52d13f93f1c45ca1a
S: fdacca0da5627679ad3e22ee49efc4611e584fae 127.0.0.1:6379
replicates cafe8b69992c2171ad2d1119f65b242e315a68e2
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 127.0.0.1:6384)
M: d75e3842921a04d2e530a899194fb5ee92b6fa91 127.0.0.1:6384
slots:0-5460 (5461 slots) master
M: a74e0aa159bcec51dfc94dd52d13f93f1c45ca1a 127.0.0.1:6383
slots:5461-10922 (5462 slots) master
M: cafe8b69992c2171ad2d1119f65b242e315a68e2 127.0.0.1:6382
slots:10923-16383 (5461 slots) master
M: d3826c34d09550a4d56d1569eb5bd652548f7a91 127.0.0.1:6381
slots: (0 slots) master
replicates d75e3842921a04d2e530a899194fb5ee92b6fa91
M: 0d78e8b3bff995b41c18b2edbbc9ea870f9c1c4a 127.0.0.1:6380
slots: (0 slots) master
replicates a74e0aa159bcec51dfc94dd52d13f93f1c45ca1a
M: fdacca0da5627679ad3e22ee49efc4611e584fae 127.0.0.1:6379
slots: (0 slots) master
replicates cafe8b69992c2171ad2d1119f65b242e315a68e2
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384
slots covered.
[root@iZ28afos96aZ src]#

【redis】 linux 下redis 集群环境搭建的更多相关文章

  1. Linux环境下SolrCloud集群环境搭建关键步骤

    Linux环境下SolrCloud集群环境搭建关键步骤. 前提条件:已经完成ZooKeeper集群环境搭建. 一.下载介质 官网下载地址:http://www.apache.org/dyn/close ...

  2. Linux环境下HDFS集群环境搭建关键步骤

    Linux环境下HDFS集群环境搭建关键步骤记录. 介质版本:hadoop-2.7.3.tar.gz 节点数量:3节点. 一.下载安装介质 官网下载地址:http://hadoop.apache.or ...

  3. Linux环境下ZooKeeper集群环境搭建关键步骤

    ZooKeeper版本:zookeeper-3.4.9 ZooKeeper节点:3个节点 以下为Linux环境下ZooKeeper集群环境搭建关键步骤: 前提条件:已完成在Linux环境中安装JDK并 ...

  4. Linux下Hadoop集群环境的安装配置

    1)安装Ubuntu或其他Linux系统: a)为减少错误,集群中的主机最好安装同一版本的Linux系统,我的是Ubuntu12.04. b)每个主机的登陆用户名也最好都一样,比如都是hadoop,不 ...

  5. Ubuntu下kafka集群环境搭建及测试

    kafka介绍: Kafka[1是一种高吞吐量[2]  的分布式发布订阅消息系统,有如下特性: 通过O(1)的磁盘数据结构提供消息的持久化,这种结构对于即使数以TB的消息存储也能够保持长时间的稳定性能 ...

  6. Linux下kafka集群的搭建

    上一篇日志已经搭建好了zookeeper集群,详细请查看:http://www.cnblogs.com/lianliang/p/6533670.html,接下来继续搭建kafka的集群 1.首先下载k ...

  7. Uubntu14.04下 Hadoop集群环境搭建

    1机器信息 master192.168.3.10 hadoop/ hadoop slave1192.168.3.11 hadoop/ hadoop slave2192.168.3.12 hadoop/ ...

  8. kafka 集群环境搭建 java

    简单记录下kafka集群环境搭建过程, 用来做备忘录 安装 第一步: 点击官网下载地址 http://kafka.apache.org/downloads.html 下载最新安装包 第二步: 解压 t ...

  9. redis哨兵集群环境搭建

    一.哨兵的介绍 哨兵(sentinal)是redis集群架构中非常重要的一个组件,主要功能如下: 集群监控,负责监控redis master和slave进程是否正常工作 消息通知,如果某个redis实 ...

  10. Redis 快速集群环境搭建

    环境 Linux :centos 7 redis:redis-5.0.9 Redis 集群环境搭建步骤 早期 redis 版本集群环境搭建需要安装 ruby 运行环境,搭建步骤比较繁琐: redis ...

随机推荐

  1. 简单的JS运动封装实例---侧栏分享到

    <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content ...

  2. 转:通过代码理解Asp.net4中的几种ClientIDMode设置.

    转:http://www.cnblogs.com/xray2005/archive/2011/07/05/2097881.html 以前我们可以通过ClientID在JavaScript脚本中服务器端 ...

  3. matlab产生正态分布样本

    mvnrnd - Multivariate normal random numbers This MATLAB function returns an n-by-d matrix R of rando ...

  4. 【Avalon】escape

    [\uD800-\uDBFF][\uDC00-\uDFFF] var rsurrogate = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g var rnoalphanumeri ...

  5. 读metronic文档学到的几个知识点

    1.RTL  同样的页面,它做了两套.为什么,因为在这个世界上,有些民族,有些语种,是从右向左来的. 2. google material design 同样的一套东西,又分别做了google mat ...

  6. SQL SERVER 2012使用sequence

    从之前Oracle转过来,现在看sql server中对于id的实现竟然用guid这种方式.为啥不像在Oracle中一样使用Sequence并行获取序列号呢?今天看MSDN才发现在sql server ...

  7. Codeforces Round #301 (Div. 2) B. School Marks

    其实是很水的一道bfs题,昨晚比赛的时候没看清题意,漏了一个条件. #include<cstdio> #include<cstring> #include<iostrea ...

  8. CentOS下解决”用户账户is not in the sudoers file“问题

    如上图,在当前用户cent(我的用户名)下使用sudo命令时,提示"cent is not in the sudoers file. This incident will be report ...

  9. Debian中如何切换默认Python版本

    当你安装 Debian Linux 时,安装过程有可能同时为你提供多个可用的 Python 版本,因此系统中会存在多个 Python 的可执行二进制文件,你可以按照以下方法使用 ls 命令来查看你的系 ...

  10. discuz使用

    1.discuz登陆错误过多,后台删除ip SELECT * FROM `lang_common_admincp_session` 2.Discuz与UCenter通信失败的解决方法 应用与 UCen ...