Preparing:
Source JDK 1.8.0
Source Hadoop
install hadoop
tar -zxvf jdk*****
tar -zxvf hadoop****.tar.gz
mv hadoop-*** hadoop
mv jdk*** jdk
vim ~/.bash_profile
export JAVA_HOME="/root/jdk"
export HADOOP_HOME="/root/hadoop"
export ZOOKEEPER_HOME="/root/zookeeper"
export PATH="$PATH:$JAVA_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$ZOOKEEPER_HOME/bin"
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
source ~/.bash_profile
# verify
echo $PATH
hadoop settings
vim /hadoop/etc/hadoop/hadoop-env.sh
export JAVA_HOME="/Install/jdk/jre"
vim hdfs-site.xml
<configuration>
<property>
<name>dfs.nameservices</name>
<value>ns</value>
</property>
<property>
<name>dfs.ha.namenodes.ns</name>
<value>nn1, nn2</value>
</property>
<property>
<name>dfs.namenode.rpc-address.ns.nn1</name>
<value>sv1:9000</value>
</property>
<property>
<name>dfs.namenode.http-address.ns.nn1</name>
<value>sv1:50070</value>
</property>
<property>
<name>dfs.namenode.rpc-address.ns.nn2</name>
<value>sv2:9000</value>
</property>
<property>
<name>dfs.namenode.http-address.ns.nn2</name>
<value>sv2:50070</value>
</property>
<property>
<name>dfs.namenode.shared.edits.dir</name>
<value>qjournal://:8485;sv2:8485;sv3:8485/ns</value>
</property>
<property>
<name>dfs.datanode.data.dir</name>
<value>/root/backup/hadoop/hdfs/data, /backup/hadoop/hdfs/data</value>
</property>
<property>
<name>dfs.namenode.checkpoint.dir</name>
<value>/root/backup/hadoop/hdfs/namesecondary, /backup/hadoop/hdfs/namesecondary</value>
</property>
</configuration>
vim core-site.xml
<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://ns</value>
</property>
</configuration>
vim mapred-site.xml
<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
<property>
<name>mapreduce.map.memory.mb</name>
<value>512</value>
</property>
<property>
<name>mapreduce.reduce.memory.mb</name>
<value>512</value>
</property>
<property>
<name>mapreduce.map.java.opts</name>
<value>-Xmx150m</value>
</property>
<property>
<name>mapreduce.reduce.java.opts</name>
<value>-Xmx512m</value>
</property>
<property>
<name>yarn.app.mapreduce.am.resource.mb</name>
<value>512</value>
</property>
<property>
<name>yarn.app.mapreduce.am.command-opts</name>
<value>-Xmx512m</value>
</property>
</configuration>
vim yarn-site.xml
<configuration>
<property>
<name>yarn.resourcemanager.hostname</name>
<value>sv3</value>
</property>
<property>
<name>yarn.resourcemanager.zk-address</name>
<value>sv1:2181,sv2:2181,sv3:2181</value>
</property>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
<property>
<name>yarn.scheduler.minimum-allocation-mb</name>
<value>256</value>
</property>
<property>
<name>yarn.scheduler.maximum-allocation-mb</name>
<value>1024</value>
</property>
<property>
<name>yarn.nodemanager.resource.memory-mb</name>
<value>1024</value>
</property>
<property>
<name>yarn.nodemanager.vmem-check-enabled</name>
<value>false</value>
</property>
</configuration>
vim slavers
sv1
sv2
sv3
verify
hdfs getconf -namenodes
start-all.sh
stop-all.sh