1、準備工作
IP | 服務列表 |
---|---|
10.1.62.186 | zk1、dashboard、proxy、server、fe |
10.1.62.187 | zk2、proxy、server |
10.1.62.188 |
zk3、proxy、server |
2、codis安裝
- 解壓
mv /home/codis/codis3.2.2-go1.9.2-linux.tar.gz /usr/codis/
tar -zxvf /usr/codis/codis3.2.2-go1.9.2-linux.tar.gz
2、codis dashboard(1臺)
- dashboard.toml編輯
./codis-dashboard --default-config | tee dashboard.toml
coordinator_name = "zookeeper"
coordinator_addr = "10.1.62.186:2181"
product_name = "codis-demo"
product_auth = ""
admin_addr = "10.1.62.186:18080"
# Set arguments for data migration (only accept 'sync' & 'semi-async').
migration_method = "semi-async"
migration_parallel_slots = 100
migration_async_maxbulks = 200
migration_async_maxbytes = "32mb"
migration_async_numkeys = 500
migration_timeout = "30s"
# Set configs for redis sentinel.
sentinel_client_timeout = "10s"
sentinel_quorum = 2
sentinel_parallel_syncs = 1
sentinel_down_after = "30s"
sentinel_failover_timeout = "5m"
sentinel_notification_script = ""
sentinel_client_reconfig_script = ""
- 啓動dashboard
nohup ./codis-dashboard --ncpu=4 --config=dashboard.toml \
--log=dashboard.log --log-level=WARN &
PS:dashboard停止,這裏必須使用命令來停止dashboard,不然會報錯。原因是已經在zk中註冊了,但是沒有正常關閉的話,zk中的信息就不能刪除,再次啓動會報錯。
./codis-admin –dashboard=10.1.62.186:18080 –shutdown
2.2、codis proxy(3臺)
- proxy.toml編輯(以10.1.62.186爲例)
./codis-proxy --default-config | tee proxy.toml
# Set bind address for admin(rpc), tcp only.
admin_addr = "10.1.62.186:11080"
# Set bind address for proxy, proto_type can be "tcp", "tcp4", "tcp6", "unix" or "unixpacket".
proto_type = "tcp4"
proxy_addr = "10.1.62.186:19000"
- 啓動proxy
nohup ./codis-proxy --ncpu=4 --config=proxy.toml \
--log=proxy.log --log-level=WARN &
2.3、codis server
與啓動普通 redis 的方法一致,啓動完成後,可以通過 codis-fe 提供的界面或者 codis-admin 命令行工具添加到集羣中。
./codis-server ./config/redis.conf
#新建redis.conf文件,可以拷貝redis中的redis.conf,主要修改bind與保護模式
bind 10.1.62.186
protected-mode no
2.4、codis fe
nohup ./codis-fe --ncpu=4 --log=fe.log --log-level=WARN \
--zookeeper=10.1.62.186:2181 --listen=10.1.62.186:8080 &
http://10.1.62.186:8080
3、使用
- 添加proxy
- 通過redis-cli訪問proxy
./redis-cli -h 10.1.62.186 -p 19000
set hello world