标签:bootstra name 数据 erp 入口 logs 服务 property org
对hdfs做高可用
服务器:centos7
Hadoop:2.6.5
Jdk:1.8
共四台服务器
192.168.1.111 node1
192.168.1.112 node2
192.168.1.113 node3
192.168.1.114 node4
在每台服务器的/etc/hosts文件中添加上边四行内容
服务器分配
|
NN |
DN |
ZK |
ZKFC |
JN |
RM |
DM |
Node1 |
1 |
|
1 |
1 |
|
1 |
|
Node2 |
1 |
1 |
1 |
1 |
1 |
|
1 |
Node3 |
|
1 |
1 |
|
1 |
|
1 |
Node4 |
|
1 |
|
|
1 |
|
1 |
Journalnode:需要为奇数个
Zookeeper:需要为奇数个
ZKFS和NN在同台服务器
DM和DN保持一致。
命令如下
ssh-keygen –t rsa –P ‘’ –f ~/.ssh/id_rsa
此时查看 ~/.ssh目录下,会有两个文件,id_rsa(私钥)、id_rsa.pub(公钥)
命令如下
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
每台服务器都需要拼接四次,包括本节点及其它三个节点的,配置完成后,即可免密登录其它节点
此处使用的hadoop版本为2.6.5
编辑/etc/hadoop/hadoop-env.sh文件
找到JAVA_HOME配置位置,修改JAVA_HOME如下
export JAVA_HOME= /home/java/jdk1.8.0_144
<property> <name>dfs.nameservices</name> <value>mycluster</value> </property>
<property> <name>dfs.ha.namenodes.mycluster</name> <value>nn1,nn2</value> </property>
注意:此处的mycluster和上边指定的服务名一致,nn1 nn2位两个namenode名称
<property> <name>dfs.namenode.rpc-address.mycluster.nn1</name> <value>machine1.example.com:8020</value> </property> <property> <name>dfs.namenode.rpc-address.mycluster.nn2</name> <value>machine2.example.com:8020</value> </property>
<property> <name>dfs.namenode.http-address.mycluster.nn1</name> <value>node1:50070</value> </property> <property> <name>dfs.namenode.http-address.mycluster.nn2</name> <value>node2:50070</value> </property>
<!-- 配置journalnode --> <property> <name>dfs.namenode.shared.edits.dir</name> <value>qjournal://node2:8485;node3:8485;node4:8485/mycluster</value> </property>
注意:此处的mycluster需要和服务名一样
<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_rsa</value>
</property>
<!--配置journalnode的工作目录--> <property> <name>dfs.journalnode.edits.dir</name> <value>/opt/journalnode/data</value> </property>
<!--开启自动切换(可选)-->
<property>
<name>dfs.ha.automatic-failover.enabled</name>
<value>true</value>
</property>
<!--配置namenode入口--> <property> <name>fs.defaultFS</name> <value>hdfs://mycluster</value> </property>
注意:此处的mycluster需要和hdfs-site.xml文件中的nameservice名称一致
<!--配置zookeeper的集群--> <property> <name>ha.zookeeper.quorum</name> <value>node1:2181,node2:2181,node3:2181</value> </property>
<!--配置hadoop的工作目录,默认在系统的临时目录下/tmp--> <property> <name>hadoop.tmp.dir </name> <value>/opt/hadoop2</value> </property>
node2
node3
node4
不需要配master了,因为没有secondarynamenode,journalnode替代了它
需要在node2、3、4启动journalnode
命令 ./hadoop-daemon.sh start journalnode
在node1上格式化namenode
./hdfs namenode –format
注意centos关闭防火墙一定要用systemctl stop firewalld
格式化后,在/opt/hadoop2下就会有元数据文件了
./hadoop-daemon.sh start namenode
./hdfs namenode –bootstrapStandby
命令成功执行后,在/opt/hadoop2/下就会有元数据文件了
hdfs zkfc -formatZK
./stop-dfs.sh
会停止除了zookeeper之外的所有进程
./start-dfs.sh
[root@localhost sbin]# ./start-dfs.sh Starting namenodes on [node1 node2] node2: starting namenode, logging to /home/hadoop/hadoop-2.6.5/logs/hadoop-root-namenode-node2.out node1: starting namenode, logging to /home/hadoop/hadoop-2.6.5/logs/hadoop-root-namenode-node1.out node4: starting datanode, logging to /home/hadoop/hadoop-2.6.5/logs/hadoop-root-datanode-node4.out node3: starting datanode, logging to /home/hadoop/hadoop-2.6.5/logs/hadoop-root-datanode-localhost.out node2: starting datanode, logging to /home/hadoop/hadoop-2.6.5/logs/hadoop-root-datanode-node2.out Starting journal nodes [node2 node3 node4] node4: starting journalnode, logging to /home/hadoop/hadoop-2.6.5/logs/hadoop-root-journalnode-node4.out node3: starting journalnode, logging to /home/hadoop/hadoop-2.6.5/logs/hadoop-root-journalnode-localhost.out node2: starting journalnode, logging to /home/hadoop/hadoop-2.6.5/logs/hadoop-root-journalnode-node2.out Starting ZK Failover Controllers on NN hosts [node1 node2] node2: starting zkfc, logging to /home/hadoop/hadoop-2.6.5/logs/hadoop-root-zkfc-node2.out node1: starting zkfc, logging to /home/hadoop/hadoop-2.6.5/logs/hadoop-root-zkfc-node1.out [root@localhost sbin]# jps 5234 Jps 5188 DFSZKFailoverController 3302 QuorumPeerMain 4920 NameNode
会发现有一个是active 一个是standby
在hdfs新建一个路径,上传文件
./hdfs dfs -mkdir -p /usr/file
./hdfs dfs -put /home/java/jdk-8u144-linux-x64.tar.gz /usr/file/
<property> <name>mapreduce.framework.name</name> <value>yarn</value> </property>
<!--resourcemanager在哪台服务器上-->
<property>
<name>yarn.resourcemanager.hostname</name>
<value>node1</value>
</property>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
<property>
<name>yarn.nodemanager.aux-services.mapreduce.shuffle.class</name>
<value>org.apache.hadoop.mapred.ShuffleHandler</value>
</property>
在node1上./stop-dfs.sh
Node1上 ./start-all.sh
jps查看进程
[root@node1 sbin]# jps
6977 NameNode
7603 Jps
3302 QuorumPeerMain
7244 DFSZKFailoverController
7327 ResourceManager
启动成功。
标签:bootstra name 数据 erp 入口 logs 服务 property org
原文地址:http://www.cnblogs.com/EnzoDin/p/7294719.html