zookeeper分布式安装

1.先把zookeeper-3.5.2-alpha.tar上传解压到/usr/local/下重命名为zookeeper

2 ############# zookeeper env #################
3 export ZOOKEEPER_HOME=/usr/local/zookeeper
4 export PATH=$JAVA_HOME/bin:$ZOOKEEPER_HOME/bin:$PATH

2.配置zookeeper各配置文件

1 [root@hadoop1 conf]# cd /usr/local/zookeeper/conf
2 [root@hadoop1 conf]# cp zoo_sample.cfg zoo.cfg
3 [root@hadoop1 conf]# vim zoo.cfg                        最后追加
4 server.1=hadoop1:7000:7001
5 server.2=hadoop2:7000:7001
6 server.3=hadoop3:7000:7001
7 [root@hadoop1 conf]# mkdir -p /tmp/zookeeper            # 所有机器,创建指定的dataDir
8 [root@hadoop1 conf]# touch /tmp/zookeeper/myid            # 所有机器,/tmp/zookeeper是刚才zoo.cfg里指定的dataDir,如果变更了这里也要变
9 [root@hadoop1 conf]# echo "1">/tmp/zookeeper/myid        # 所有机器操作,与zoo.cfg最后追加的对应,hadoop2为2,hadoop3为3

3.修改日志记录方式,将原本的一直累计追加变更为每日一份

1 [root@hadoop1 conf]# vim log4j.properties
2 zookeeper.root.logger=INFO, CONSOLE变更为zookeeper.root.logger=INFO, ROLLINGFILE
3 log4j.appender.ROLLINGFILE=org.apache.log4j.RollingFileAppender变更为log4j.appender.ROLLINGFILE=org.apache.log4j.DailyRollingFileAppender
4 [root@hadoop1 conf]# vim ../bin/zkEnv.sh
5 ZOO_LOG4J_PROP="INFO,CONSOLE"变更为ZOO_LOG4J_PROP="INFO,ROLLINGFILE"
6 [root@hadoop1 local]# scp -rp zookeeper/ hadoop2:/usr/local/
7 [root@hadoop1 local]# scp -rp zookeeper/ hadoop3:/usr/local/

4.启动并验证

1 [root@hadoop1 conf]# zkServer.sh start                    # 所有机器
2 [root@hadoop1 conf]# jps
3 18628 Jps
4 18484 QuorumPeerMain
5 [root@hadoop1 conf]# zkServer.sh status
6 ZooKeeper JMX enabled by default
7 Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg
8 Client port found: 2181. Client address: localhost.
9 Mode: follower                                            # 会有一台是leader,剩下都是follower,因为zookeeper是完全对等的,所以不一定是当前操作的hadoop1就是leader

 

posted @ 2017-11-14 16:51  北方姆Q  阅读(164)  评论(0编辑  收藏  举报