189 8069 5689

Zookeeper快速部署文档

Zookeeper主结点配置:

10年积累的网站建设、成都做网站经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先网站制作后付款的网站建设流程,更有竹山免费网站建设让你可以放心的选择与我们合作。

hostname zookeeper1

sed -i.ori 's#HOSTNAME=localhost.localdomain#HOSTNAME=zookeeper1#g'/etc/sysconfig/network

tee >>/etc/hosts<<-eof

172.26.242.111 zookeeper1

172.26.242.112 zookeeper2

eof

 

/etc/init.d/iptables stop

chkconfig iptables off

sed -i.ori 's#SELINUX=enforcing#SELINUX=disabled#g'/etc/sysconfig/selinux

setenforce 0

 

cd /software/

mkdir -p /application

tar xf jdk-7u67-linux-x64.tar.gz -C/application/

ln -s /application/jdk1.7.0_67//application/jdk

tee >>/etc/profile<<-eof

###JAVA_HOME

export JAVA_HOME=/application/jdk

export PATH=$JAVA_HOME/bin:$PATH

eof

source /etc/profile

java -version

 

cd /software/

tar xf zookeeper-3.4.9.tar.gz -C/application/

ln -s /application/zookeeper-3.4.9//application/zookeeper

mkdir -p /application/zookeeper/data

echo "1" >>/application/zookeeper/data/myid

cp /application/zookeeper/conf/zoo_sample.cfg/application/zookeeper/conf/zoo.cfg

sed -i's#dataDir=/tmp/zookeeper#dataDir=/application/zookeeper/data#g'/application/zookeeper/conf/zoo.cfg

tee >>/application/zookeeper/conf/zoo.cfg<<-eof

server.1=zookeeper1:2888:3888

server.2=zookeeper2:2888:3888

eof

 

tee >>/etc/profile<<-eof

##ZOOKEEPER_HOME

exportZOOKEEPER_HOME=/application/zookeeper

export PATH=$ZOOKEEPER_HOME/bin:$PATH

eof

source /etc/profile

 

 

备节点的配置:

hostname zookeeper2

sed -i.ori 's#HOSTNAME=localhost.localdomain#HOSTNAME=zookeeper2#g'/etc/sysconfig/network

tee >>/etc/hosts<<-eof

172.26.242.111 zookeeper1

172.26.242.112 zookeeper2

eof

 

/etc/init.d/iptables stop

chkconfig iptables off

sed -i.ori 's#SELINUX=enforcing#SELINUX=disabled#g'/etc/sysconfig/selinux

setenforce 0

mkdir -p /application

 

 

主节点上将配置目录拷贝到另外一台机器上:

scp -r /application/jdk1.7.0_67/root@172.26.242.112:/application

scp -r /application/zookeeper-3.4.9root@172.26.242.112:/application

 

 

备节点继续配置:

ln -s /application/jdk1.7.0_67//application/jdk

tee >>/etc/profile<<-eof

export JAVA_HOME=/application/jdk

export PATH=$JAVA_HOME/bin:$PATH

eof

source /etc/profile

java -version

 

ln -s /application/zookeeper-3.4.9//application/zookeeper

tee >>/etc/profile<<-eof

##ZOOKEEPER_HOME

exportZOOKEEPER_HOME=/application/zookeeper

export PATH=$ZOOKEEPER_HOME/bin:$PATH

eof

source /etc/profile

echo "2" >/application/zookeeper/data/myid   -->将1修改为2

 

 

启动ZK:多台ZK不能间隔太久启动,否则容易认不到对方

zkServer.sh start

 

查看:

[root@zookeeper1~]# ps -ef | grep zookeeper

