轉載原文鏈接:http://navyaijm.blog.51cto.com/4647068/1637688
1
2
3
4
5
6
7
8
9
10
11
12
13
|
zookeeper集羣: 10.10.0.47 10.10.0.48 10.10.1.76 codis-config、codis-ha: 10.10.32.10:18087 codis-proxy: 10.10.32.10:19000 10.10.32.49:19000 codis-server: 10.10.32.42:6379、10.10.32.43:6380(主、從) 10.10.32.43:6379、10.10.32.44:6380(主、從) 10.10.32.44:6379、10.10.32.42:6380(主、從) |
1
|
yum -y install zookeeper jdk ##安裝服務 |
1
2
3
4
|
vim /etc/hosts ##添加host 10.10.0.47 ZooKeeper-node1 10.10.0.48 ZooKeeper-node2 10.10.1.76 ZooKeeper-node3 |
1
2
3
4
5
6
7
8
9
10
|
vim /etc/zookeeper/conf/zoo .cfg ##撰寫zk的配置文件 maxClientCnxns=50 tickTime=2000 initLimit=10 syncLimit=5 dataDir= /data/zookeeper/ clientPort=2181 server.1=ZooKeeper-node1:2888:3888 server.2=ZooKeeper-node2:2888:3888 server.3=ZooKeeper-node3:2888:3888 |
1
2
3
|
mkdir /data/zookeeper/ ##創建zk的datadir目錄 echo "2" > /data/zookeeper/myid ##生成ID,這裏需要注意, myid對應的zoo.cfg的server.ID,比如ZooKeeper-node2對應的myid應該是2 /usr/lib/zookeeper/bin/zkServer .sh start ## 服務啓動 |
1
2
3
4
5
6
7
8
9
10
11
12
|
wget https: //storage .googleapis.com /golang/go1 .4.1.linux-amd64. tar .gz tar -zxvf go1.4.1.linux-amd64. tar .gz mv go /usr/local/ cd /usr/local/go/src/ bash all. bash cat >> ~/.bashrc << _bashrc_export export GOROOT= /usr/local/go export PATH=\$PATH:\$GOROOT /bin export GOARCH=amd64 export GOOS=linux _bashrc_export source ~/.bashrc |
1
2
3
4
5
6
|
mkdir /data/go export GOPATH= /data/go /usr/local/go/bin/go get github.com /wandoulabs/codis cd /data/go/src/github .com /wandoulabs/codis/ . /bootstrap .sh make gotest |
1
2
3
4
5
6
7
|
cat /etc/codis/config_10 .ini ##撰寫配置文件 zk=10.10.0.47:2181,10.10.0.48:2181,10.10.1.76:2181 product=zh_news proxy_id=codis-proxy_10 net_timeout=5000 proto=tcp4 dashboard_addr=10.10.32.10:18087 |
1
|
cd /data/go/src/github .com /wandoulabs/codis/ && . /bin/codis-config -c /etc/codis/config_10 .ini dashboard & |
1
|
cd /data/go/src/github .com /wandoulabs/codis/ && . /bin/codis-config -c /etc/codis/config_10 .ini slot init |
1
|
cd /data/go/src/github .com /wandoulabs/codis/ && . /bin/codis-server /etc/redis_6379 .conf & |
1
2
3
4
5
6
7
|
cd /data/go/src/github .com /wandoulabs/codis/ . /bin/codis-config -c /etc/codis/config_10 .ini server add 1 10.10.32.42:6379 master . /bin/codis-config -c /etc/codis/config_10 .ini server add 1 10.10.32.43:6380 slave . /bin/codis-config -c /etc/codis/config_10 .ini server add 2 10.10.32.43:6379 master . /bin/codis-config -c /etc/codis/config_10 .ini server add 2 10.10.32.44:6380 slave . /bin/codis-config -c /etc/codis/config_10 .ini server add 3 10.10.32.44:6379 master . /bin/codis-config -c /etc/codis/config_10 .ini server add 3 10.10.32.42:6380 slave |
1
2
3
4
|
cd /data/go/src/github .com /wandoulabs/codis/ . /bin/codis-config -c /etc/codis/config_10 .ini slot range- set 0 300 1 online . /bin/codis-config -c /etc/codis/config_10 .ini slot range- set 301 700 2 online . /bin/codis-config -c /etc/codis/config_10 .ini slot range- set 701 1023 3 online |
1
2
3
4
5
6
7
|
cat /etc/codis/config_10 .ini ##撰寫配置文件 zk=10.10.0.47:2181,10.10.0.48:2181,10.10.1.76:2181 product=zh_news proxy_id=codis-proxy_10 ##10.10.32.49上改成codis-proxy_49,多個proxy,proxy_id 需要唯一 net_timeout=5000 proto=tcp4 dashboard_addr=10.10.32.10:18087 |
1
2
|
cd /data/go/src/github .com /wandoulabs/codis/ && . /bin/codis-proxy -c /etc/codis/config_10 .ini -L /data/log/codis-proxy_10 .log --cpu=4 --addr=0.0.0.0:19000 --http-addr=0.0.0.0:11000 & cd /data/go/src/github .com /wandoulabs/codis/ && . /bin/codis-proxy -c /etc/codis/config_49 .ini -L /data/log/codis-proxy_49 .log --cpu=4 --addr=0.0.0.0:19000 --http-addr=0.0.0.0:11000 & |
1
2
3
4
5
6
7
|
export GOPATH= /data/go /usr/local/go/bin/go get github.com /ngaut/codis-ha cd /data/go/src/github .com /ngaut/codis-ha go build cp codis-ha /data/go/src/github .com /wandoulabs/codis/bin/ 使用方法: codis-ha --codis-config=dashboard地址:18087 --productName=集羣項目名稱 |
1
|
yum -y install supervisord |
1
2
3
4
5
6
7
8
9
10
11
|
/etc/supervisord .conf中添加如下內容: [program:codis-ha] autorestart = True stopwaitsecs = 10 startsecs = 1 stopsignal = QUIT command = /data/go/src/github .com /wandoulabs/codis/bin/codis-ha --codis-config=10.10.32.17:18087 --productName=zh_news user = root startretries = 3 autostart = True exitcodes = 0,2 |
1
2
|
/etc/init .d /supervisord start chkconfig supervisord on |