Codis集群的搭建与使用
2015-04-23 17:29
337 查看
一、简介
Codis是一个分布式的Redis解决方案,对于上层的应用来说,连接Codis Proxy和连接原生的Redis Server没有明显的区别(不支持的命令列表),上层应用可以像使用单机的Redis一样使用,Codis底层会处理请求的转发,不停机的数据迁移等工作,所有后边的一切事情,对于前面客户端来说是透明的,可以简单的认为后边连接是一个内存无限大的Redis服务。
Codis架构图:
View Code
总结:
一、搭建环境前,先好好看一下codis的资料还有zookeeper的资料,思路理清了,搭建起来就没那么吃力了,刚刚开始时,我纠结了N久zookeeper到底有什么用,哈哈,好好看看相关的资料就明白它的作用了。
二、codis还有别的测试,我上面就不一一写出了,如果上线到生产环境中,一定要做好各种测试,希望大家也能够把自己研究出来的东西分享出来,一起学习,一起进步^.^。
三、 reids-cluster计划在redis3.0中推出了,因为刚推出不久,相信会存在不少的坑,所以生产环境中的redis集群可以考虑豌豆荚开源的codis,还有Twitter开源的twemproxy,这两个已经有很多公司在线上使用了,推荐大家使用,后期会补上twemproxy的博客。
参考资料:
codis官网:https://github.com/wandoulabs/codis
https://github.com/wandoulabs/codis/blob/master/doc/tutorial_zh.md https://github.com/wandoulabs/codis/blob/master/doc/FAQ_zh.md http://xmarker.blog.163.com/blog/static/226484057201422491547716/ (redis压力测试)
Codis是一个分布式的Redis解决方案,对于上层的应用来说,连接Codis Proxy和连接原生的Redis Server没有明显的区别(不支持的命令列表),上层应用可以像使用单机的Redis一样使用,Codis底层会处理请求的转发,不停机的数据迁移等工作,所有后边的一切事情,对于前面客户端来说是透明的,可以简单的认为后边连接是一个内存无限大的Redis服务。
Codis架构图:
5.1.1 server: 主要用来添加,删除,提权,查找 server group(实际操作zookeeper) root@codis-3:/usr/local/codis/bin# ./codis-config server --help codis-config server list codis-config server add <group_id> <redis_addr> <role> codis-config server remove <group_id> <redis_addr> codis-config server promote <group_id> <redis_addr> codis-config server add-group <group_id> codis-config server remove-group <group_id> 5.1.2 slot: 主要用来初始化,迁移,设置range-set,查询slot [root@redis-slave bin]# ./codis-config slot --help usage: codis-config slot init [-f] codis-config slot info <slot_id> codis-config slot set <slot_id> <group_id> <status> codis-config slot range-set <slot_from> <slot_to> <group_id> <status> codis-config slot migrate <slot_from> <slot_to> <group_id> [--delay=<delay_time_in_ms>] codis-config slot rebalance [--delay=<delay_time_in_ms>] 5.1.3 dashboard: 主要用来启动dashboard [root@redis-slave bin]# ./codis-config dashboard --help usage: codis-config dashboard [--addr=<address>] [--http-log=<log_file>] options: --addr listen ip:port, e.g. localhost:12345, :8086, [default: :8086] --http-log http request log [default: request.log ] 5.1.4 action: 主要用来操作codis保存的事件记录,并解除zk锁(迁移异常会出现锁) [root@redis-slave bin]# ./codis-config action --help usage: codis-config action (gc [-n <num> | -s <seconds>] | remove-lock) options: gc: gc -n N gc -s Sec keep last N actions; keep last Sec seconds actions; remove-lock force remove zookeeper lock; 5.1.5 proxy: 主要用来实现proxy上线,下线,查询 [root@redis-slave bin]# ./codis-config proxy usage: codis-config proxy list codis-config proxy offline <proxy_name> codis-config proxy online <proxy_name> 5.2 codis-proxy 主要用来启动 proxy 进程 [root@redis-slave bin]# ./codis-proxy --help usage: proxy [-c <config_file>] [-L <log_file>] [--log-level=<loglevel>] [--cpu=<cpu_num>] [--addr=<proxy_listen_addr>] [--http-addr=<debug_http_server_addr>] options: -cset config file -Lset output log file, default is stdout --log-level=<loglevel> set log level: info, warn, error, debug [default: info] --cpu=<cpu_num> num of cpu cores that proxy can use --addr=<proxy_listen_addr> proxy listen address, example: 0.0.0.0:9000 --http-addr=<debug_http_server_addr> debug vars http server 5.3 codis-server 主要用来启动 codis(redis 实例) [root@redis-slave bin]# ./codis-server --help Usage: ./redis-server [/path/to/redis.conf] [options] ./redis-server - (read config from stdin) ./redis-server -v or --version ./redis-server -h or --help ./redis-server --test-memory <megabytes> Examples: ./redis-server (run the server with default conf) ./redis-server /etc/redis/6379.conf ./redis-server --port 7777 ./redis-server --port 7777 --slaveof 127.0.0.1 8888 ./redis-server /etc/myredis.conf --loglevel verbose Sentinel mode: ./redis-server /etc/sentinel.conf –sentinel 5.4 codis-ha 主要来实现 server_group 中的主从 ha [root@redis-slave bin]# ./codis-ha --help Usage of ./codis-ha: -codis-config="localhost:18087": api server address -productName="test": product name, can be found in codis-proxy's config [root@redis-slave bin]#
View Code
总结:
一、搭建环境前,先好好看一下codis的资料还有zookeeper的资料,思路理清了,搭建起来就没那么吃力了,刚刚开始时,我纠结了N久zookeeper到底有什么用,哈哈,好好看看相关的资料就明白它的作用了。
二、codis还有别的测试,我上面就不一一写出了,如果上线到生产环境中,一定要做好各种测试,希望大家也能够把自己研究出来的东西分享出来,一起学习,一起进步^.^。
三、 reids-cluster计划在redis3.0中推出了,因为刚推出不久,相信会存在不少的坑,所以生产环境中的redis集群可以考虑豌豆荚开源的codis,还有Twitter开源的twemproxy,这两个已经有很多公司在线上使用了,推荐大家使用,后期会补上twemproxy的博客。
参考资料:
codis官网:https://github.com/wandoulabs/codis
https://github.com/wandoulabs/codis/blob/master/doc/tutorial_zh.md https://github.com/wandoulabs/codis/blob/master/doc/FAQ_zh.md http://xmarker.blog.163.com/blog/static/226484057201422491547716/ (redis压力测试)
作者:陆炫志 出处:xuanzhi的博客 http://www.cnblogs.com/xuanzhi201111 您的支持是对博主最大的鼓励,感谢您的认真阅读。本文版权归作者所有,欢迎转载,但请保留该声明。 |
相关文章推荐
- Codis集群的搭建与使用
- codis集群的搭建与使用
- Centos6下Codis集群的搭建与使用(二)
- Codis集群的搭建与使用
- Codis集群的搭建与使用
- Codis集群的搭建与使用
- Redis集群方案之使用豌豆荚Codis搭建(待实践)
- Redis之Codis集群的搭建与使用-yellowcong
- Codis集群的搭建与使用
- Codis集群的搭建与使用
- Centos6下Codis集群的搭建与使用(一)
- [Big Data - Codis] Codis集群的搭建与使用
- Codis集群的搭建与使用
- Codis集群的搭建与使用
- Codis集群的搭建与使用
- kafka入门:简介、使用场景、设计原理、主要配置及集群搭建
- Codis 集群搭建
- 使用ubuntu+haproxy+heartbeat搭建大规模WEB集群环境实现负载均衡。
- 搭建及使用K8s集群 <k8s集群搭建>
- 使用docker 1.12 搭建多主机docker swarm集群