root      1491    1  0 14:53 pts/2    00:00:01 /application/jdk/bin/java-Dzookeeper.log.dir=. -Dzookeeper.root.logger=INFO,CONSOLE -cp/application/zookeeper/bin/../build/classes:/application/zookeeper/bin/../build/lib/*.jar:/application/zookeeper/bin/../lib/slf4j-log4j12-1.6.1.jar:/application/zookeeper/bin/../lib/slf4j-api-1.6.1.jar:/application/zookeeper/bin/../lib/netty-3.10.5.Final.jar:/application/zookeeper/bin/../lib/log4j-1.2.16.jar:/application/zookeeper/bin/../lib/jline-0.9.94.jar:/application/zookeeper/bin/../zookeeper-3.4.9.jar:/application/zookeeper/bin/../src/java/lib/*.jar:/application/zookeeper/bin/../conf:-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=falseorg.apache.zookeeper.server.quorum.QuorumPeerMain/application/zookeeper/bin/../conf/zoo.cfg

 

[root@zookeeper1 ~]# netstat -lntup

Active Internet connections (only servers)

Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name  

tcp       0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      920/sshd           

tcp       0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      997/master         

tcp       0      0 ::ffff:172.26.242.111:3888  :::*                        LISTEN      1491/java          

tcp       0      0 :::22                       :::*                        LISTEN      920/sshd           

tcp       0      0 ::1:25                      :::*                        LISTEN      997/master         

tcp       0      0 :::51106                    :::*                        LISTEN      1491/java          

tcp       0      0 :::2181                     :::*                        LISTEN      1491/java           

 

[root@zookeeper2 ~]# zkServer.sh status

ZooKeeper JMX enabled by default

Using config:/application/zookeeper/bin/../conf/zoo.cfg

Mode: leader  -->另一端是follower

 

[root@zookeeper2 ~]# jps

1441 Jps

1370 QuorumPeerMain -->这个就是zookeeper进程

 

查看日志:

[root@zookeeper1 ~]# cat /root/zookeeper.out

2017-05-25 14:53:45,599 [myid:] - INFO  [main:QuorumPeerConfig@124] - Readingconfiguration from: /application/zookeeper/bin/../conf/zoo.cfg

2017-05-25 14:53:45,620 [myid:] - INFO  [main:QuorumPeer$QuorumServer@149] - Resolvedhostname: zookeeper1 to address: zookeeper1/172.26.242.111

2017-05-25 14:53:45,620 [myid:] - INFO  [main:QuorumPeer$QuorumServer@149] - Resolvedhostname: zookeeper2 to address: zookeeper2/172.26.242.112

2017-05-25 14:53:45,621 [myid:] - WARN  [main:QuorumPeerConfig@305] - No serverfailure will be tolerated. You need at least 3 servers.

2017-05-25 14:53:45,622 [myid:] - INFO  [main:QuorumPeerConfig@352] - Defaulting tomajority quorums

2017-05-25 14:53:45,627 [myid:1] - INFO  [main:DatadirCleanupManager@78] -autopurge.snapRetainCount set to 3

2017-05-25 14:53:45,627 [myid:1] - INFO  [main:DatadirCleanupManager@79] -autopurge.purgeInterval set to 0

2017-05-25 14:53:45,627 [myid:1] - INFO  [main:DatadirCleanupManager@101] - Purge taskis not scheduled.

2017-05-25 14:53:45,645 [myid:1] - INFO  [main:QuorumPeerMain@127] - Starting quorumpeer

2017-05-25 14:53:45,659 [myid:1] - INFO  [main:NIOServerCnxnFactory@89] - binding toport 0.0.0.0/0.0.0.0:2181

2017-05-25 14:53:45,677 [myid:1] - INFO  [main:QuorumPeer@1019] - tickTime set to 2000

2017-05-25 14:53:45,677 [myid:1] - INFO  [main:QuorumPeer@1039] - minSessionTimeoutset to -1

2017-05-25 14:53:45,678 [myid:1] - INFO  [main:QuorumPeer@1050] - maxSessionTimeoutset to -1

2017-05-25 14:53:45,678 [myid:1] - INFO  [main:QuorumPeer@1065] - initLimit set to 10

2017-05-25 14:53:45,713 [myid:1] - INFO  [main:QuorumPeer@533] - currentEpoch notfound! Creating with a reasonable default of 0. This should only happen whenyou are upgrading your installation

2017-05-25 14:53:45,718 [myid:1] - INFO  [main:QuorumPeer@548] - acceptedEpoch notfound! Creating with a reasonable default of 0. This should only happen whenyou are upgrading your installation

2017-05-25 14:53:45,731 [myid:1] - INFO [ListenerThread:QuorumCnxManager$Listener@534] - My election bind port:zookeeper1/172.26.242.111:3888

2017-05-25 14:53:45,745 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumPeer@774]- LOOKING

2017-05-25 14:53:45,748 [myid:1] - INFO [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:FastLeaderElection@818] - Newelection. My id =  1, proposed zxid=0x0

2017-05-25 14:53:45,752 [myid:1] - INFO  [WorkerReceiver[myid=1]:FastLeaderElection@600]- Notification: 1 (message format version), 1 (n.leader), 0x0 (n.zxid), 0x1(n.round), LOOKING (n.state), 1 (n.sid), 0x0 (n.peerEpoch) LOOKING (my state)

2017-05-25 14:53:45,758 [myid:1] - WARN  [WorkerSender[myid=1]:QuorumCnxManager@400] -Cannot open channel to 2 at election address zookeeper2/172.26.242.112:3888

java.net.ConnectException: Connection refused

        atjava.net.PlainSocketImpl.socketConnect(Native Method)

        atjava.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)

        atjava.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)

        atjava.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)

        atjava.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)

        atjava.net.Socket.connect(Socket.java:579)

        atorg.apache.zookeeper.server.quorum.QuorumCnxManager.connectOne(QuorumCnxManager.java:381)

        atorg.apache.zookeeper.server.quorum.QuorumCnxManager.toSend(QuorumCnxManager.java:354)

        atorg.apache.zookeeper.server.quorum.FastLeaderElection$Messenger$WorkerSender.process(FastLeaderElection.java:452)

        atorg.apache.zookeeper.server.quorum.FastLeaderElection$Messenger$WorkerSender.run(FastLeaderElection.java:433)

        atjava.lang.Thread.run(Thread.java:745)

2017-05-25 14:53:45,761 [myid:1] - INFO [WorkerSender[myid=1]:QuorumPeer$QuorumServer@149] - Resolved hostname:zookeeper2 to address: zookeeper2/172.26.242.112

2017-05-25 14:53:45,804 [myid:1] - INFO [zookeeper1/172.26.242.111:3888:QuorumCnxManager$Listener@541] -Received connection request /172.26.242.112:57129

2017-05-25 14:53:45,816 [myid:1] - INFO [WorkerReceiver[myid=1]:FastLeaderElection@600] - Notification: 1(message format version), 2 (n.leader), 0x0 (n.zxid), 0x1 (n.round), LOOKING(n.state), 2 (n.sid), 0x0 (n.peerEpoch) LOOKING (my state)

2017-05-25 14:53:45,817 [myid:1] - INFO [WorkerReceiver[myid=1]:FastLeaderElection@600] - Notification: 1(message format version), 2 (n.leader), 0x0 (n.zxid), 0x1 (n.round), LOOKING(n.state), 1 (n.sid), 0x0 (n.peerEpoch) LOOKING (my state)

2017-05-25 14:53:46,019 [myid:1] - INFO [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumPeer@844] - FOLLOWING

2017-05-25 14:53:46,024 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:Learner@86]- TCP NoDelay set to: true

2017-05-25 14:53:46,032 [myid:1] - INFO [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:Environment@100] - Serverenvironment:zookeeper.version=3.4.9-1757313, built on 08/23/2016 06:50 GMT

2017-05-25 14:53:46,032 [myid:1] - INFO [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:Environment@100] - Serverenvironment:host.name=zookeeper1

2017-05-25 14:53:46,032 [myid:1] - INFO [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:Environment@100] - Serverenvironment:java.version=1.7.0_67

2017-05-25 14:53:46,032 [myid:1] - INFO [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:Environment@100] - Serverenvironment:java.vendor=Oracle Corporation

2017-05-25 14:53:46,032 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:Environment@100]- Server environment:java.home=/application/jdk1.7.0_67/jre

2017-05-25 14:53:46,032 [myid:1] - INFO [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:Environment@100] - Serverenvironment:java.class.path=/application/zookeeper/bin/../build/classes:/application/zookeeper/bin/../build/lib/*.jar:/application/zookeeper/bin/../lib/slf4j-log4j12-1.6.1.jar:/application/zookeeper/bin/../lib/slf4j-api-1.6.1.jar:/application/zookeeper/bin/../lib/netty-3.10.5.Final.jar:/application/zookeeper/bin/../lib/log4j-1.2.16.jar:/application/zookeeper/bin/../lib/jline-0.9.94.jar:/application/zookeeper/bin/../zookeeper-3.4.9.jar:/application/zookeeper/bin/../src/java/lib/*.jar:/application/zookeeper/bin/../conf:

2017-05-25 14:53:46,032 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:Environment@100]- Serverenvironment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib

2017-05-25 14:53:46,033 [myid:1] - INFO [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:Environment@100] - Serverenvironment:java.io.tmpdir=/tmp

2017-05-25 14:53:46,033 [myid:1] - INFO [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:Environment@100] - Serverenvironment:java.compiler=

2017-05-25 14:53:46,033 [myid:1] - INFO [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:Environment@100] - Serverenvironment:os.name=Linux

2017-05-25 14:53:46,033 [myid:1] - INFO [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:Environment@100] - Serverenvironment:os.arch=amd64

2017-05-25 14:53:46,033 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:Environment@100]- Server environment:os.version=2.6.32-431.el6.x86_64

2017-05-25 14:53:46,033 [myid:1] - INFO [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:Environment@100] - Serverenvironment:user.name=root

2017-05-25 14:53:46,033 [myid:1] - INFO [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:Environment@100] - Serverenvironment:user.home=/root

2017-05-25 14:53:46,033 [myid:1] - INFO [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:Environment@100] - Serverenvironment:user.dir=/root

2017-05-25 14:53:46,035 [myid:1] - INFO [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:ZooKeeperServer@173] - Createdserver with tickTime 2000 minSessionTimeout 4000 maxSessionTimeout 40000datadir /application/zookeeper/data/version-2 snapdir /application/zookeeper/data/version-2

2017-05-25 14:53:46,036 [myid:1] - INFO [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:Follower@61] - FOLLOWING -LEADER ELECTION TOOK - 288

2017-05-25 14:53:46,039 [myid:1] - INFO  [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:QuorumPeer$QuorumServer@149]- Resolved hostname: zookeeper2 to address: zookeeper2/172.26.242.112

2017-05-25 14:53:46,097 [myid:1] - INFO [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:Learner@326] - Getting a difffrom the leader 0x0

2017-05-25 14:53:46,101 [myid:1] - INFO [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:FileTxnSnapLog@240] -Snapshotting: 0x0 to /application/zookeeper/data/version-2/snapshot.0

2017-05-25 15:02:50,711 [myid:1] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@192] -Accepted socket connection from /127.0.0.1:55742

2017-05-25 15:02:50,717 [myid:1] - INFO [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxn@827] -Processing srvr command from /127.0.0.1:55742

2017-05-25 15:02:50,720 [myid:1] - INFO  [Thread-1:NIOServerCnxn@1008] - Closed socketconnection for client /127.0.0.1:55742 (no session established for client)


分享题目:Zookeeper快速部署文档
标题URL:http://cdxtjz.com/article/ppgjgj.html

其他资讯