标签:receive readline doc rdo 配置 perl node nts ssl
Redis集群安装
Centos6.5 2.6.32-431.el6.x86_64
yum -y install wget tcpdump glibc libgcc gcc gcc-c++ ncurses-devel bison openssl openssl-devel xinetd glibc glibc-common gd gd-devel rsync puppet ntp perl cmake man tree lsof openssh-clients traceroute lsb glibc-2.12-1.132.el6.i686 libgcc-4.4.7-4.el6.i686 vim strace readline-devel tcl tcl-devel python-devel libnl-devel unzip lrzsz(安装系统时更新)
yum -y install ruby ruby-devel ruby-rdoc tcl tcl-devel
tar –zxvf redis-3.0.3.tar.gz
mv redis-3.0.3 /opt/redis
make
tar -zxvf rubygems-1.8.7.gz
mv rubygems-1.8.7 /opt/redis/
cd /opt/redis/rubygems.1.8.7/
ruby setup.rb
cp redis-3.2.1.gem /opt/redis/
gem install redis-3.2.1.gem
mkdir /opt/redis/cluster
注:7000-7005是redis实际发布的端口号。若集群搭建在不同主机上,则分别在各主机建立各自端口号对应的文件夹即可。
cd /opt/redis/cluster
mkdir 7000 7001 7002 7003 7004 7005
daemonize no 为 yes
appendonly no 为yes
在appendonly yes后新增:
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 5000
cp redis.conf /opt/redis/cluster/7000/
cp redis.conf /opt/redis/cluster/7001/
cp redis.conf /opt/redis/cluster/7002/
cp redis.conf /opt/redis/cluster/7003/
cp redis.conf /opt/redis/cluster/7004/
cp redis.conf /opt/redis/cluster/7005/
sed –i ‘s#6379#7000#g’ /opt/redis/cluster/7000/redis.conf
cd /opt/redis/cluster/7000/
./../../src/redis.server redis.conf &
cd /opt/redis/cluster/7001/
./../../src/redis.server redis.conf &
cd /opt/redis/cluster/7002/
./../../src/redis.server redis.conf &
cd /opt/redis/cluster/7003/
./../../src/redis.server redis.conf &
cd /opt/redis/cluster/7004/
./../../src/redis.server redis.conf &
cd /opt/redis/cluster/7005/
./../../src/redis.server redis.conf &
进入/opt/redis/src/,执行如下命令:
./redis-trib.rb create --replicas 1 172.16.19.8:7000 172.16.19.9:7001 172.16.19.10:7002 172.16.19.11:7003 172.16.19.12:7004 172.16.19.13:7005
命令解释:
redis-trib.rb 是搭建集群的命令
--replicas 1 是指为每个MASTER分配一个SLAVE,集群需要六个节点(官方推荐配置)
--replicas 0是指只有三个MASTER,没有SLAVE,集群有三个节点(不采用)
172.16.19.8:7000是指对应redis服务器的IP地址以及redis服务配置的端口
此外,启动后redis会询问是否需要保存集群配置信息,敲yes,然后系统会自动选择谁做主机谁备份
通过客户端,进去集群控制台。运行如下命令:
cd /opt/redis/src
./redis-cli –c –p 7000 ----其中-c是以集群方式进去–p是选择进入端口号
查看集群信息:cluster info
127.0.0.1:7001> cluster info
cluster_state:ok ------集群状态ok说明集群状态正常
cluster_slots_assigned:16384
cluster_slots_ok:16384
cluster_slots_pfail:0
cluster_slots_fail:0
cluster_known_nodes:6
cluster_size:3
cluster_current_epoch:24
cluster_my_epoch:24
cluster_stats_messages_sent:21294261
cluster_stats_messages_received:5858767
查看集群节点信息:cluster nodes
标签:receive readline doc rdo 配置 perl node nts ssl
原文地址:http://www.cnblogs.com/cf532088799/p/7425455.html