189 8069 5689

Zookeeper快速部署文档-创新互联

Zookeeper主结点配置:

创新互联建站是专业的伽师网站建设公司,伽师接单;提供成都网站设计、成都做网站、外贸网站建设,网页设计,网站设计,建网站,PHP网站建设等专业做网站服务;采用PHP框架,可快速的进行伽师网站开发网页制作和功能扩展;专业做搜索引擎喜爱的网站,专业的做网站团队,希望更多企业前来合作!

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)

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


分享题目:Zookeeper快速部署文档-创新互联
分享链接:http://cdxtjz.cn/article/hpdds.html

其他资讯