1.安装包依赖
yum -y install gcc gcc-c++ wget make tcl
2. make
make MALLOC=libc
make install
3.使用脚本安装服务
cd utils/
./install_server.sh
4.将src目录下的redis开头的可执行文件全部拷贝到/usr/local/redis/bin
5. 在三台服务器上分别创建目录
192.168.153.135
mkdir -p /usr/local/redis/7001/{conf,data}
mkdir -p /usr/local/redis/7002/{conf,data}
192.168.153.136
mkdir -p /usr/local/redis/7003/{conf,data}
mkdir -p /usr/local/redis/7004/{conf,data}
192.168.153.137
mkdir -p /usr/local/redis/7005/{conf,data}
mkdir -p /usr/local/redis/7006/{conf,data}
将redis.conf 复制到 /usr/local/redis/7001/conf/redis7001.conf
修改里面的内容
注释掉 #bind 127.0.0.1
protected-mode no
port 7001
daemonize yes
tcp-keepalive 0
pidfile /usr/local/redis/7001/redis7001.pid
logfile "/usr/local/redis/7001/data/redis7001.log"
databases 1
dir /usr/local/redis/7001/data
appendonly yes
cluster-config-file /usr/local/redis/7001/nodes-7001.conf
启动redis /usr/local/redis/bin/redis-server /usr/local/redis/7001/conf/redis7001.conf 另外五个也一样
安装 yum -y install ruby ruby-devel rubygems rpm-build
YUM安装的ruby的版本较低,要重新安装
gpg2 --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3
curl -L get.rvm.io | bash -s stable
find / -name rvm -print
source /usr/local/rvm/scripts/rvm
rvm install 2.3.3
gem install redis
安装完成以后,可以执行命令 /usr/local/redis/bin/redis-trib.rb create --replicas 1 192.168.153.135:7001 192.168.153.135:7002 192.168.153.136:7003 192.168.153.136:7004 192.168.153.137:7005 192.168.153.137:7006
这样三主三从的集群就搭建好了。