当当配置中心
1.把config-web.war复制到tomcat/webapp目录下
2.在shell下执行
python -c "import hashlib;print hashlib.sha1('cloudcc@2017').hexdigest();"
a66cf76edd9b6bc6179cad7c528dec3ceaf001cc
3.在zk的bin目录下执行
./zkCli.sh -server localhost:2181
[zk: localhost:2181(CONNECTED) 0] set /cloudcc 1
Node does not exist: /cloudcc
[zk: localhost:2181(CONNECTED) 1] get /cloudcc
Node does not exist: /cloudcc
[zk: localhost:2181(CONNECTED) 2] create /cloudcc a66cf76edd9b6bc6179cad7c528dec3ceaf001cc
Created /cloudcc
[zk: localhost:2181(CONNECTED) 3]
Kafka单节点安装
[root@localhost Cluster]# tar -xzf kafka_2.12-0.10.2.0.tgz
[root@localhost Cluster]# cd kafka_2.12-0.10.2.0/config/
[root@localhost config]# vim server.properties
#开启远程访问
advertised.listeners=PLAINTEXT://192.168.1.244:9092
[root@localhost config]# cd ../bin/
[root@localhost bin]# ./kafka-server-start.sh ../config/server.properties &
CentOS7下RabbitMQ服务安装配置
http://www.linuxidc.com/Linux/2016-03/129557.htm
Zookeeper单节点安装
tar -xvzf zookeeper-3.4.5.tar.gz
mv conf/zoo-sample.cfg conf/zoo.cfg
vim zoo.cfg
dataDir=/users/me/zookeeper
bin/zkServer.sh start
bin/zkServer.sh start-foreground
bin/zkServer.sh status
tail -500f zookeeper.out
bin/zkCli.sh
bin/zkCli.sh -server 127.0.0.1:2181
ls /
create /workers ""
ls /
delete /workers
ls /
quit
bin/zkServer.sh stop
cap zookeeper的设计尽可能满足一致性和可用性
脑裂
代码实例
Zookeeper集群安装
tickTime=2000
initLimit=10
syncLimit=5
dataDir=./data
clientPort=2181(2182,2183,...)
server.1=127.0.0.1:2222:2223
server.2=127.0.0.1:3333:3334
server.3=127.0.0.1:4444:4445
mkdir -p z1/data
mkdir -p z2/data
mkdir -p z3/data
echo 1 > z1/data/myid
echo 2 > z2/data/myid
echo 3 > z3/data/myid
cd z1
bin/zkServer.sh start ./z1.cfg
cd z2
bin/zkServer.sh start ./z2.cfg
cd z3
bin/zkServer.sh start ./z3.cfg
bin/zkCli.sh -server 127.0.0.1:2181,127.0.0.1:2182,127.0.0.1:2183
负载均衡
如果只想按区域连接服务器,只需客户端连接串中包括指定的IP就可以。