多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
一)通过脚本安装一个zookeeper伪集群 ~~~ #!/bin/bash #decsription install zookeeper SOFTDIR=/usr/local/src ZKVER=3.4.9 DIR=/opt/data DATADIR1=${DIR}/zk01 DATADIR2=${DIR}/zk02 DATADIR3=${DIR}/zk03 IP=$(ifconfig eth0|grep inet|grep -v "inet6"|awk '{print $2'}) #DATALOGDIR=/opt/log/ #create zk datadir and touch myid [ ! -d $DIR ] && mkdir -p $DIR for dir in zk01 zk02 zk03;do [ ! -d ${DIR}/$dir ] && mkdir -p ${DIR}/$dir done echo "01" > ${DATADIR1}/myid echo "02" > ${DATADIR2}/myid echo "03" > ${DATADIR3}/myid #install java environment cd $SOFTDIR && [ ! -f jdk-8u131-linux-x64.rpm ] && wget http://soft.51yuki.cn/jdk-8u131-linux-x64.rpm && yum -y localinstall jdk-8u131-linux-x64.rpm #install zookeeper cd $SOFTDIR && [ ! -f zookeeper-${ZKVER}.tar.gz ] && wget http://soft.51yuki.cn/zookeeper-${ZKVER}.tar.gz cd /usr/local if [ ! -d zookeeper-${ZKVER} ];then cd $SOFTDIR && tar xf zookeeper-${ZKVER}.tar.gz -C /usr/local ln -s /usr/local/zookeeper-${ZKVER} /usr/local/zookeeper fi #configure zookeeper env variables echo "export PATH=/usr/local/zookeeper/bin:$PATH" > /etc/profile.d/zookeeper.sh source /etc/profile.d/zookeeper.sh #configure zookeeper cd /usr/local/zookeeper/conf cat >zoo.cfg <<EOF tickTime=2000 initLimit=10 syncLimit=5 dataDir=$DATADIR1 clientPort=2181 server.01=${IP}:3181:4181 server.02=${IP}:3182:4182 server.03=${IP}:3183:4183 EOF for cfg in zk01.cfg zk02.cfg zk03.cfg;do cp zoo.cfg $cfg done sed -i 's/zk01/zk02/g' /usr/local/zookeeper/conf/zk02.cfg sed -i 's/2181/2182/g' /usr/local/zookeeper/conf/zk02.cfg sed -i 's/zk01/zk03/g' /usr/local/zookeeper/conf/zk03.cfg sed -i 's/2181/2183/g' /usr/local/zookeeper/conf/zk03.cfg #start Zookeeper for cfg in zk01.cfg zk02.cfg zk03.cfg;do /usr/local/zookeeper/bin/zkServer.sh start /usr/local/zookeeper/conf/$cfg done ~~~ 第二步:通过脚本安装codis ~~~ #!/bin/bash #description install codis SOFTDIR=/usr/local/src GOVER=1.9.4 #install go environment yum -y install gcc glibc gcc-c++ make git cd $SOFTDIR [ ! -f go${GOVER}.linux-amd64.tar.gz ] && wget http://soft.51yuki.cn/go${GOVER}.linux-amd64.tar.gz tar -C /usr/local -xzf go${GOVER}.linux-amd64.tar.gz #add system evironment variable #work is GOPATH dir mkdir -p /usr/local/go/work cat > /etc/profile.d/go.sh <<EOF export GOROOT=/usr/local/go export GOPATH=/usr/local/go/work export PATH=$PATH:$GOROOT/bin EOF source /etc/profile.d/go.sh #download codis and install codis mkdir -p $GOPATH/src/github.com/CodisLabs cd $_ && git clone https://github.com/CodisLabs/codis.git -b release3.2.1 make cd $GOPATH/src/github.com/CodisLabs/codis/ for ser in codis-dashboard-admin.sh codis-fe-admin.sh codis-proxy-admin.sh codis-server-admin.sh;do ./admin/$ser start done if [ "`ss -tunlp|grep 9090|awk -F "[ :]+" '{print $5}'`" == "9090" -a "`ss -tunlp|grep 11080|awk -F "[ :]+" '{print $5}'`" == "11080" -a "`ss -tunlp|grep 19000|awk -F "[ :]+" '{print $5}'`" == "19000" -a "`ss -tunlp|grep 18080|awk -F "[ :]+" '{print $5}'`" == "18080" -a "`ss -tunlp|grep 6379|awk -F "[ :]+" '{print $5}'`" == "6379" ];then echo "codis start successful" else echo "codis start fail" fi ~~~ 第三步:启动codis-dashboard /usr/local/go/work/src/github.com/CodisLabs/codis 当前路径 /usr/local/go/work/src/github.com/CodisLabs/codis/config [root@huancun02 config]# ll total 64 -rw-r--r--. 1 root root 1215 Feb 26 22:43 dashboard.toml -rw-r--r--. 1 root root 3903 Feb 26 22:43 proxy.toml -rw-r--r--. 1 root root 46711 Feb 26 22:42 redis.conf -rw-r--r--. 1 root root 7614 Feb 26 22:42 sentinel.conf [root@huancun02 config]# vim dashboard.toml coordinator_name = "zookeeper" coordinator_addr = "10.2.13.197:2181,10.2.13.197:2182,10.2.13.197:2183" product_name = "yuki" product_auth = "" # Set bind address for admin(rpc), tcp only. #admin_addr = "10.2.13.197:18080" admin_addr = "10.2.13.197:8080" ![](https://box.kancloud.cn/304443218ff6356f3a55dd3cec76fb62_644x249.png) * codis-proxy nohup ./bin/codis-proxy --ncpu=4 --config=proxy.toml \ --log=proxy.log --log-level=WARN &