centos6.7 搭建 redis集群

一,准备工作

1,下载redis包 redis-3.2.0.tar.gz

2,下载 tcl8.6.5-src.tar.gz (针对tcl版本过低的centos系统)

二,创建redis用户

useradd redis

passwd redis 输入密码

三,安装

1,创建redis安装目录

mkdir -p /usr/local/redis

chown -R redis.redis /usr/local/redis

1,将redis安装包上传到/usr/local/redis目录并解压

3,进入 redis-3.2.0 文件夹编译安装(其实我觉得没必要再编译安装,直接进入src目录运行命令就可以)

编译安装过程中可能会出现一些错误 所以最好编译安装之前运行一下以下的命令

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

。。。过程中还会出现tcl版本过低的问题,在网上找资料升级一下就可以了

4,创建集群需要的目录并拷贝redis
mkdir -p /usr/local/cluster
mkdir -p /usr/local/cluster/7000
mkdir -p /usr/local/cluster/7001
mkdir -p /usr/local/cluster/7002
mkdir -p /usr/local/cluster/7003
mkdir -p /usr/local/cluster/7004
mkdir -p /usr/local/cluster/7005
cp -rf /usr/local/redis3.2.0/* /usr/local/cluster/7000/
cp -rf /usr/local/redis3.2.0* /usr/local/cluster/7001/
cp -rf /usr/local/redis3.2.0* /usr/local/cluster/7002/
cp -rf /usr/local/redis3.2.0* /usr/local/cluster/7003/
cp -rf /usr/local/redis3.2.0* /usr/local/cluster/7004/
cp -rf /usr/local/redis3.2.0* /usr/local/cluster/7005/

5,修改配置文件redis.conf

vi /usr/local/cluster/7000/redis.conf

##修改配置文件中的下面选项
port 7000
daemonize yes
cluster-enabled yes
cluster-config-file nodes-7000.conf
cluster-node-timeout 5000
appendonly yes

#同样再对其它配置文件进行修改
vi /usr/local/cluster/7001/redis.conf
vi /usr/local/cluster/7002/redis.conf
vi /usr/local/cluster/7003/redis.conf
vi /usr/local/cluster/7004/redis.conf
vi /usr/local/cluster/7005/redis.conf

cd /usr/local/cluster/7000/src
./redis-server ../redis.conf

6,创建redis集群
cd /usr/local/redis3.0/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

centos6.7 搭建 redis集群_第1张图片


你可能感兴趣的:(centos,redis集群)