linux 使用codis集群管理

**

环境

**
一、软件环境

系统:centos 6.5

Jdk:jdk-8u111-linux-x64.gz
go
zookeeper:
codis

本机IP:172.25.254.2
安装相关依赖包
yum install -y gcc makegcc-c++ automake lrzsz openssl-devel zlib-* bzip2-* readline* git nmap unzipwget lsof xz net-tools mercurial

1安装java环境 前面已经有文章 不再赘述
2go环境安装
我下载的完整软件包 不用编译 直接加入变量即可
变量添加为

export GOROOT=/usr/local/go
export GOPATH=/usr/local/go/gopkg
export CODISPATH=/usr/local/codis
#export ZOOKEEPERPATH=/usr/local/zookeeper-3.4.8
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin:$CODISPATH/bin

这里写图片描述

这里写图片描述

**

zookeeper安装 (有错误)

**





**

mkdir  /{app,appdata}

cd /app

mkdir -pv ./{zk1,zk2,zk3}/{data,log}



tar zxvf zookeeper-3.4.6.tar.gz -C  /app/zk1/

tar zxvf zookeeper-3.4.6.tar.gz -C /app/zk2/

tar zxvf zookeeper-3.4.6.tar.gz -C /app/zk3/



ln -sv /app/zk1/zookeeper-3.4.6  /app/zk1/zookeeper

ln -sv /app/zk2/zookeeper-3.4.6 /app/zk2/zookeeper

ln -sv /app/zk3/zookeeper-3.4.6 /app/zk3/zookeeper



cp /app/zk1/zookeeper/conf/zoo_sample.cfg/app/zk1/zookeeper/conf/zoo.cfg



修改zoo.cfg配置文件

vi /app/zk1/zookeeper/conf/zoo.cfg



# The number of milliseconds of each tick

tickTime=2000

# The number of ticks that the initial

# synchronization phase can take

initLimit=10

# The number of ticks that can pass between

# sending a request and getting anacknowledgement

syncLimit=5

# the directory where the snapshot isstored.

# do not use /tmp for storage, /tmp here isjust

# example sakes.

dataDir=/app/zk1/data

# the port at which the clients willconnect

clientPort=2181

# the maximum number of client connections.

# increase this if you need to handle moreclients

#maxClientCnxns=60

#

# Be sure to read the maintenance sectionof the

# administrator guide before turning onautopurge.

#

#http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance

#

# The number of snapshots to retain indataDir

#autopurge.snapRetainCount=3

# Purge task interval in hours

# Set to "0" to disable autopurge feature

#autopurge.purgeInterval=1

server.1=172.25.254.1:2881:3888

server.2=172.25.254.2:2882:3888

server.3=172.25.254.3:2883:3888



生成myid

echo "1">/app/zk1/data/myid



配置zk2、zk3:



cp /app/zk1/zookeeper/conf/zoo.cfg  /app/zk2/zookeeper/conf/

cp /app/zk1/zookeeper/conf/zoo.cfg  /app/zk3/zookeeper/conf/



sed -i 's/zk1/zk2/g'  /app/zk2/zookeeper/conf/zoo.cfg

sed -i 's/zk1/zk3/g'  /app/zk3/zookeeper/conf/zoo.cfg



sed -i 's/2181/2182/g'  /app/zk2/zookeeper/conf/zoo.cfg

sed -i 's/2181/2183/g'  /app/zk3/zookeeper/conf/zoo.cfg



echo "2">/app/zk2/data/myid

echo "3">/app/zk3/data/myid



启动zookeeper服务

/app/zk1/zookeeper/bin/zkServer.sh  start

/app/zk2/zookeeper/bin/zkServer.sh  start

/app/zk3/zookeeper/bin/zkServer.sh  start





查看zookeeper状态

/app/zk1/zookeeper/bin/zkServer.sh  status

JMX enabled by default

Using config:/app/zk1/zookeeper/bin/../conf/zoo.cfg

Mode: leader



/app/zk2/zookeeper/bin/zkServer.sh  status

JMX enabled by default

Using config:/app/zk2/zookeeper/bin/../conf/zoo.cfg



/app/zk3/zookeeper/bin/zkServer.sh  status

JMX enabled by default

Using config:/app/zk3/zookeeper/bin/../conf/zoo.cfg

Mode: follower

**

安装codis

**

cd  /usr/log/go/gopkg/src/github.com/CodisLabs/
mv  codis  .
make

看到如下结果即可
go build -i -o bin/codis-dashboard ./cmd/dashboard
go build -i -tags "cgo_jemalloc" -o bin/codis-proxy ./cmd/proxy
go build -i -o bin/codis-admin ./cmd/admin
go build -i -o bin/codis-fe ./cmd/fe

测试运行

codis-dashboard-admin.sh start
/usr/local/go/gopkg/src/github.com/CodisLabs/codis/admin/../config/dashboard.toml
starting codis-dashboard ... 
查看日志
cat  codis-dashboard.log.2018-08-12 
2018/08/12 00:28:52 main.go:78: [WARN] set ncpu = 1
2018/08/12 00:28:52 topom.go:119: [WARN] create new topom:
{
    "token": "fc6efce89056a6f6d75b0816051031c3",
    "start_time": "2018-08-12 00:28:52.358513794 +0800 CST",
    "admin_addr": "server2:18080",
    "product_name": "codis-demo",
    "pid": 16164,
    "pwd": "/usr/local/go/gopkg/src/github.com/CodisLabs/codis/admin",
    "sys": "Linux server2 2.6.32-431.el6.x86_64 #1 SMP Sun Nov 10 22:19:54 EST 2013 x86_64 x86_64 x86_64 GNU/Linux"
}
2018/08/12 00:28:52 main.go:103: [WARN] create topom with config



 codis-proxy-admin.sh  start
/usr/local/go/gopkg/src/github.com/CodisLabs/codis/admin/../config/proxy.toml
starting codis-proxy ... 

sh codis-server-admin.sh start
/usr/local/go/gopkg/src/github.com/CodisLabs/codis/admin/../config/redis.conf


 sh codis-fe-admin.sh start

starting codis-fe ... 

查看启动日志
cat codis-fe.log.2018-08-12 
2018/08/12 00:32:03 main.go:101: [WARN] set ncpu = 1
2018/08/12 00:32:03 main.go:104: [WARN] set listen = 0.0.0.0:9090
2018/08/12 00:32:03 main.go:120: [WARN] set assets = /usr/local/go/gopkg/src/github.com/CodisLabs/codis/bin/assets
2018/08/12 00:32:03 main.go:155: [WARN] set --filesystem = /tmp/codis
2018/08/12 00:32:03 main.go:209: [WARN] option --pidfile = /usr/local/go/gopkg/src/github.com/CodisLabs/codis/bin/codis-fe.pid


在浏览器输入ip测试
http://172.25.254.2:9090/

linux 使用codis集群管理_第1张图片

你可能感兴趣的:(linux)