hadoop单机环境配置
1.配置一台linux服务器(当前使用CentOS7)及一些基本设置
1.1在wmware下制作一台centos服务器(桥接模式)
并设置静态ip (编辑/etc/sysmconfig/network-scripts/ifcfg-ens33为如下内容,然后service network restart)
HWADDR="00:0C:29:76:12:2A"
Type="Ethernet"
BOOTPROTO="static"
IPADDR=192.168.1.155
GATEWAY=192.168.1.1
NETMASK=255.255.255.0
ONBOOT="yes"
1.2 设置机器名(/etc/hostname, e.g. master)
机器名及ip映射(/etc/hosts, e.g. 192.168.1.155 master)
2.关闭SELinux及防火墙
2.1 /etc/selinux/config(SELinux=disabled)
2.2 systemctl stop firewalld.service
3.安装java运行环境
4.下载hadoop(当前2.7.3版本),然后配置及运行
4.1 下载hadoop,并解压缩置指定 目录(e.g. /usr/local/hadoop)
4.2 设置hadoop环境变量(/etc/profile.d/hadoop.sh, 把如下内容copy进去,然后source /etc/profile.d/hadoop.sh)
#set hadoop environment
export JAVA_HOME=/usr/local/java
export HADOOP_HOME=/usr/local/hadoop
export PATH=$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$PATH
export HADOOP_MAPRED_HOME=$HADOOP_HOME
export HADOOP_COMMON_HOME=$HADOOP_HOME
export HADOOP_HDFS_HOME=$HADOOP_HOME
export YARN_HOME=HADOOP_HOME
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native
export HADOOP_OPTS="-Djava.library.path=$HADOOP_HOME/lib"
export JAVA_LIBRARY_PATH=$HADOOP_HOME/lib/native:$JAVA_LIBRARY_PATH
4.3 配置core-site.xml
<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://master:9000</value>
</property>
</configuration>
4.4 配置yarn-site.xml
......
<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>
......
4.5 配置mapred-site.xml
<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
</configuration>
4.6 配置hfds-site.xml
<configuration>
<property>
<name>dfs.name.dir</name>
<value>file:/usr/local/hadoop/hadoop_data/hdfs/namenode</value>
</property>
<property>
<name>dfs.data.dir</name>
<value>file:/usr/local/hadoop/hadoop_data/hdfs/datanode</value>
</property>
<property>
<name>dfs.replication</name>
<value>3</value>
</property>
</configuration>
4.7 创建目录namenode,datanode(e.g. mkdir -p /usr/local/hadoop/hadoop_data/hdfs/namenode)
4.8 更改hadoop目录的所有者(e.g. chown hduser:hadoop -R /usr/local/hadoop)
4.9 格式化namenode(hdfs namenode -format)
4.10 启动hdfs(start-dfs.sh), 启动yarn(start-yarn.sh), 或者使用start-all.sh启动两者
4.11 访问Hadoop Resource Manager Web界面(http://192.168.1.155:8088)
4.12 访问namenode hdfs Web界面(http://192.168.1.155:50070)
4.13 关闭stop-dfs.sh/stop-yarn.sh或者stop-all.sh