环境
系统:CentOS 6.8
软件:codis3.1
准备
-
安装git
# yum insatll git
-
安装zookeeper
参见:http://www.jianshu.com/p/0079b1ecb9ec
本文zookeeper集群地址:10.10.10.21:2181,10.10.10.22:2181,10.10.10.23:2181 -
安装godep
- 方法一:在线安装
# go get -u github.com/tools/godep
- 方法二:离线安装
- 运行
git clone https://github.com/tools/godep.git
下载 godep 源码 - 将 godep 目录移动到 $GOPATH/src/github.com/tools/godep,并进入该目录
- 运行命令
go install ./
,该命令会将 godep 生成到 $GOPATH/bin 下
- 运行
codis安装
-
安装
# mkdir -p $GOPATH/src/github.com/CodisLabs # cd $_ # git clone https://github.com/CodisLabs/codis.git -b release3.1 # make
-
配置环境变量
# vim /etc/profile export PATH=$GOPATH/src/github.com/CodisLabs/codis/bin:$PATH # source /etc/profile
codis配置启动
-
进入codis目录
# cd $GOPATH/src/github.com/CodisLabs/codis
-
codis dashboard配置启动
-
配置
# vim config/dashboard.toml coordinator_name = "zookeeper" coordinator_addr = "10.10.10.21:2181,10.10.10.22:2181,10.10.10.23:2181" product_name = "codis-demo" product_auth = "123456"
-
启动
# nohup ./bin/codis-dashboard --ncpu=4 --config=config/dashboard.toml --log=logs/dashboard.log --log-level=WARN &
-
-
codis proxy配置启动
-
配置
# vim config/proxy.toml product_name = "codis-demo" product_auth = "123456" jodis_name = "zookeeper" jodis_addr = "10.10.10.21:2181,10.10.10.22:2181,10.10.10.23:2181"
-
启动
# nohup ./bin/codis-proxy --ncpu=4 --config=config/proxy.toml --log=logs/proxy.log --log-level=WARN &
-
-
codis server配置启动
-
配置
# vim config/redis.conf bind 0.0.0.0 port 6379 daemonize yes pidfile /var/run/redis-6379.pid dir /data/redis-data/redis-6379/ requirepass 123456
-
启动
# mkdir /data/redis-data/redis-6379 # ./bin/codis-server ./config/redis.conf
-
-
codis fe配置启动
-
创建配置文件
# vim config/codis.json [ { "name": "codis-demo", "dashboard": "127.0.0.1:18080" } ]
-
启动
# nohup ./bin/codis-fe --ncpu=4 --log=logs/fe.log --log-level=WARN --dashboard-list=config/codis.json --listen=0.0.0.0:8080 &
-
codis集群配置
登陆codis fe,http://10.10.10.10:8080
在codis fe上完成codis proxy添加、group添加、codis server添加、slots划分等集群配置操作
说明
-
codis架构
1个codis集群=1个zookeeper(或1个zookeeper集群) + 1个codis dashboard + n个codis proxy + n个codis server + 1个Codis FE(可选) -
可复用组件
codis fe可复用:多个codis dashboard可添加到1个codis fe上
zookeeper可复用:多个codis集群可注册到1个zookeeper上,product_name需不同 -
java客户端jodis配置信息
zookeeper地址:10.10.10.21:2181,10.10.10.22:2181,10.10.10.23:2181
zookeeper中proxy地址:/jodis/{product_name}
网友评论