Codis部署
评论(0) 浏览量(4415)

GITHUB地址:https://github.com/CodisLabs/codis


codis部署文档:https://github.com/CodisLabs/codis/blob/master/doc/tutorial_zh.md


codis部署流程:

1、安装go,配置环境变量

2、执行go get -u -d github.com/CodisLabs/codis下载codis代码

3、切换到$GOPATH/src/github.com/CodisLabs/codis目录执行make命令编译代码,并执行make gotest来跑测试

4、安装zookeeper

5、codis启动,配置

1)启动 dashboard

$ bin/codis-config dashboard

2)启动 Codis Redis

$ bin/codis-server /etc/redis/6379.conf 
$ bin/codis-server /etc/redis/16379.conf 
$ bin/codis-server /etc/redis/6380.conf 
$ bin/codis-server /etc/redis/16380.conf

 

3)添加 Redis Server Group

$ bin/codis-config server add 1 localhost:6379 master
$ bin/codis-config server add 1 localhost:16379 slave
$ bin/codis-config server add 2 localhost:6380 master
$ bin/codis-config server add 2 localhost:16380 slave


4)设置 server group 服务的 slot 范围

$ bin/codis-config slot range-set 0 511 1 online
$ bin/codis-config slot range-set 512 1023 2 online


5)启动 codis-proxy

第一个代理:

nohup bin/codis-proxy -c config.ini -L ./proxy.log --cpu=2 --addr=0.0.0.0:19000 --http-addr=0.0.0.0:11000 &
bin/codis-config -c config.ini proxy online proxy_1

配置文件:

##### Properties below are for dashboard and proxies
# zookeeper or etcd
coordinator=zookeeper
# Use comma "," for multiple instances. If you use etcd, you should also use this property.
zk=192.168.0.123:2181
product=test
# This addr is used for codis's proxies and commands, which should be host:port, host can not be 0.0.0.0 or omited.
# The address/port which is listened by dashborad service whose host can be omited depends on the "--addr" in its start command arguments.
dashboard_addr=192.168.0.123:18087
password=test
##### Properties below are only for proxies
# Proxy will ping-pong backend redis periodly to keep-alive
backend_ping_period=5
# If there is no request from client for a long time, the connection will be droped. Set 0 to disable.
session_max_timeout=1800
# Buffer size for each client connection.
session_max_bufsize=131072
# Number of buffered requests for each client connection.
# Make sure this is higher than the max number of requests for each pipeline request, or your client may be blocked.
session_max_pipeline=1024
# If proxy don't send a heartbeat in timeout millisecond which is usually because proxy has high load or even no response, zk will mark this proxy offline.
# A higher timeout will recude the possibility of "session expired" but clients will not know the proxy has no response in time if the proxy is down indeed.
# So we highly recommend you not to change this default timeout and use Jodis(https://github.com/CodisLabs/jodis)
# which watches the available proxies and will skip the offline proxy or add new online proxy automatically.
# If you are not using Java in client, you can DIY a zk watcher accourding to Jodis source code.
zk_session_timeout=30000
##### must be different for each proxy
proxy_id=proxy_1

第二个代理:

nohup bin/codis-proxy -c config.ini -L ./proxy.log --cpu=2 --addr=0.0.0.0:19000 --http-addr=0.0.0.0:11000 &
bin/codis-config -c config.ini proxy online proxy_2

配置文件

##### Properties below are for dashboard and proxies
# zookeeper or etcd
coordinator=zookeeper
# Use comma "," for multiple instances. If you use etcd, you should also use this property.
zk=192.168.0.123:2181
product=test
# This addr is used for codis's proxies and commands, which should be host:port, host can not be 0.0.0.0 or omited.
# The address/port which is listened by dashborad service whose host can be omited depends on the "--addr" in its start command arguments.
dashboard_addr=192.168.0.123:18087
password=
##### Properties below are only for proxies
# Proxy will ping-pong backend redis periodly to keep-alive
backend_ping_period=5
# If there is no request from client for a long time, the connection will be droped. Set 0 to disable.
session_max_timeout=1800
# Buffer size for each client connection.
session_max_bufsize=131072
# Number of buffered requests for each client connection.
# Make sure this is higher than the max number of requests for each pipeline request, or your client may be blocked.
session_max_pipeline=1024
# If proxy don't send a heartbeat in timeout millisecond which is usually because proxy has high load or even no response, zk will mark this proxy offline.
# A higher timeout will recude the possibility of "session expired" but clients will not know the proxy has no response in time if the proxy is down indeed.
# So we highly recommend you not to change this default timeout and use Jodis(https://github.com/CodisLabs/jodis)
# which watches the available proxies and will skip the offline proxy or add new online proxy automatically.
# If you are not using Java in client, you can DIY a zk watcher accourding to Jodis source code.
zk_session_timeout=30000
##### must be different for each proxy
proxy_id=proxy_2

6、打开浏览器

访问http://localhost:18087/admin , 现在可以在浏览器里面完成各种操作了。


没有登录不能评论