redis多机集群部署文档(centos6.2)

(要让集群正常工作至少需要3个主节点,在这里我们要创建6个redis节点,其中三个为主节点,三个为从节点,对应的redis节点的ip和端口对应关系如下)

10.168.32.116:6379

10.168.32.117:6379

10.168.32.118:6379

10.168.32.119:6379

10.168.32.120:6379

10.168.32.121:6379

在安装集群之前,需要在服务器上安装ruby环境,

yum install -y ruby rubygems

gem install redis

下载redis版本,

#git clone https://github.com/antirez/redis.git

#mv redis /usr/local/redis

#cd  /usr/local/redis

#make && make install

修改配置集群需要的基本配置,其余部分,根据实际需要配置

#vi /usr/local/redis/redis.conf

bind 10.168.32.116

port 6379

daemonize yes

cluster-enabled yes

cluster-config-file nodes.conf

appendonly yes

修改完这几行,把redis.conf分发到其余的服务器,所有服务器的配置可以完全一致,bind是主机ip(如果是在同一台服务器进行实验,需要修改port,每个redis使用独立的端口)

配置同步之后,启动所有服务器的redis

redis-server /usr/local/redis/redis.conf

执行redis的创建集群命令创建集群:

#./redis-trib.rb create --replicas 1 10.168.32.116:6379 10.168.32.117:6379 10.168.32.118:6379 10.168.32.119:6379 10.168.32.120:6379 10.168.32.121:6379

>>> Creating cluster

Connecting to node 10.168.32.116:6379: OK

Connecting to node 10.168.32.117:6379: OK

Connecting to node 10.168.32.118:6379: OK

Connecting to node 10.168.32.119:6379: OK

Connecting to node 10.168.32.120:6379: OK

Connecting to node 10.168.32.121:6379: OK

>>> Performing hash slots allocation on 6 nodes...

Using 3 masters:

10.168.32.121:6379

10.168.32.120:6379

10.168.32.119:6379

Adding replica 10.168.32.118:6379 to 10.168.32.121:6379

Adding replica 10.168.32.117:6379 to 10.168.32.120:6379

Adding replica 10.168.32.116:6379 to 10.168.32.119:6379

S: f3314ecda2ef4ea0ec140e06de3e4bf656a5e71b 10.168.32.116:6379

replicates a5a22ba976c05b1d495812241a8dd10a5d4a5b42

S: 314f957e1021b0c262e635ad4feeb340dfe5955c 10.168.32.117:6379

replicates 9880ecc98cde59e0d6341ba7c54bbcae9b27c877

S: 07634642c88fdf1b886d3db87dedc4b9857fce7c 10.168.32.118:6379

replicates b7f33a1b733fe4a51447a788e334fab625a984bc

M: a5a22ba976c05b1d495812241a8dd10a5d4a5b42 10.168.32.119:6379

slots:10923-16383 (5461 slots) master

M: 9880ecc98cde59e0d6341ba7c54bbcae9b27c877 10.168.32.120:6379

slots:5461-10922 (5462 slots) master

M: b7f33a1b733fe4a51447a788e334fab625a984bc 10.168.32.121:6379

slots:0-5460 (5461 slots) master

Can I set the above configuration? (type 'yes' to accept): yes 此次输入yes

>>> Nodes configuration updated

>>> Assign a different config epoch to each node

>>> Sending CLUSTER MEET messages to join the cluster

Waiting for the cluster to join...

>>> Performing Cluster Check (using node 10.168.32.116:6379)

M: f3314ecda2ef4ea0ec140e06de3e4bf656a5e71b 10.168.32.116:6379

slots: (0 slots) master

replicates a5a22ba976c05b1d495812241a8dd10a5d4a5b42

M: 314f957e1021b0c262e635ad4feeb340dfe5955c 10.168.32.117:6379

slots: (0 slots) master

replicates 9880ecc98cde59e0d6341ba7c54bbcae9b27c877

M: 07634642c88fdf1b886d3db87dedc4b9857fce7c 10.168.32.118:6379

slots: (0 slots) master

replicates b7f33a1b733fe4a51447a788e334fab625a984bc

M: a5a22ba976c05b1d495812241a8dd10a5d4a5b42 10.168.32.119:6379

slots:10923-16383 (5461 slots) master

M: 9880ecc98cde59e0d6341ba7c54bbcae9b27c877 10.168.32.120:6379

slots:5461-10922 (5462 slots) master

M: b7f33a1b733fe4a51447a788e334fab625a984bc 10.168.32.121:6379

slots:0-5460 (5461 slots) master

[OK] All nodes agree about slots configuration.

>>> Check for open slots...

>>> Check slots coverage...

[OK] All 16384 slots covered.

至此redis集群即搭建成功!

执行命令redis-cli -c -p 6379 cluster nodes,查看集群节点

[root@puppetmaster1 src]# redis-cli -c -h 10.168.32.116 -p 6379 cluster nodes

