准备工作
配置节点间 ssh 免密
略
安装 java 环境
略
搭建 zookeeper
zookeeper集群搭建
绑定 hosts
1 2 3 4 5
| cat >> /etc/hosts << 'EOF' 192.168.200.11 hadoop1 192.168.200.12 hadoop2 192.168.200.13 hadoop3 EOF
|
环境变量
vim /etc/profile
1 2 3
| export HADOOP_HOME=/data/hadoop-3.2.4/ export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin
|
创建目录
1 2
| mkdir -p /data/hadoop_data/ mkdir -p /var/lib/hadoop-hdfs
|
修改配置
workers 这里面是 datanode 节点列表。
1 2 3 4
| [root@m1 hadoop] hadoop1 hadoop2 hadoop3
|
hadoop-env.sh
1 2 3 4 5 6 7 8 9 10
| export JAVA_HOME=/usr/local/java
export HDFS_NAMENODE_USER=root export HDFS_DATANODE_USER=root export HDFS_SECONDARYNAMENODE_USER=root export YARN_RESOURCEMANAGER_USER=root export YARN_NODEMANAGER_USER=root export HDFS_JOURNALNODE_USER=root export HDFS_ZKFC_USER=root
|
hdfs-site.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
| <configuration>
<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>hadoop1:8020</value> </property>
<property> <name>dfs.namenode.http-address.mycluster.nn1</name> <value>hadoop1:9870</value> </property>
<property> <name>dfs.namenode.rpc-address.mycluster.nn2</name> <value>hadoop2:8020</value> </property>
<property> <name>dfs.namenode.http-address.mycluster.nn2</name> <value>hadoop2:9870</value> </property>
<property> <name>dfs.namenode.shared.edits.dir</name> <value>qjournal://hadoop1:8485;hadoop2:8485;hadoop3:8485/mycluster</value> </property>
<property> <name>dfs.journalnode.edits.dir</name> <value>/data/hadoop_data/journaldata</value> </property>
<property> <name>dfs.ha.automatic-failover.enabled</name> <value>true</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>shell(/bin/true)</value> </property>
<property> <name>dfs.client.read.shortcircuit</name> <value>true</value> </property>
<property> <name>dfs.domain.socket.path</name> <value>/var/lib/hadoop-hdfs/dn_socket</value> </property>
<property> <name>dfs.hosts.exclude</name> <value>/data/hadoop-3.2.4/etc/hadoop/excludes</value> </property>
</configuration>
|
core-site.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| <configuration>
<property> <name>fs.defaultFS</name> <value>hdfs://mycluster</value> </property>
<property> <name>hadoop.tmp.dir</name> <value>/data/hadoop_data/tmp</value> </property>
<property> <name>hadoop.http.staticuser.user</name> <value>root</value> </property>
<property> <name>ha.zookeeper.quorum</name> <value>hadoop1:2181,hadoop2:2181,hadoop3:2181</value> </property> </configuration>
|
集群初始化
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
hdfs --daemon start journalnode
[root@hadoop1 ~] [root@hadoop1 ~]
[root@hadoop2 ~]
[root@hadoop1 ~]
|
start-dfs.sh
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| [root@hadoop1 ~] 6355 QuorumPeerMain 6516 JournalNode 7573 DataNode 7989 DFSZKFailoverController 8040 Jps 7132 NameNode [root@hadoop2 ~] 4688 JournalNode 5201 NameNode 5521 Jps 5282 DataNode 4536 QuorumPeerMain 5482 DFSZKFailoverController [root@hadoop3 ~] 4384 DataNode 3990 QuorumPeerMain 4136 JournalNode 4511 Jps
|
检查
浏览器打开
http://hadoop1:9870 查看状态。