可以看到生成了aof和nodes文件,保存的时候还会有dump文件生成。
在看看pid
[root@localhost 11:03 /usr/local/redis-cluster]# ll /var/run/redis* -rw-r--r--. 1 root root 5 9月 10 10:51 /var/run/redis_7000.pid -rw-r--r--. 1 root root 5 9月 10 10:52 /var/run/redis_7001.pid -rw-r--r--. 1 root root 5 9月 10 10:52 /var/run/redis_7002.pid -rw-r--r--. 1 root root 5 9月 10 10:52 /var/run/redis_7003.pid -rw-r--r--. 1 root root 5 9月 10 10:52 /var/run/redis_7004.pid -rw-r--r--. 1 root root 5 9月 10 10:52 /var/run/redis_7005.pid [root@localhost 11:03 /usr/local/redis-cluster]#
接下来,我们就需要使用redis-trib工具和这六个节点来创建集群了。
redis-trib位于redis源码的src目录下。
我们复制一份到redis-cluster目录下。
[root@localhost 11:03 /usr/local/redis-cluster]# ll ../redis/src/redis-trib* -rwxrwxr-x. 1 root root 60843 7月 24 22:58 ../redis/src/redis-trib.rb [root@localhost 11:04 /usr/local/redis-cluster]# cp ../redis/src/redis-trib.rb ./ [root@localhost 11:05 /usr/local/redis-cluster]# ll 总用量 84 drwxr-xr-x. 2 root root 4096 9月 10 10:51 7000 drwxr-xr-x. 2 root root 4096 9月 10 10:52 7001 drwxr-xr-x. 2 root root 4096 9月 10 10:52 7002 drwxr-xr-x. 2 root root 4096 9月 10 10:52 7003 drwxr-xr-x. 2 root root 4096 9月 10 10:52 7004 drwxr-xr-x. 2 root root 4096 9月 10 10:52 7005 -rwxr-xr-x. 1 root root 60843 9月 10 11:05 redis-trib.rb [root@localhost 11:05 /usr/local/redis-cluster]#
开始启动集群:
[root@localhost 11:13 /usr/local/redis-cluster]# ./redis-trib.rb create --replicas 1 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005 /usr/bin/env: ruby: 没有那个文件或目录 [root@localhost 11:15 /usr/local/redis-cluster]#
下面是本人失败的安装版本,后面也有成功的版本。
因为是ruby的程序,所以我们需要安装ruby,
yum -y install ruby
继续启动集群:
[root@localhost 11:21 /usr/local/redis-cluster]# ./redis-trib.rb create --replicas 1 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005
./redis-trib.rb:24:in `require': no such file to load -- rubygems (LoadError)
from ./redis-trib.rb:24
[root@localhost 11:22 /usr/local/redis-cluster]#
还是报错了,说需要rubygems,我们继续安装:
yum -y install rubygems
继续启动集群:
[root@localhost 11:24 /usr/local/redis-cluster]# ./redis-trib.rb create --replicas 1 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005
/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@localhost 11:24 /usr/local/redis-cluster]#










