请参考波主的另一篇博客codis集群部署实战 - 入门篇
Codis 是一个分布式 Redis 解决方案, 对于上层的应用来说, 连接到 Codis Proxy 和连接原生的 Redis Server 没有显著区别 (不支持的命令列表), 上层应用可以像使用单机的 Redis 一样使用, Codis 底层会处理请求的转发, 不停机的数据迁移等工作, 所有后边的一切事情, 对于前面的客户端来说是透明的, 可以简单的认为后边连接的是一个内存无限大的 Redis 服务。
下载地址:www.redis.cn
[root@server8 ~]# tar -zxf redis-4.0.1.tar.gz
[root@server8 ~]# cd redis-4.0.1
[root@server8 redis-4.0.1]# make
[root@server8 redis-4.0.1]# make install
[root@server8 redis-4.0.1]# cd utils/
[root@server8 utils]# ./install_server.sh
[root@server8 utils]# cd /etc/redis
[root@server8 redis]# ls
6379.conf
[root@server8 utils]# vim /etc/redis/6379.conf
bind 0.0.0.0
[root@server8 redis]# /etc/init.d/redis_6379 restart
下载地址 :https://www.golangtc.com/download
根据你的操作系统选择响应的版合适版本,我选择的是go1.7rc5.linux-amd64.tar.gz 即1.7.5的
[root@server8 ~]# tar -C /usr/local -xzf go1.7rc5.linux-amd64.tar.gz
[root@server8 ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
[root@server8 ~]# export PATH=$PATH:/usr/local/go/bin
[root@server8 ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/go/bin
[root@server8 ~]# echo $GOPATH
[root@server8 ~]# export GOPATH=/usr/local/go/bin
[root@server8 ~]# echo $GOPATH
/usr/local/go/bin
[root@server8 ~]# vim /etc/profile
export GOROOT=/usr/local/go
export GOPATH=/usr/local/codis
export PATH=$PATH:/usr/local/go/bin
[root@server8 ~]# source /etc/profile
[root@server8 ~]# go version
go version go1.7rc5 linux/amd64
[root@server8 ~]# go env GOPATH
/usr/local/codis
[root@server8 ~]# go env GOROOT
/usr/local/go
说明Go 运行环境安装成功
下载地址: https://github.com/CodisLabs/codis
https://codeload.github.com/CodisLabs/codis/zip/release3.2
[root@server8 ~]# yum install -y git autoconf
[root@server8 ~]# mkdir -p $GOPATH/src/github.com/CodisLabs
[root@server8 ~]# cd $GOPATH/src/github.com/CodisLabs
[root@server8 CodisLabs]# git clone https://github.com/CodisLabs/codis.git -b release3.1
##或者
[root@server8 ~]# wget https://codeload.github.com/CodisLabs/codis/zip/release3.2
[root@server8 ~]# mkdir -p $GOPATH/src/Codis
[root@server8 ~]# unzip codis-release3.2.zip -d /usr/local/codis/src/Codis
[root@server8 ~]# cd $GOPATH/Codis/codis-release3.2
[root@server8 codis-release3.2]# ls
admin cmd deploy Dockerfile extern kubernetes MIT-LICENSE.txt README.md vendor wandoujia_license.txt
ansible config doc example Godeps Makefile pkg scripts version
[root@server8 codis-release3.2]# pwd
/usr/local/codis/src/Codis/codis-release3.2
值得注意的是: 通过这两种方法下载的源码位置不一样,根据具体情况来,这里我是通过第一种方法下载的,所以我的编译时进入的路径是 $GOPATH/src/github.com/CodisLabs/codismake 如果你用的是第一种方法,那么你需要进入的相应的路径是 /usr/local/codis/src/Codis/codis-release3.2
[root@server8 ~]# cd $GOPATH/src/github.com/CodisLabs/codis
[root@server8 codis]# make
JEMALLOC_PRIVATE_NAMESPACE
: je_
install_suffix :
malloc_conf :
autogen : 1
cc-silence : 1
debug : 0
code-coverage : 0
stats : 1
prof : 0
prof-libunwind : 0
prof-libgcc : 0
prof-gcc : 0
tcache : 1
fill : 1
utrace : 0
valgrind : 0
xmalloc : 0
munmap : 0
lazy_lock : 0
tls : 1
cache-oblivious : 1
===============================================================================
go build -i -o bin/codis-dashboard ./cmd/dashboard
go build -i -o bin/codis-proxy ./cmd/proxy
go build -i -o bin/codis-admin ./cmd/admin
go build -i -o bin/codis-ha ./cmd/ha
go build -i -o bin/codis-fe ./cmd/fe
[root@server8 codis]# cat bin/version ##查看安装以后的版本
version = 2017-03-08 14:07:13 +0800 @b1919d11593dfd1f47a2461837233dfc8fc78002 @3.1.5-26-gb1919d1
compile = 2017-10-19 00:38:53 +0800 by go version go1.5.4 linux/amd64
[root@server8 codis]# mkdir -p /opt/local/codis/{bin,logs,data}/
[root@server8 codis]# cp -rf $GOPATH/src/github.com/CodisLabs/codis/bin/* /opt/local/codis/bin
[root@server8 codis]# cp -rf $GOPATH/src/github.com/CodisLabs/codis/config /opt/local/codis/
[root@server8 codis]# cd /opt/local/codis/config/
[root@server8 config]# vim dashboard.toml
##################################################
# #
# Codis-Dashboard #
# #
##################################################
# Set Coordinator, only accept "zookeeper" & "etcd" & "filesystem".
coordinator_name = "zookeeper"
coordinator_addr = "127.0.0.1:2181"
# Set Codis Product Name/Auth.
product_name = "codis-demo"
product_auth = ""
# Set bind address for admin(rpc), tcp only.
admin_addr = "0.0.0.0:18080"
# Set configs for redis sentinel.
sentinel_quorum = 2
sentinel_parallel_syncs = 1
sentinel_down_after = "30s"
sentinel_failover_timeout = "5m"
sentinel_notification_script = ""
sentinel_client_reconfig_script = ""
启动 Dashboard
[root@server8 config]# nohup /opt/local/codis/bin/codis-dashboard --ncpu=4 --config=/opt/local/codis/config/dashboard.toml --log=/opt/local/codis/logs/dashboard.log --log-level=WARN &
[root@server8 config]# vim /opt/local/codis/config/proxy.toml
# Set jodis address & session timeout, only accept "zookeeper" & "etcd".
jodis_name = "zookeeper"
jodis_addr = "127.0.0.1:2181"
jodis_timeout = "20s"
jodis_compatible = false
启动 codis-proxy
[root@server8 config]# nohup /opt/local/codis/bin/codis-proxy --ncpu=4 --config=/opt/local/codis/config/proxy.toml --log=/opt/local/codis/logs/proxy.log --log-level=WARN &
查看日至
[root@server8 ~]# cat /opt/local/codis/logs/proxy.log.2017-10-19
2017/10/19 01:04:46 main.go:206: [WARN] [0xc82023a6c0] proxy waiting online ...
2017/10/19 01:04:47 main.go:206: [WARN] [0xc82023a6c0] proxy waiting online ...
必须添加到集群中,才正常