一、 环境部署概况
cdh-master | 172.168.10.251 |
cdh-node1 | 172.168.10.251 |
cdh-node2 | 172.168.10.251 |
三台服务器已按照CDH4 RPM方式安装hadoop,还包括SSH联机,保证三台机器无需密码即可切换用户。
搭建两台NAMENODE机器 分别部署在cdh-master和cdh-node1上
同时有三台journalnode用来存储namenode元数据
有三台zookeeper组成的集群用来管理namenode的状态(active或者standby)
当active的namnode出现问题时,standby节点立刻投入使用
有一台datanode节点,部署在cdh-node2上
启动顺序为:
1、 启动zookeeper,每台机器
2、 启动journalnode,每台机器
3、 启动hadoop,每台机器,包括namenode和datanode
4、 启动zkfs,每台namenode机器
二、 搭建zookeeper
yum install zookeeper
在/usr/lib/zookeeper/conf/(不同安装方式路径不同)中添加如下配置:
[root@cdh-node1 conf]# more zoo.cfg
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
maxClientCnxns=50
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
dataDir=/var/lib/zookeeper
# the port at which the clients will connect
clientPort=2181
#server.1=172.168.10.251:2888:3888
#server.2=172.168.10.252:2888:3888
#server.3=172.168.10.253:2888:3888
server.1=cdh-master:2888:3888
server.2=cdh-node1:2888:3888
server.3=cdh-node2:2888:3888
在各个机器中建立文件/var/lib/zookeeper/myid(不同安装方式路径不同) --myid中的数字代表当前机器在集群中的编号
cdh-master 中输入1 --要和上面对应
cdh-node1 中输入2
cdh-node2 中输入3
启动每台机器的zookeeper服务
./bin/zkServer.sh start
检查各个机器的启动情况
echo ruok | nc ocdata192181
echo ruok | nc ocdata172181
echo ruok | ncocdata18 2181
如果都返回imok 则代表zookeeper搭建成功