yum install autoconf automake libtool -y yum install -y gcc glibc gcc-c++ make git
tar -zxf jdk-8u152-linux-x64.tar.gz
JAVA_HOME=/opt/jdk1.8.0_152 CLASSPATH=$JAVA_HOME/lib/ PATH=$PATH:$JAVA_HOME/bin export PATH JAVA_HOME CLASSPATH
source /etc/profile
java -version
tar -zxf go1.9.2.linux-amd64.tar.gz
GOROOT=/opt/go GOPATH=/opt/gopath PATH=$PATH:$GOROOT/bin export PATH GOROOT GOPATH
source /etc/profile
go version
tar -zxf zookeeper-3.4.6.tar.gz
cd /opt/zookeeper-3.4.6 ./bin/zkServer.sh conf/zoo.cfg
mkdir -p $GOPATH/src/github.com/CodisLabs cd $GOPATH/src/github.com/CodisLabs git clone https://github.com/CodisLabs/codis.git -b release3.2
cd $GOPATH/src/github.com/CodisLabs/codis make make gotest
dashboard 是仪表盘,可以把其他服务绑定到监控仪表盘来进行服务管理及监控。
coordinator_name = "zookeeper" coordinator_addr = "127.0.0.1:2181" product_name = "codis-demo" product_auth = "" admin_addr = "0.0.0.0:18080"
cd $GOPATH/src/github.com/CodisLabs/codis mkdir log nohup ./bin/codis-dashboard --ncpu=1 --config=config/dashboard.toml --log=log/dashboard.log --log->level=WARN &
proxy是对外提供redis服务的入口。
jodis_name = "zookeeper" jodis_addr = "127.0.0.1:2181" product_name = "codis-demo" product_auth = "" admin_addr = "0.0.0.0:11080" proto_type = "tcp4" proxy_addr = "0.0.0.0:19000"
cd $GOPATH/src/github.com/CodisLabs/codis nohup ./bin/codis-proxy --ncpu=2 --config=config/proxy.toml --log=log/proxy.log --log-level=WARN &
cd $GOPATH/src/github.com/CodisLabs/codis ./bin/codis-admin --dashboard=100.100.10.85:18080 --create-proxy -x 100.100.10.85:11080
注意:不可使用原生redis
cd $GOPATH/src/github.com/CodisLabs/codis mkdir redis mkdir -pv redis/redis_638{1..4} cp config/redis.conf redis/redis_6381/ cp config/redis.conf redis/redis_6382/ cp config/redis.conf redis/redis_6383/ cp config/redis.conf redis/redis_6384/
pidfile "/opt/gopath/src/github.com/CodisLabs/codis/redis/redis_6381/redis_6381.pid" daemonize yes protected-mode no port 6381 dbfilename "dump_6381.rdb" dir "/opt/gopath/src/github.com/CodisLabs/codis/redis/redis_6381" logfile "/opt/gopath/src/github.com/CodisLabs/codis/redis/redis_6381/redis_6381.log" maxmemory 1953125kb
cd $GOPATH/src/github.com/CodisLabs/codis ./bin/codis-server redis/redis_6381/redis.conf ./bin/codis-server redis/redis_6382/redis.conf ./bin/codis-server redis/redis_6383/redis.conf ./bin/codis-server redis/redis_6384/redis.conf
ha用来监控redis主从,在主挂了以后自动切换到从;
nohup ./bin/codis-ha --interval=5 --dashboard=127.0.0.1:18080 --log=log/ha.log --log-level=WARN &
[页面管理工具][CPU核心数可以指定,按需配置]
cd $GOPATH/src/github.com/CodisLabs/codis nohup ./bin/codis-fe --ncpu=1 --log=log/fe.log --log-level=WARN --zookeeper=127.0.0.1:2181 -->listen=0.0.0.0:80 &
codis-proxy 对外提供redis服务,直接使用redis client链接codis-proxy即可,但是部分命令不能使用;
./src/redis-cli -h x.x.x.x -p 19000
页面访问 x.x.x.x:80/#codis-demo
zookeeper集群搭建不再详述,如果使用zookeeper集群,config/dashboard.toml , config/proxy.toml 中关于zookeeper的配置从单点变为集群即可
dashboard.toml
coordinator_name = "zookeeper" coordinator_addr = "127.0.0.1:2181,127.0.0.1:2182,127.0.0.1:2183"
proxy.toml
jodis_name = "zookeeper" jodis_addr = "127.0.0.1:2181,127.0.0.1:2182,127.0.0.1:2183"
多台服务器构建一个codis集群,所有服务器都需要安装codis环境;按照上述步骤在每台服务器上安装codis即可。
需要注意的是:
按照上述启动步骤,启动多个proxy后,在页面或者命令行将proxy绑定到dashboard即可使用;
在配置上,所有proxy仅注册到同一个zookeeper,即可使用;
每一个proxy单独对外提供服务,推荐在多个proxy前面提供ha服务进行负载均衡;
按照上述启动步骤,启动多个redis后,在页面配置redis具体的分布;
https://www.cnblogs.com/reblue520/p/6874925.html