10.6.12.119 (安装zk,codis-server-master,codis-dashboard,codis-proxy,codis-fe)
10.6.12.120 (安装zk,codis-server-master,codis-proxy)
10.6.12.121 (安装zk,codis-server-master,codis-proxy)
10.6.12.122 (安装zk,codis-server-slave作为120的从库)测试
关闭防火墙
systemctl stop firewalld
安装jdk
步骤省略
下载一个zookeeper的安装包
mv zookeeper-3.4.14.tar.gz /usr/local
cd /usr/local
tar zxvf zookeeper-3.4.14.tar.gz
cd zookeeper-3.4.14
mkdir data
mkdir logs
cd conf
touch zoo.cfg
vim zoo.cfg
tickTime=2000 dataDir=/usr/local/zookeeper-3.4.14/data dataLogDir=/usr/local/zookeeper-3.4.14/logs clientPort=2181 initLimit=5 syncLimit=2 quorumListenOnAllIPs=true server.1=10.6.12.119:2888:3888 server.2=10.6.12.120:2888:3888 server.3=10.6.12.121:2888:3888 server.4=10.6.12.122:2888:3888 |
cd /usr/local/zookeeper-3.4.14
新建data/myid
#10.6.12.119
echo '1' > data/myid
#10.6.12.120
echo '2' > data/myid
#10.6.12.121
echo '3' > data/myid
#10.6.12.122
echo '4' > data/myid
依次启动
cd bin
./zkServer.sh start
全部启动之后
/usr/local/zookeeper-3.4.14/bin/zkServer.sh status
查看选出的leader 121
安装go
go安装目录/usr/local/go:
tar -zxf go1.9.1.linux-amd64.tar.gz -C /usr/local/
在/etc/profile文件末尾加配置
echo '
export GOPATH=/usr/local/codis
export GOROOT=/usr/local/go
export PATH=$PATH:/usr/local/go/bin
' >> /etc/profile
#使/etc/profile马上生效----------------------------------------------------------------------
source /etc/profile
重新加载/etc/profile
source /etc/profile
检测是否安装成功
go version
安装codis3.2
1、安装依赖
yum install autoconf automake libtool -y
yum install -y gcc glibc gcc-c++ make git
2、设置编译环境
下载并编译codis(codis-config、codis-proxy、codis-serve)
codis编译目录必须为$GOPATH/src/github.com/CodisLabs,否则编译时报找不到目录,
将codis-release3.2.zip解压到此目录后改名为codis:
unzip codis-release3.2.zip
mkdir -p $GOPATH/src/github.com/CodisLabs
mv codis-release3.2 $GOPATH/src/github.com/CodisLabs/codis
3、编译Codis源码
cd $GOPATH/src/github.com/CodisLabs/codis
make
#复制文件,更改codis目录,方便管理
mkdir -p /usr/local/codis/{bin,logs,data}/
cp -rf $GOPATH/src/github.com/CodisLabs/codis/bin/* /usr/local/codis/bin
cp -rf $GOPATH/src/github.com/CodisLabs/codis/config /usr/local/codis/
安装dashboard
修改/usr/local/codis/config/dashboard.toml
################################################## # # # Codis-Dashboard # # # ##################################################
# Set Coordinator, only accept "zookeeper" & "etcd" & "filesystem". # for zookeeper/etcd, coorinator_auth accept "user:password" # Quick Start coordinator_name = "zookeeper" coordinator_addr = "10.6.12.119:2181,10.6.12.120:2181,10.6.12.121:2181,10.6.12.122:2181" product_name = "codis-demo" product_auth = "Hangzhou@123" admin_addr = "0.0.0.0:18080" migration_method = "semi-async" migration_parallel_slots = 100 migration_async_maxbulks = 200 migration_async_maxbytes = "32mb" migration_async_numkeys = 500 migration_timeout = "30s" 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 = "" |
启动
cd /usr/local/codis/logs
/usr/local/codis/bin/codis-dashboard --ncpu=2 --config=/usr/local/codis/config/dashboard.toml --log=/usr/local/codis/logs/dashboard.log --log-level=WARN &
coordinator name= zookeeper
/usr/local/codis/codis-admin --remove-lock --product=codis-demo --zookeeper=10.6.12.119:2181
安装proxy
/usr/local/codis/config/proxy.toml
#主机110 product_name = "codis-demo" product_auth = "Hangzhou@123" session_auth = "" admin_addr = "0.0.0.0:11080" proto_type = "tcp4" proxy_addr = "0.0.0.0:19000" jodis_name = "zookeeper" jodis_addr = "10.6.12.119:2181,10.6.12.120:2181,10.6.12.121:2181,10.6.12.122:2181" jodis_auth = "" jodis_timeout = "20s" jodis_compatible = true proxy_datacenter = "" proxy_max_clients = 1000 proxy_max_offheap_size = "1024mb" proxy_heap_placeholder = "256mb" backend_ping_period = "5s" backend_recv_bufsize = "128kb" backend_recv_timeout = "30s" backend_send_bufsize = "128kb" backend_send_timeout = "30s" backend_max_pipeline = 20480 backend_primary_only = false backend_primary_parallel = 1 backend_replica_parallel = 1 backend_keepalive_period = "75s" backend_number_databases = 16 session_recv_bufsize = "128kb" session_recv_timeout = "30m" session_send_bufsize = "64kb" session_send_timeout = "30s" session_max_pipeline = 10000 session_keepalive_period = "75s" session_break_on_failure = false metrics_report_server = "" metrics_report_period = "1s" metrics_report_influxdb_server = "" metrics_report_influxdb_period = "1s" metrics_report_influxdb_username = "" metrics_report_influxdb_password = "" metrics_report_influxdb_database = "" metrics_report_statsd_server = "" metrics_report_statsd_period = "1s" metrics_report_statsd_prefix = "" |
cd /usr/local/codis/logs/
nohup /usr/local/codis/bin/codis-proxy --ncpu=4 --config=/usr/local/codis/config/proxy.toml --log=/usr/local/codis/logs/proxy.log --log-level=WARN &
接着启动120和121的proxy
Codis-admin
关联proxy到dashboard
#主机10.6.12.119上执行
/usr/local/codis/bin/codis-admin --dashboard=10.6.12.119:18080 --create-proxy --addr=10.6.12.119:11080
加入之后 会从proxy waiting online ...变成proxy is working ...
同理在119上加入其余proxy
/usr/local/codis/bin/codis-admin --dashboard=10.6.12.119:18080 --create-proxy -x 10.6.12.120:11080 (用上面的命令也可以)
/usr/local/codis/bin/codis-admin --dashboard=10.6.12.119:18080 --create-proxy --addr=10.6.12.121:11080
如果出现报错 [Remote Error] topom is not online
/usr/local/codis/bin/codis-admin --remove-lock --product=codis-proxy --zookeeper=172.16.129.86:2181 即可
Codis-Server
即创建redis实例,每台主机都创建2个redis实例
mkdir -p /usr/local/codis/redis/6379
mkdir -p /usr/local/codis/redis/6380
cp $GOPATH/src/github.com/CodisLabs/codis/config/redis.conf /usr/local/codis/redis/6379
cp $GOPATH/src/github.com/CodisLabs/codis/config/redis.conf /usr/local/codis/redis/6380
修改/usr/local/codis/redis/6379/redis.conf配置文件
bind 0.0.0.0 protected-mode yes port 6379 tcp-backlog 511 timeout 0 tcp-keepalive 300 daemonize yes supervised no pidfile /usr/local/codis/redis/6379/redis.pid loglevel notice logfile "/usr/local/codis/redis/6379/redis.log" databases 16 save 900 1 save 300 10 save 60 10000 stop-writes-on-bgsave-error yes rdbcompression yes rdbchecksum yes dbfilename dump.rdb dir "/usr/local/codis/redis/6379/" slave-serve-stale-data yes slave-read-only yes repl-diskless-sync no repl-diskless-sync-delay 5 repl-disable-tcp-nodelay no slave-priority 100 appendonly no appendfilename "appendonly.aof" appendfsync everysec no-appendfsync-on-rewrite no auto-aof-rewrite-percentage 100 auto-aof-rewrite-min-size 64mb aof-load-truncated yes lua-time-limit 5000 slowlog-log-slower-than 10000 slowlog-max-len 128 latency-monitor-threshold 0 notify-keyspace-events "" hash-max-ziplist-entries 512 hash-max-ziplist-value 64 list-max-ziplist-size -2 list-compress-depth 0 set-max-intset-entries 512 zset-max-ziplist-entries 128 zset-max-ziplist-value 64 hll-sparse-max-bytes 3000 activerehashing yes client-output-buffer-limit normal 0 0 0 client-output-buffer-limit slave 256mb 64mb 60 client-output-buffer-limit pubsub 32mb 8mb 60 hz 10 aof-rewrite-incremental-fsync yes
requirepass "china2008" maxmemory 1gb |
修改/usr/local/codis/redis/6380/redis.conf配置文件
bind 0.0.0.0 protected-mode yes port 6380 tcp-backlog 511 timeout 0 tcp-keepalive 300 daemonize yes supervised no pidfile /usr/local/codis/redis/6380/redis.pid loglevel notice logfile "/usr/local/codis/redis/6380/redis.log" databases 16 save 900 1 save 300 10 save 60 10000 stop-writes-on-bgsave-error yes rdbcompression yes rdbchecksum yes dbfilename dump.rdb dir "/usr/local/codis/redis/6380/" slave-serve-stale-data yes slave-read-only yes repl-diskless-sync no repl-diskless-sync-delay 5 repl-disable-tcp-nodelay no slave-priority 100 appendonly no appendfilename "appendonly.aof" appendfsync everysec no-appendfsync-on-rewrite no auto-aof-rewrite-percentage 100 auto-aof-rewrite-min-size 64mb aof-load-truncated yes lua-time-limit 5000 slowlog-log-slower-than 10000 slowlog-max-len 128 latency-monitor-threshold 0 notify-keyspace-events "" hash-max-ziplist-entries 512 hash-max-ziplist-value 64 list-max-ziplist-size -2 list-compress-depth 0 set-max-intset-entries 512 zset-max-ziplist-entries 128 zset-max-ziplist-value 64 hll-sparse-max-bytes 3000 activerehashing yes client-output-buffer-limit normal 0 0 0 client-output-buffer-limit slave 256mb 64mb 60 client-output-buffer-limit pubsub 32mb 8mb 60 hz 10 aof-rewrite-incremental-fsync yes
requirepass "Hangzhou@123"#此处密码要和上面一致 否则会报密码错误 maxmemory 1gb |
启动codis-server
后面需要使用 Codis-fe或者Codis-admin 添加到集群
nohup /usr/local/codis/bin/codis-server /usr/local/codis/redis/6379/redis.conf &
nohup /usr/local/codis/bin/codis-server /usr/local/codis/redis/6380/redis.conf &
/usr/local/codis/bin/codis-fe --ncpu=4 --log=/usr/local/codis/logs/fe.log --log-level=WARN --zookeeper=10.6.12.119:2181 --listen=0.0.0.0:8888 &
访问http://10.6.12.119:8888
在fe界面查看、添加proxy代理服务。
proxy启动默认会自动注册到dashboard中,也可以在fe中手动添加,
“Proxy Admin Address”选项中分别填写如下内容,然后点击“New Proxy”按钮添加
10.6.12.119:11080
10.6.12.120:11080
10.6.12.120:11080
备注:主机的codis-proxy服务需要启动,11080端口是互通的,才能添加成功,结果如下:
部署codis-server加入集群
添加group
Group栏为空,因为我们启动的codis-server并未加入到集群,启动所有主机codis-server服务,
“NEW GROUP”选项分别输入输入1,2,3,点击NEW GROUP添加3个Group。
添加实例(按照部署规划,添加redis服务)
“Data Center” 选项填 空
“Codis Server Address” 选项填10.6.12.119:6379
“Group”选项填1
“Data Center” 选项填 空
“Codis Server Address” 选项填10.6.12.119:6380
“Group”选项填1
出现下面错误 请确认密码是否正确
slots分组和codis集群测试
参考
https://blog.csdn.net/guoyanliang1985/article/details/88578226