赞
踩
所有主机关闭防火墙。
所有主机安装JDK1.8,并配置环境变量。
所有主机设置静态IP地址,修改主机名称。
设置所有主机selinux=disabled。
安装好zookeeper集群。并启动。
机器现状
六台虚拟机a2-a7
export JAVA_HOME=/apps/jdk 可以只配置这其他的我这是后边有问题加上的
export HADOOP_PID_DIR=/apps/hadoop/hadoop_data/tmp/pids
HADOOP_CLASSPATH=$HADOOP_CLASSPATH:/apps/hadoop/share/hadoop/mapreduce/*
- <!-- 指定hdfs的nameservice为ns1 -->
- <property>
- <name>fs.defaultFS</name>
- <value>hdfs://test</value>
- </property>
- <!-- 指定hadoop hdfs目录 -->
- <property>
- <name>hadoop.tmp.dir</name>
- <value>/data/hadoop/</value>
- </property>
- <property>
- <name>hadoop.native.lib</name>
- <value>false</value>
- <description>Should native hadoop libraries, if present, be used.</description>
- </property>
- <!-- 指定zookeeper地址 -->
- <property>
- <name>ha.zookeeper.quorum</name>
- <value>a1:2181,a2:2181,a3:2181,a4:2181,a5:2181,a6:2181</value>
- </property>
- <!--可选的配置QJM日志目录-->
- <property>
- <name>dfs.journalnode.edits.dir</name>
- <value>/data/hadoop/journal/local/data</value>
- </property>
- <?xml version="1.0" encoding="UTF-8"?>
- <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
- <!--
- Licensed 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. See accompanying LICENSE file.
- -->
-
- <!-- Put site-specific property overrides in this file. -->
-
- <configuration>
- <!--指定hdfs的nameservice为test,需要和core-site.xml中的保持一致 -->
- <property>
- <name>dfs.nameservices</name>
- <value>test</value>
- </property>
- <property>
- <name>dfs.ha.namenodes.test</name>
- <value>nn1,nn2,nn3,nn4,nn5</value>
- </property>
- <!--配置每一个NameNode的rpc通信地址-->
- <property>
- <name>dfs.namenode.rpc-address.test.nn1</name>
- <value>a2:8020</value>
- </property>
- <property>
- <name>dfs.namenode.rpc-address.test.nn2</name>
- <value>a3:8020</value>
- </property>
- <property>
- <name>dfs.namenode.rpc-address.test.nn3</name>
- <value>a4:8020</value>
- </property>
- <property>
- <name>dfs.namenode.rpc-address.test.nn4</name>
- <value>a5:8020</value>
- </property>
- <property>
- <name>dfs.namenode.rpc-address.test.nn5</name>
- <value>a6:8020</value>
- </property>
- <!--配置每一个NameNode的web http地址-->
- <property>
- <name>dfs.namenode.http-address.test.nn1</name>
- <value>a2:9870</value>
- </property>
- <property>
- <name>dfs.namenode.http-address.test.nn2</name>
- <value>a3:9870</value>
- </property>
- <property>
- <name>dfs.namenode.http-address.test.nn3</name>
- <value>a4:9870</value>
- </property>
- <property>
- <name>dfs.namenode.http-address.test.nn4</name>
- <value>a5:9870</value>
- </property>
- <property>
- <name>dfs.namenode.http-address.test.nn5</name>
- <value>a6:9870</value>
- </property>
- <property>
- <name>dfs.namenode.shared.edits.dir</name>
- <value>qjournal://a2:8485;a3:8485;a4:8485/test</value>
- </property>
- <!--配置QJM日志的目录-->
- <property>
- <name>dfs.journalnode.edits.dir</name>
- <value>/data/hadoop/qjm/edits</value>
- </property>
- <!--配置为自动切换功能打开,需要在core-site.xml文件中配置ZK地址-->
- <property>
- <name>dfs.ha.automatic-failover.enabled</name>
- <value>true</value>
- </property>
- <property>
- <name>dfs.client.failover.proxy.provider.test</name>
- <value>org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider</value>
- </property>
- <!--配置自动切换的方式-->
- <property>
- <name>dfs.ha.fencing.methods</name>
- <value>
- sshfence
- shell(/bin/true)
- </value>
- </property>
-
- <!--配置SSH key,注意根据不同的用户名修改目录-->
-
- <property>
- <name>dfs.ha.fencing.ssh.private-key-files</name>
- <value>/root/.ssh/id_rsa</value>
- </property>
-
- <property>
- <name>dfs.permissions.enabled</name>
- <value>false</value>
- </property>
-
- <!-- 配置sshfence隔离机制超时时间 -->
- <property>
- <name>dfs.ha.fencing.ssh.connect-timeout</name>
- <value>30000</value>
- </property>
- <property>
- <name>dfs.namenode.checkpoint.check.period</name>
- <value>3600s</value>
- </property>
- </configuration>
- <property>
- <name>mapreduce.framework.name</name>
- <value>yarn</value>
- </property>
- <!--配置RM高可靠-->
-
- <property>
- <name>yarn.resourcemanager.ha.enabled</name>
- <value>true</value>
- </property>
-
- <property>
- <name>yarn.resourcemanager.cluster-id</name>
- <value>cluster1</value>
- </property>
-
- <!--配置Resourcemanager个数,hadoop3以后可以为3到5个-->
-
- <property>
- <name>yarn.resourcemanager.ha.rm-ids</name>
- <value>rm1,rm2,rm3</value>
- </property>
-
- <!--以下配置每一个RM的地址-->
-
- <property>
- <name>yarn.resourcemanager.hostname.rm1</name>
- <value>a2</value>
- </property>
-
- <property>
- <name>yarn.resourcemanager.hostname.rm2</name>
- <value>a3</value>
- </property>
-
- <property>
- <name>yarn.resourcemanager.hostname.rm3</name>
- <value>a4</value>
- </property>
-
- <!--配置每一个RM的http地址-->
-
- <property>
- <name>yarn.resourcemanager.webapp.address.rm1</name>
- <value>a2:8088</value>
- </property>
-
- <property>
- <name>yarn.resourcemanager.webapp.address.rm2</name>
- <value>a3:8088</value>
- </property>
-
- <property>
- <name>yarn.resourcemanager.webapp.address.rm3</name>
- <value>a4:8088</value>
- </property>
-
- <!--配置zookeeper地址-->
-
- <property>
- <name>yarn.resourcemanager.zk-address</name>
- <value>a2:2181,a3:2181,a4:2181</value>
- </property>
-
- <property>
- <name>yarn.nodemanager.aux-services</name>
- <value>mapreduce_shuffle</value>
- </property>
- <property>
- <name>yarn.application.classpath</name>
- <value>/apps/hadoop/etc/hadoop:/apps/hadoop/share/hadoop/common/lib/*:/apps/hadoop/share/hadoop/common/*:/apps/hadoop/share/hadoop/hdfs:/apps/hadoop/share/hadoop/hdfs/lib/*:/apps/hadoop/share/hadoop/hdfs/*:/apps/hadoop/share/hadoop/mapreduce/lib/*:/apps/hadoop/share/hadoop/mapreduce/*:/apps/hadoop/share/hadoop/yarn:/apps/hadoop/share/hadoop/yarn/lib/*:/apps/hadoop/share/hadoop/yarn/*</value>
- </property>
- <property>
- <name>yarn.nodemanager.resource.memory-mb</name>
- <value>16384</value>
- </property>
- <property>
- <name>yarn.nodemanager.resource.cpu-vcores</name>
- <value>4</value>
- </property>
- <property>
- <name>yarn.scheduler.maximum-allocation-vcores</name>
- <value>4</value>
- </property>
-
- a2
- a3
- a4
- a5
- a6
- a7
在中间位置,找到一个空白的位置添加:
HDFS_NAMENODE_USER=root
HDFS_SECONDARYNAMENODE_USER=root
HDFS_DATANODE_USER=root
HDFS_DATANODE_SECURE_USER=root
#以下是高可靠配置的
HDFS_JOURNALNODE_USER=root
HDFS_ZKFC_USER=root
在两个配置文件中间位置添加以下内容:
YARN_RESOURCEMANAGER_USER=root
YARN_NODEMANAGER_USER=root
export HADOOP_HOME=/data/apps/hadoop-3.3.0
export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin
scp -r /data/apps/hadoop/ a3:/data/apps/
hadoop-daemon.sh start journalnode
hdfs namenode -format
出现successfully formatted为成功
现在将格式化后的hdfs目录,拷贝到a3,a4,a5,a6主机上的相同目录下:
scp -r /data/hadoop/dfs/ a3:/data/hadoop/
内容是这样 的目录
格式化前要停止
hadoop-daemon.sh stop journalnode 不停止会报错,如果不报错就不用在意
hdfs zkfc -formatZK
Successfully created hadoop-ha/cluster in ZK 出现这个就是成功
start-dfs.sh 因为配置了环境变量所以可以直接启动
start-yarn.sh
start-all.sh 启动所有
stop-all.sh 停止全部
web 访问 http://ip:9870
$ hdfs haadmin -getServiceState nn1
active
$ hdfs haadmin -getServiceState nn2
standby
$ yarn rmadmin -getServiceState rm1
active
$ yarn rmadmin -getServiceState rm2
standby
有可能出现的问题:
这个问题现在还没有解决 可以手动切换namenode 到前两个namenode
Currently, the standby NN will log StandbyExceptions at ERROR level any time a client tries to connect to it. So, if the second NN in an HA pair is active, the first NN will spew a lot of these errors in the log, as each client gets redirected to the proper NN. Instead, this should be at INFO level, and should probably be logged in a less "scary" manner (eg "Received READ request from client 1.2.3.4, but in Standby state. Redirecting client to other NameNode.")
有大神知道怎么解决可以留言谢谢
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。