机器配置:
机器
Hostname
user
192.168.169.139
node139
hadoop
192.168.169.140
node140
hadoop
192.168.169.141
node141
hadoop
12、zookeeper集群安装(node139服务器hadoop用户)
上传zookeeper-3.4.5-cdh5.5.4.tar.gz包至hadoop用户主目录,解压,解压后删除tar包
上传包完毕后依次执行
安装包下载地址
链接:https://pan.baidu.com/s/1V4klTVidPEAkkn8W_f8_Ow
密码:koye
tar -zxvf zookeeper-3.4.5-cdh5.5.4.tar.gz
rm -rf zookeeper-3.4.5-cdh5.5.4.tar.gz
13、进入到zookeeper的安装目录
cd zookeeper-3.4.5-cdh5.5.4/
14、新建data和logs文件夹
mkdir data mkdir logs
15、复制zoo_sample.cfg文件
cd conf/ cp zoo_sample.cfg zoo.cfg
16、修改zoo.cfg文件
vi zoo.cfg tickTime=2000 initLimit=5 syncLimit=2 dataDir=/home/hadoop/cm/zookeeper-3.4.5-cdh5.5.4/data dataLogDir=/home/hadoop/cm/zookeeper-3.4.5-cdh5.5.4/logs clientPort=2181 server.1=192.168.179.132:2888:3888 server.2=192.168.179.142:2888:3888 server.3=192.168.179.152:2888:3888
底下这三条虚拟机没写
maxClientCnxns=60 minSessionTimeout=4000 maxSessionTimeout=300000 [root@master zookeeper-3.4.5]# cd conf [root@master conf]# vi zoo.cfg # The number of milliseconds of each tick tickTime=2000 # The number of ticks that the initial # synchronization phase can take initLimit=5 # The number of ticks that can pass between # sending a request and getting an acknowledgement syncLimit=2 # the directory where the snapshot is stored. # do not use /tmp for storage, /tmp here is just # example sakes. dataDir=/usr/local/zookeeper-3.4.5/data dataLogDir=/usr/local/zookeeper-3.4.5/logs # the port at which the clients will connect clientPort=2181 # # Be sure to read the maintenance section of the # administrator guide before turning on autopurge. # # http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance # # The number of snapshots to retain in dataDir #autopurge.snapRetainCount=3 # Purge task interval in hours # Set to "0" to disable auto purge feature #autopurge.purgeInterval=1 server.1=192.168.179.132:2888:3888 server.2=192.168.179.142:2888:3888 server.3=192.168.179.152:2888:3888
注释:
tickTime:心跳时间
initLimit:多少个心跳时间内,允许其他server连接并初始化数据
syncLimit:多少个tickTime内,允许follower节点同步
dataDir:存放内存数据文件目录,根据实际环境修改
dataLogDir:存放日志文件目录,根据实际环境修改
clientPort:监听端口,使用默认2181端口
server.x:配置集群主机信息,[hostname]:[通信端口]:[选举端口],根据自己的主机信息修改
maxClientCnxns:最大并发客户端数,用于防止DOS的,设置为0是不加限制
minSessionTimeout:最小的客户端session超时时间(单位是毫秒)
maxSessionTimeout:最大的客户端session超时时间(单位是毫秒)
17、将本机安装目录,通过scp全部拷贝至另外2台机器。
输入命令:
scp -r zookeeper-3.4.5/ Slave1:/usr/local/ scp -r zookeeper-3.4.5/ Slave2:/usr/local/
18、在三台服务器的zookeeper安装目录下的data文件夹下面新建文件myid
touch myid vi myid
分别输入数字1、2、3,对应上面配置文件的server后面的数字
[root@Master data]# cat myid [root@slave1 data]# cat myid [root@slave2 data]# cat myid
19、Zookeeper的启动停止 (要三台都启动才行!!!!)
分别进入三台服务器的zookeeper安装目录!!!!!!!!!!,输入命令bin/zkServer.sh start 启动Zookeeper服务
查看状态命令:
./zkServer.sh status [root@master bin]# ./zkServer.sh status JMX enabled by default Using config: /usr/local/zookeeper-3.4.5/bin/../conf/zoo.cfg Mode: follower [root@slave1 bin]# ./zkServer.sh status JMX enabled by default Using config: /usr/local/zookeeper-3.4.5/bin/../conf/zoo.cfg Mode: leader [root@slave2 bin]# ./zkServer.sh status JMX enabled by default Using config: /usr/local/zookeeper-3.4.5/bin/../conf/zoo.cfg Mode: follower
20、进入节点,执行命令为:
[root@slave2 bin]# ./zkCli.sh -server 192.168.179.132:2181 回车
ls / (查看当前 ZooKeeper 中所包含的内容,输入命令quit 退出Zookeeper服务)
21、启动zookeeper服务后可以通过jps命令查看zookeeper进程,进程名为QuorumPeerMain
22、在zookeeper安装目录下输入命令 bin/zkServer.sh status 各个节点的状态
23、如果需要停止zookeeper服务,则在zookeeper安装目录上输入命令 bin/zkServer.sh stop