一、hadoop安装
1、在master机器上,解压到/home/hadoop/目录下
tar -zxcf hadoop-2.6.5.tar.gz -C /usr/softwares/
2、在hadoop-2.7.3文件夹里面先创建文件夹
mkdir -p hadoop-2.7.3/data/name
mkdir -p hadoop-2.7.3/data/data
mkdir -p hadoop-2.7.3/data/tmp
mkdir -p hadoop-2.7.3/data/edits_share
mkdir -p hadoop-2.7.3/data/journal
二、配置
1、hadoop-env.sh文件
sudo vim hadoop-env.sh
Export JAVA_HOME=/usr/softwares/jdk1.8.0_191
2、yarn-env.sh文件
将其中的JAVA_HOME修改为本机JAVA_HOME路径(先把这一行的#去掉)
export JAVA_HOME=/usr/softwares/jdk1.8.0_191
3、 core-site.xml文件
<configuration>
<!-- hdfs地址,ha模式中是连接到nameservice -->
<property>
<name>fs.defaultFS</name>
<value>hdfs://masters</value>
</property>
<!-- 这里的路径默认是NameNode、DataNode、JournalNode等存放数据的公共目录,也可以单独指定 -->
<property>
<name>hadoop.tmp.dir</name>
<value>file:///usr/softwares/hadoop-2.7.3/data/tmp</value>
<description>A base for other temporary directories.</description>
</property>
<!-- 指定ZooKeeper集群的地址和端口。注意,数量一定是奇数,且不少于三个节点-->
<property>
<name>ha.zookeeper.quorum</name>
<value>192.168.199.131:2181,192.168.199.132:2181,192.168.199.134:2181</value>
</property>
<property>
<name>io.file.buffer.size</name>
<value>131072</value>
</property>
- <property>
<name>dfs.journalnode.edits.dir</name>
<value>/usr/hadoop-2.7.3/data/journal</value>
</property>
</configuration>
4、hdfs-site.xml 文件
<configuration>
<property>
<name>dfs.nameservices</name>
<value>masters</value>
</property>
<property>
<name>dfs.ha.namenodes.masters</name>
<value>master,slave1</value>
</property>
<property>
<name>dfs.namenode.rpc-address.masters.master</name>
<value>192.168.199.131:8020</value>
</property>
<property>
<name>dfs.namenode.rpc-address.masters.slave1</name>
<value>192.168.199.132:8020</value>
</property>
<property>
<name>dfs.namenode.http-address:masters.master</name>
<value>192.168.199.131:50070</value>
</property>
<property>
<name>dfs.namenode.http-address:masters.slave1</name>
<value>192.168.199.132:50070</value>
</property>
<property>
<name>dfs.namenode.shared.edits.dir</name>
<value>file:///usr/softwares/hadoop-2.7.3/data/edits_share</value>
</property>
<property>
<name>dfs.clien