redis集群安装

安装redis集群(版本必须3.0+)



1、需要gcc环境,如果没有执行命令安装gcc

#yum install gcc-c++

2、下载redis3.0的源码并编译

http://pan.baidu.com/s/1c21uAAG
# tar -zxvf redis-3.0.0.tar.gz
# cd redis-3.0.0/
# make 
# make install PREFIX=/usr/local/redis
从redis-3.0.0文件中复制redis-conf到redis的安装目录中
修改 daemonize 
yes为后台启动
daemonize yes
启动单节点
cd  /usr/local/redis/bin
./redis-server redis.conf

3.默认rvm

 # gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
# \curl -sSL https://get.rvm.io | bash -s stable 
# vi .bashrc
# source /etc/profile.d/rvm.sh
#  source ~/.bashrc
#  source ~/.bash_profile  
# rvm install 2.2.0 --disable-binary
# rvm use 2.2.0
# rvm use 2.2.0 --default 

4.安装rubygem

yum install rubygems

5.安装redis库

gem install redis --version 3.0.0

6.集群安装

在local下创建redis-cluster文件夹,在该文件夹中创建6个redis实例,端口号从7001~7006
redis.7001.conf文件
port 7001
daemonize yes
cluster-enabled yes
cluster-config-file nodes.7001.conf
cluster-node-timeout 5000
appendonly yes

# cd /usr/local/redis/bin
# ./redis-server /usr/local/redis-cluster/7001/redis.7001.conf
# ./redis-server /usr/local/redis-cluster/7002/redis.7002.conf
./redis-server /usr/local/redis-cluster/7003/redis.7003.conf
# ./redis-server /usr/local/redis-cluster/7004/redis.7004.conf
# ./redis-server /usr/local/redis-cluster/7005/redis.7005.conf
# ./redis-server /usr/local/redis-cluster/7006/redis.7006.conf
# cd /usr/local/redis-3.0.6/src/
# ./redis-trib.rb create --replicas 1 127.0.01:7001127.0.01:7002 127.0.01:7003 127.0.01:7004127.0.01:7005  127.0.01:7006










你可能感兴趣的:(redis集群安装)