314f957e1021b0c262e635ad4feeb340dfe5955c 10.168.32.117:6379 slave 9880ecc98cde59e0d6341ba7c54bbcae9b27c877 0 1425114266105 5 connected

a5a22ba976c05b1d495812241a8dd10a5d4a5b42 10.168.32.119:6379 master - 0 1425114267205 4 connected 10923-16383

07634642c88fdf1b886d3db87dedc4b9857fce7c 10.168.32.118:6379 slave b7f33a1b733fe4a51447a788e334fab625a984bc 0 1425114265605 6 connected

b7f33a1b733fe4a51447a788e334fab625a984bc 10.168.32.121:6379 master - 0 1425114266205 6 connected 0-5460

f3314ecda2ef4ea0ec140e06de3e4bf656a5e71b 10.168.32.116:6379 myself,slave a5a22ba976c05b1d495812241a8dd10a5d4a5b42 0 0 1 connected

9880ecc98cde59e0d6341ba7c54bbcae9b27c877 10.168.32.120:6379 master - 0 1425114266505 5 connected 5461-10922

7:使用redis-cli命令进入集群环境

redis-cli -c -h 10.168.32.117 -p 6379

Redis集群操作节点

1:新增一个节点,IP为10.168.32.122,端口为6379

首先把需要添加的节点启动

cd /usr/local/redis/

#vi /usr/local/redis/redis.conf

bind 10.168.32.122

port 6379

启动redis

redis-server /usr/local/redis/redis.conf

将新节点添加到集群

cd /usr/local/redis/src

[root@puppetmaster1 src]# ./redis-trib.rb add-node 10.168.32.122:6379 10.168.32.116:6379

>>> Adding node 10.168.32.122:6379 to cluster 10.168.32.116:6379

Connecting to node 10.168.32.116:6379: OK

Connecting to node 10.168.32.117:6379: OK

Connecting to node 10.168.32.119:6379: OK

Connecting to node 10.168.32.118:6379: OK

Connecting to node 10.168.32.121:6379: OK

Connecting to node 10.168.32.120:6379: OK

>>> Performing Cluster Check (using node 10.168.32.116:6379)

S: f3314ecda2ef4ea0ec140e06de3e4bf656a5e71b 10.168.32.116:6379

slots: (0 slots) slave

replicates a5a22ba976c05b1d495812241a8dd10a5d4a5b42

S: 314f957e1021b0c262e635ad4feeb340dfe5955c 10.168.32.117:6379

slots: (0 slots) slave

replicates 9880ecc98cde59e0d6341ba7c54bbcae9b27c877

M: a5a22ba976c05b1d495812241a8dd10a5d4a5b42 10.168.32.119:6379

slots:10923-16383 (5461 slots) master

1 additional replica(s)

S: 07634642c88fdf1b886d3db87dedc4b9857fce7c 10.168.32.118:6379

slots: (0 slots) slave

replicates b7f33a1b733fe4a51447a788e334fab625a984bc

M: b7f33a1b733fe4a51447a788e334fab625a984bc 10.168.32.121:6379

slots:0-5460 (5461 slots) master

1 additional replica(s)

M: 9880ecc98cde59e0d6341ba7c54bbcae9b27c877 10.168.32.120:6379

slots:5461-10922 (5462 slots) master

1 additional replica(s)

[OK] All nodes agree about slots configuration.

>>> Check for open slots...

>>> Check slots coverage...

[OK] All 16384 slots covered.

Connecting to node 10.168.32.122:6379: OK

>>> Send CLUSTER MEET to node 10.168.32.122:6379 to make it join the cluster.

[OK] New node added correctly.

查看集群节点

[root@puppetmaster1 src]# redis-cli -c -h 10.168.32.116 -p 6379 cluster nodes

314f957e1021b0c262e635ad4feeb340dfe5955c 10.168.32.117:6379 slave 9880ecc98cde59e0d6341ba7c54bbcae9b27c877 0 1425114360107 5 connected

38c2f060533c24698334a16b26f678ae6bd7ec41 10.168.32.122:6379 master - 0 1425114361107 0 connected

a5a22ba976c05b1d495812241a8dd10a5d4a5b42 10.168.32.119:6379 master - 0 1425114361507 4 connected 10923-16383

07634642c88fdf1b886d3db87dedc4b9857fce7c 10.168.32.118:6379 slave b7f33a1b733fe4a51447a788e334fab625a984bc 0 1425114362507 6 connected

b7f33a1b733fe4a51447a788e334fab625a984bc 10.168.32.121:6379 master - 0 1425114360507 6 connected 0-5460

f3314ecda2ef4ea0ec140e06de3e4bf656a5e71b 10.168.32.116:6379 myself,slave a5a22ba976c05b1d495812241a8dd10a5d4a5b42 0 0 1 connected

