服务器配置
- 10.8.8.70
- 10.8.8.71
- 10.8.8.72
- 10.8.8.73
- 10.8.8.74
- 10.7.7.75
1、redis安装
下载redis
1
| [root@redis ~]# wget http://download.redis.io/releases/redis-3.2.1.tar.gz
|
解压
1 2 3 4
| [root@redis ~]# tar zxvf redis-3.2.1.tar.gz [root@redis ~]# cd redis-3.2.1 [root@redis redis-3.2.1]# yum install -y gcc epel-release [root@redis redis-3.2.1]# yum install -y jemalloc-devel
|
编译
1
| [root@redis redis-3.2.1]# make
|
如果出错,运行如下命令
1 2 3 4
| [root@redis redis-3.2.1]# cd deps/ [root@redis deps]# make hiredis lua jemalloc linenoise/ [root@redis deps]# cd .. [root@redis redis-3.2.1]# make
|
安装
1 2 3
| [root@redis redis-3.2.1]# make PREFIX=/usr/local/redis install [root@redis redis-3.2.1]# mkdir /usr/local/redis/etc [root@redis ~]# wget http://www.apelearn.com/study_v2/.redis_conf -O /usr/local/redis/etc/redis.conf 2>/dev/null
|
2、redis启动脚本
1 2 3 4 5 6 7 8 9 10
| [root@redis ~]# wget http://www.apelearn.com/study_v2/.redis_init -O /etc/init.d/redis 2>/dev/null [root@redis ~]# useradd -s /sbin/nologin redis [root@redis ~]# mkdir /usr/local/redis/var [root@redis ~]# chmod 777 /usr/local/redis/var [root@redis ~]# chmod 755 /etc/init.d/redis [root@redis ~]# chkconfig --add redis [root@redis ~]# chkconfig redis on [root@redis ~]# service redis start 启动 : [确定]
|
3、安装ruby环境
1
| yum install -y ruby rubygems
|
4、更新gem源
1 2
| gem sources –remove https://rubygems.org/ grm sources –a https://ruby.taobao.org/
|
5、使用gem安装redis核ruby接口
或
1
| gem install redis -version 3.2.1
|
6、创建集群
1 2
| cd /usr/local/src/redis-3.2.1/src ./redis-trib.rb create –replicas 1 10.8.8.70:6379 10.8.8.71:6379 10.8.8.72:6379 10.8.8.73:6379 10.8.8.74:6379 10.8.8.75:6379
|
留意屏幕,会有提示(type ‘yes’ to accept),输入yes,回车,就是接收自动分配的三主三从。
如果最后出现
1 2 3 4
| [OK] All nodes agree about slots configuration >>> Check for open slots ... >>> Check slots coverage. [OK] All 16384 slits covered.
|
说明成功了。