1、安装wget
yum -y install wget
2、下载redis安装包(版本3.0以上)
wget http://download.redis.io/releases/redis-3.0.4.tar.gz
3、安装redis
1)解压:tar -zxvf redis-3.0.4.tar.gz
2)进入src目录
3)make MALLOC=libc
4)make install(执行完后,会在/usr/local/下面出现redis-cli、redis-server等文件,方便操作)
4、创建本机多个redis实例
1)创建本机redis集群目录(集群至少6个实例完成主从配置)
mkdir /usr/local/redis/redis7000
mkdir /usr/local/redis/redis7001
mkdir /usr/local/redis/redis7002
mkdir /usr/local/redis/redis7003
mkdir /usr/local/redis/redis7004
mkdir /usr/local/redis/redis7005
2)将刚编译好的redis-3.0.4复制到上面的每个目录
cp -fr redis-3.0.4/* /usr/local/redis/redis7000/
cp -fr redis-3.0.4/* /usr/local/redis/redis7001/
......
3)修改配置文件redis.conf
vi /usr/local/redis/redis7000/redis.conf(7001,7002......都需要修改)
修改如下参数:
port 7000
daemonize yes
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 5000
appendonly yes
4)创建集群
cd /usr/local/redis/redis7000/src
./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(如果报错,执行第五步操 作)
5)ruby安装环境
yum install ruby
yum install rubygems
wget https://rubygems.global.ssl.fastly.net/gems/redis-3.2.1.gem
gem install -l ./redis-3.2.1.gem
gem install redis