9880ecc98cde59e0d6341ba7c54bbcae9b27c877 10.168.32.120:6379 master - 0 1425114362107 5 connected 5461-10922

删除redis集群节点

redis-trib.rb  del-node        host:port node_id

./redis-trib.rb del-node 10.168.32.122:6379 38c2f060533c24698334a16b26f678ae6bd7ec41

redis多机集群部署文档的更多相关文章

  1. Redis集群部署文档(Ubuntu15.10系统)

    Redis集群部署文档(Ubuntu15.10系统)(要让集群正常工作至少需要3个主节点,在这里我们要创建6个redis节点,其中三个为主节点,三个为从节点,对应的redis节点的ip和端口对应关系如 ...

  2. HP DL160 Gen9服务器集群部署文档

    HP DL160 Gen9服务器集群部署文档 硬件配置=======================================================Server        Memo ...

  3. Apache ZooKeeper 单机、集群部署文档

    简介: Apache ZooKeeper 是一个分布式应用的高性能协调服务,功能包括:配置维护.统一命名.状态同步.集群管理.仲裁选举等. 下载地址:http://apache.fayea.com/z ...

  4. kafka集群部署文档(转载)

    原文链接:http://www.cnblogs.com/luotianshuai/p/5206662.html Kafka初识 1.Kafka使用背景 在我们大量使用分布式数据库.分布式计算集群的时候 ...

  5. 二进制搭建一个完整的K8S集群部署文档

    服务器规划 角色 IP 组件 k8s-master1 192.168.31.63 kube-apiserver kube-controller-manager kube-scheduler etcd ...

  6. 从零开始,无DNS vcenter 6.7 vmotion热迁移,存储集群部署文档。

    1,环境准备 准备:Vmware workstation环境 IP地址段规划 ESXI主机IP地址段 192.168.197.4-192.168.197.10 Vcenter Server集群IP地址 ...

  7. Apache Hadoop 集群安装文档

    简介: Apache Hadoop 集群安装文档 软件:jdk-8u111-linux-x64.rpm.hadoop-2.8.0.tar.gz http://www.apache.org/dyn/cl ...

  8. 面试连环炮系列(二):你们的项目Redis做了集群部署吗

    你们的项目Redis做了集群部署吗? 我们有大量数据需要缓存,而单实例的容量毕竟是有限的,于是做了Redis集群部署. 采取的方案是什么,Codis还是Redis Cluster,为什么要选择这个方案 ...

  9. kafka集群搭建文档

    kafka集群搭建文档 一. 下载解压 从官网下载Kafka,下载地址http://kafka.apache.org/downloads.html 注意这里最好下载scala2.10版本的kafka, ...

随机推荐

  1. IaaS,PaaS,Saas 云服务的介绍

    云服务只是一个统称,可以分成三大类. IaaS:基础设施服务,Infrastructure-as-a-service PaaS:平台服务,Platform-as-a-service SaaS:软件服务 ...

  2. 了解CentOS服务器的基本信息

    简单描述了如何从CPU.内存.硬盘性能.负载方面去了解自己工作的服务器性能.这个很重要,必须了解机器的方方面面才能提高在自己运维工作效率. 一.查看linux服务器cpu详情 查看物理cpu个数: [ ...

  3. C调用Lua中的函数解析table

    Passing Tables to Lua Functions A use case that happens often is the passing of tables to and from L ...

  4. [转]eclipse中的常用快捷键

    1.选中你要加注释的区域,用ctrl+shift+C 会加上//注释2.先把你要注释的东西选中,用shit+ctrl+/ 会加上注释3.要修改在eclispe中的命令的快捷键方式我们只需进入windo ...

  5. PyVmomi 使用示例

    PyVmomi: VMware vSphere Python SDK 一.OverView 重点知识: 1.view_type = [vim.VirtualMachine] 2.content.vie ...

  6. 【反思】一个价值两天的BUG,无论工作还是学习C语言的朋友都看看吧!

    博文原创,转载请联系博主! 使用C语言也有两个年头了,BUG写出来过不少,也改过不少BUG.但是偏偏就是有这么一个BUG让我手头的项目停工了两天,原因从百度找到谷歌,资料从MAN手册找到RFC也没有找 ...

  7. 三维bfs

    胜利大逃亡 Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submi ...

  8. codeforces 54A

    题意:收到礼物的规则为每个假日必收到一份礼物,每K天里至少收到一份礼物,求出N天中收到的礼物的最小数量. 思路:将N天根据假日所在天数分为一段段,当假日与假日之间间隔天数hol[i]>-hol[ ...

  9. MySQL服务器调优思路

    1.mysqladmin -uroot ext|awk '/Queries/{q=$4}/Threads_connected/{c=$4}/Threads_running/{r=$4}END{prin ...

  10. unity3D中一些有用的设置

    edit-project setting-time:可以设置fixed update()每一帧执行的时间 timescale:时间流动速度,设置为0则运用了time.deltatime的动画计时器均停 ...