单机环境配置
------------------------------------------------
1、下载安装redis
wget http://download.redis.io/releases/redis-2.8.17.tar.gz
tar xzf redis-2.8.17.tar.gz
cd redis-2.8.17
make
make完后 redis-2.8.17目录下会出现编译后的redis服务程序redis-server,还有用于测试的客户端程序redis-cli,两个程序位于安装目录 src 目录下:
2、修改redis配置文件
vi redis.conf
修改 bind 127.0.0.1 为bind 0.0.0.0
设置密码 requirepass 123456
3、启动redis
下面启动redis服务.
$ cd src
$ ./redis-server redis.conf
关闭服务 redis-cli -p 6381 -a password shutdown
redis 集群配置
1、将redis.conf复制5份 修改配置内容
requirepass 123456
port 6381 //修改不同的port 6381 6382 6383 6384 6385 6386
bind 0.0.0.0
cluster-enabled yes
daemonize yes
cluster-config-file nodes-6381.conf//每个节点一个文件 不重名 推荐用端口号
2、启动上述6个节点
./redis-server /usr/local/cluster/6381/redis.conf
./redis-server /usr/local/cluster/6382/redis.conf
./redis-server /usr/local/cluster/6383/redis.conf
./redis-server /usr/local/cluster/6384/redis.conf
./redis-server /usr/local/cluster/6385/redis.conf
./redis-server /usr/local/cluster/6386/redis.conf
3、安装ruby环境
yum install ruby
yum install rubygems
gem install redis-3.2.9.gem
4、合并集群
./redis-trib.rb create --replicas 1 XXX.XXX.XXX.XXX:6381 XXX.XXX.XXX.XXX:6382 XXX.XXX.XXX.XXX:6383 XXX.XXX.XXX.XXX:6384 XXX.XXX.XXX.XXX:6385 XXX.XXX.XXX.XXX:6386