Codis集群安装配置

2018-04-24  本文已影响0人  小白正在飞

一.借用网上codis架构图(https://github.com/CodisLabs/codis

clipboard.png

各组件作用说明

1.codis-proxy 相当于redis,是底层codis-server集群代理、

2.codis-group 是一个虚拟的节点机制通过槽位映射机制实现proxy与server的映射(一个组有一个master和多个slave组成,默认1024个槽位,redis cluster默认16384个槽位,不同的槽位内容放在不同group,通过zk查询key记录位置)

3.codis-fe 集群管理界面

4.codis-dashboard 集群管理中心

二. 环境搭建配置

系统centos7.1 64位系统

环境包

jdk1.8.0.91

go1.7.3 https://storage.googleapis.com/golang/go1.7.3.linux-amd64.tar.gz

zookeeper3.4.6 http://mirrors.shuosc.org/apache/zookeeper/zookeeper-3.4.10/zookeeper-3.4.10.tar.gz

QQ截图20180424175938.png

zk集群简要配置(需要安装jdk--步骤略)

[root@codis01 ~]# sed '/^$/ d;/^#/ d' /usr/local/zookeeper/conf/zk1.cfg

tickTime=2000

initLimit=10

syncLimit=5

dataDir=/usr/local/zookeeper/data

clientPort=2181

server.1=192.168.10.5:2888:3888

server.2=192.168.10.6:2888:3888

server.3=192.168.10.7:2888:3888


echo 1 > /usr/local/zookeeper/data/myid

codis02 上操作类似 echo 2 > /usr/local/zookeeper/data/myid

codis03 上操作类似 echo 3 > /usr/local/zookeeper/data/myid

启动zk集群,检测zk状态是否正常

go环境编译安装

[root@codis01 ~]# tar zxvf go1.7.3.linux-amd64.tar.gz

[root@codis01 ~]# mv go /usr/local

[root@codis01 ~]# mkdir /usr/local/codis

配置环境变量 vi /etc/profile

export PATH=$PATH:/usr/local/go/bin

export GOROOT=/usr/local/go

export GOPATH=/usr/local/codis

path=$PATH:$HOME/bin:$GOROOT/bin:$GOPATH/bin

source /etc/profile

验证是否生效

[root@codis01 ~]# go version

go version go1.7.3 linux/amd64

[root@codis01 ~]# echo $GOPATH

/usr/local/codis

codis安装

mkdir -p $GOPATH/src/github.com/CodisLabs************************此目录不能为别的名

[root@codis01 ~]# cd /usr/local/codis/src/github.com/CodisLabs/

[root@codis01 ~]# git clone https://github.com/CodisLabs/codis.git -b release3.2

进行编译 cd /usr/local/codis/src/github.com/CodisLabs/codis

make ---------执行全部指令后,会在 bin 文件夹内生成 codis-proxy、codis-server三个可执行文件

clipboard1.png

修改配置信息

启动方式有两种

[root@codis01 codis]# sed '/^#/ d;/^$/ d' config/dashboard.toml (修改了红字信息)

coordinator_name = "zookeeper"

coordinator_addr = "192.168.10.5:2181,192.168.10.6:2181,192.168.10.7:2181"

product_name = "codis-protal"

product_auth = ""

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 = ""


[root@codis01 codis]# sed '/^#/ d;/^$/ d' config/proxy.toml (修改了红字信息)

product_name = "codis-protal"

product_auth = ""

session_auth = ""

admin_addr = "0.0.0.0:11080"

proto_type = "tcp4"

proxy_addr = "0.0.0.0:19000"

jodis_name = "zookeeper"

jodis_addr = "192.168.10.5:2181,192.168.10.6:2181,192.168.10.7:2181"

jodis_auth = ""

jodis_timeout = "20s"

jodis_compatible = true


新建4个codis-server节点(redis配置修改红字部分)

[root@codis01 opt]# sed '/^#/ d;/^$/ d' /opt/redis-6379/redis.conf

protected-mode no

port 6379

tcp-backlog 511

timeout 0

tcp-keepalive 300

daemonize yes

supervised no

pidfile "/opt/redis-6379/redis_6379.pid"

loglevel notice

logfile "/opt/redis-6379/redis_6379.log"

databases 16

save 900 1

save 300 10

save 60 10000

stop-writes-on-bgsave-error yes

rdbcompression yes

rdbchecksum yes

dbfilename "dump_6379.rdb"

dir "/opt/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


服务启动【自带脚本方式】

cd $GOPATH/src/github.com/CodisLabs/codis/admin

./admin/codis-dashboard-admin.sh start 启动CODIS-DASHBOARD 外部存储

./admin/codis-proxy-admin.sh start 启动CODIS-PROXY 并加入CODIS-DASHBOARD管理

./admin/codis-server-admin.sh start 启动CODIS-SERVER

./admin/codis-fe-admin.sh start 启动CODIS-FE,可以通过127.0.0.1:9090访问管理界面

【手动运行命令后台运行】

./bin/codis-dashboard --ncpu=1 --config=config/dashboard.toml --log=dashboard.log --log-level=WARN &

./bin/codis-proxy --ncpu=1 --config=config/proxy.toml --log=proxy.log --log-level=WARN &

./bin/codis-fe --ncpu=1 --log=fe.log --log-level=WARN --zookeeper=192.168.10.5:2181 --listen=192.168.10.5:8090 & --管理页面端口

./bin/codis-server /opt/redis-6379/redis.conf

./bin/codis-server /opt/redis-6380/redis.conf

./bin/codis-server /opt/redis-6381/redis.conf

./bin/codis-server /opt/redis-6382/redis.conf

clipboard2.png

三.通过fe管理页面管理codis机器

浏览器访问http://192.168.10.5:8090进入管理页面

clipboard3.png

添加proxy代理

clipboard4.png

先添加4个分组,每个256个槽位,然后把codis-server加入到分组,组成一组两从

clipboard5.png clipboard6.png

测试codis集群功能。停掉192.168.10.5:19000 这个proxy节点。检测工作是否正常

tag: 在10.5的节点上写入key,停掉10.5工作节点,在10.6上查询key

[root@codis01 codis]# ./bin/redis-cli -h 192.168.10.5 -p 19000

192.168.10.5:19000> set fctee hello-world

OK

[root@codis02 codis]# ./bin/redis-cli -h 192.168.10.6 -p 19000

192.168.10.6:19000> get fctee

"hello-world"

结果工作正常

tag:测试redis-key值写入,分配均衡

!/bin/bash

for ((i=0;i<20000;i++))

do

echo -en "helloworld" | redis-cli -h 192.168.10.5 -p 19000 -x set name$i >>redis.log

done

------------参考链接

http://www.cnblogs.com/reblue520/p/6874925.html

http://blog.csdn.net/liaoyoujinb/article/details/70800860

上一篇下一篇

猜你喜欢

热点阅读