搭建redis集群环境
2017-02-24 00:00
447 查看
摘要: 闲来无事^_^
创建集群,出错
开始创建节点
重新创建redis集群
搭建redis集群环境
伪集群,单机上搭建,没多的机器
说明
Redis3.0版本之后支持Cluster 当前版本3.2.8 redis集群搭建最少6个节点其中3个主节点
修改配置
接上文redis环境搭建 redis1配置 打开集群配置 port 7001 cluster-enabled yes cluster-config-file nodes-7001.conf cluster-node-timeout 5000 redis2配置 port 7002 cluster-enabled yes cluster-config-file nodes-7002.conf cluster-node-timeout 5000 redis3配置 port 7003 cluster-enabled yes cluster-config-file nodes-7003.conf cluster-node-timeout 5000
启动redis
cd redis1 ./redis-server redis.conf cd redis2 ./redis-server redis.conf cd redis3 ./redis-server redis.conf
查看服务是否正常
ps -ef|grep redis 查看redis进程
创建集群
官方有提供工具redis-trib.rb,采用ruby编写,so安装ruby
安装ruby
yum -y install ruby ruby-devel rubygems rpm-build
通过ruby命令工具安装redis
gem install redis
通过redis-trib.rb 创建集群
查看命令参数
[root@vultr src]# ./redis-trib.rb Usage: redis-trib <command> <options> <arguments ...> set-timeout host:port milliseconds reshard host:port --pipeline <arg> --to <arg> --yes --slots <arg> --from <arg> --timeout <arg> del-node host:port node_id add-node new_host:new_port existing_host:existing_port --slave --master-id <arg> fix host:port --timeout <arg> help (show this help) rebalance host:port --pipeline <arg> --simulate --auto-weights --use-empty-masters --weight <arg> --timeout <arg> --threshold <arg> check host:port info host:port create host1:port1 ... hostN:portN --replicas <arg> import host:port --replace --copy --from <arg> call host:port command arg arg .. arg For check, fix, reshard, del-node, set-timeout you can specify the host and port of any working node in the cluster.
创建集群,出错
./redis-trib.rb create --replicas 1 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 *** ERROR: Invalid configuration for cluster creation. *** Redis Cluster requires at least 3 master nodes. *** This is not possible with 3 nodes and 1 replicas per node. *** At least 6 nodes are required. 至少需要6个节点
开始创建节点
重新创建redis集群
测试
1.通过redis-cli链接redis redis-cli -c -p 7001 [root@vultr bin]# redis-cli -c -p 7001 127.0.0.1:7001> set name kite -> Redirected to slot [5798] located at 127.0.0.1:7002 OK 127.0.0.1:7002> get name "kite" 127.0.0.1:7002> exit [root@vultr bin]# redis-cli -c -p 7003 127.0.0.1:7003> get name -> Redirected to slot [5798] located at 127.0.0.1:7002 "kite" 127.0.0.1:7002> 已经进行同步
参考
Redis 3.2.1集群搭建相关文章推荐
- Java + Redis3.0.2集群的应用(一)——Redis集群环境的搭建
- redis集群环境搭建以及java中jedis客户端集群代码实现
- Redis3.2+Tomcat实现集群的Session管理 -- tomcat-redis-session-manager的编译和开发部署环境搭建
- Linux环境redis集群搭建
- redis常用命令及安全Redis集群环境搭建
- 1、Redis 集群环境的搭建
- redis之(十六)redis的cluster集群环境的搭建,转载
- redis集群环境的搭建和错误分析
- Centos7 搭建Redis3.2.0版本集群环境
- 搭建redis集群环境
- redis集群环境搭建
- 【redis】 linux 下redis 集群环境搭建
- Redis-3.0.6 集群部署集成SpringJava工程-----环境搭建
- Redis集群环境搭建
- redis集群环境搭建
- redis集群环境搭建以及java中jedis客户端集群代码实现
- Redis3.0《集群环境搭建》
- Redis 3.0 cluster 集群环境搭建
- redis 集群环境搭建-redis集群管理