标签:strong control bootstra ddr data rop boot dir val
namenode1 | namenode2 | datanode | zk | zkfc | jnn | |
node0001 | * | * | * | |||
node0002 | * | * | * | * | * | |
node0003 | * | * | * | |||
node0004 | * | * |
1,两个namenode节点相互免密钥,以完成主备切换
node0002:cd .ssh
ssh-keygen -t dsa -P ‘‘ -f ~/.ssh/id_dsa
cat id_dsa.pub >> authorized_keys (0002节点自己免密钥)
scp id_dsa.pub node0001:`pwd`/node0002.pub (发送到0001)
node0001:cd .ssh
cat node0002.pub >> authorized_keys
测试node0002 :ssh node0001
2,修改配置文件
vi hdfs-site.xml
<configuration> <property> <name>dfs.replication</name> <value>2</value> </property> <property> <name>dfs.nameservices</name> <value>mycluster</value> </property> <property> <name>dfs.ha.namenodes.mycluster</name> <value>nn1,nn2</value> </property> <property> <name>dfs.namenode.rpc-address.mycluster.nn1</name> <value>node0001:8020</value> </property> <property> <name>dfs.namenode.rpc-address.mycluster.nn2</name> <value>node0002:8020</value> </property> <property> <name>dfs.namenode.http-address.mycluster.nn1</name> <value>node0001:50070</value> </property> <property> <name>dfs.namenode.http-address.mycluster.nn2</name> <value>node0002:50070</value> </property> <property> <name>dfs.namenode.shared.edits.dir</name> <value>qjournal://node0001:8485;node0002:8485;node0003:8485/mycluster</value> </property> <property> <name>dfs.client.failover.proxy.provider.mycluster</name> <value>org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider</value> </property> <property> <name>dfs.ha.fencing.methods</name> <value>sshfence</value> </property> <property> <name>dfs.ha.fencing.ssh.private-key-files</name> <value>/root/.ssh/id_dsa</value> </property>
<property>
<name>dfs.journalnode.edits.dir</name>
<value>/var/sxt/hadoop/ha/jn</value>
</property>
<property>
<name>dfs.ha.automatic-failover.enabled</name>
<value>true</value>
</property>
</configuration>
vi core-site.xml
<configuration> <property> <name>fs.defaultFS</name> <value>hdfs://mycluster</value> </property> <property> <name>hadoop.tmp.dir</name> <value>/var/sxt/hadoop/ha</value> </property>
<property>
<name>ha.zookeeper.quorum</name>
<value>node0002:2181,node0003:2181,node0004:2181</value>
</property>
</configuration>
3,分发配置文件
scp core-site.xml hdfs-site.xml node0002:`pwd` (hadoop 目录下)
scp core-site.xml hdfs-site.xml node0003:`pwd` (hadoop 目录下)
scp core-site.xml hdfs-site.xml node0004:`pwd` (hadoop 目录下)
4,搭建zookeeper(0002,0003,0004)
node0002:cd /software (上传zookeeper-3.4.6.tar.gz)
tar xf zookeeper-3.4.6.tar.gz -C /opt/sxt/ (解压)
cd /opt/sxt/zookeeper-3.4.6
cd conf (修改zk配置文件)
mv zoo_sample.cfg zoo.cfg (修改名称才可用)
vi zoo.cfg
dataDir=/var/sxt/zk (修改,不要用临时的)
server.1=node0002:2888:3888 (最后追加)
server.2=node0003:2888:3888
server.3=node0004:2888:3888
cd /opt/sxt/
scp -r zookeeper-3.4.6/ node0003:`pwd`
scp -r zookeeper-3.4.6/ node0004:`pwd`
mkdir -p /var/sxt/zk (三台机器都要创建)
node0002:echo 1 > /var/sxt/zk/myid (每台机器zookeeper对应自己编号)
node0003:echo 2 > /var/sxt/zk/myid
node0004:echo 3 > /var/sxt/zk/myid
cd zookeeper-3.4.6 pwd (获取zk路径)
vi + /etc/profile
export ZOOKEEPER_HOME=路径
:$ZOOKEEPER_HOME/bin (追加到path后)
node0003和node0004相同配置
. /etc/profile (编译后,zkCli.sh查看是否能自动补全验证)
5,启动zookeeper(0002,0003,0004)
zkServer.sh start (三台都要启动,zkServer.sh stop 关闭)
jps (QuorumPeerMain 进程出现则成功启动)
zkServer.sh status (查看当前机器的主从状态)
6,启动journalnode(0001,0002,0003)
hadoop-daemon.sh start journalnode (三台机器都要启动)
jps (JournalNode进程出现则成功)
7,格式化namenode(随便找一个NN机器)
node0001:hdfs namenode -format (生成集群id文件,只执行一次)
hadoop-daemon.sh start namenode (启动该节点)
jps (namenode进程也会出现)
node0002:hdfs namenode -bootstrapStandby (将主节点的元数据信息拷贝到当前节点下)
8,格式化zkfc
node0001: hdfs zkfc -formatZK
8,启动集群
node0001:start-dfs.sh (只用在主节点)
jps
node0001:JournalNode
DFSZKFailoverController
NameNode
node0002:DataNode
JournalNode
DFSZKFailoverController
QuorumPeerMain
ZookeeperMain
NameNode
node0003:DataNode
JournalNode
QuorumPeerMain
node0004:DataNode
QuorumPeerMain
9,浏览器访问
node0001:50070
node0002:50070
标签:strong control bootstra ddr data rop boot dir val
原文地址:https://www.cnblogs.com/dongchao3312/p/13358295.html