1.环境配置
1.1安装jdk
yum -y install java-1.7.0-openjdk*
1.2配置jdk
vim /etc/profile
加入以及内容:
export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.131-2.6.9.0.el7_3.x86_64/
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$CLASSPATH:$JAVA_HOME/lib:$JRE_HOME/lib
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
#配置hadoop home
export HADOOP_HOME=/usr/local/hadoop
export PATH=$PATH:$HADOOP_HOME/bin
export HADOOP_HOME_WARN_SUPPRESS=1
1.3配置ssh免密码登录
yum install openssh-server -y
//安装后,可以使用如下命令登陆本机:
ssh localhost
//此时会有如下提示(SSH首次登陆提示),输入 yes 。然后按提示输入密码 hadoop,这样就登陆到本机了
exit # 退出刚才的 ssh localhost
cd ~/.ssh/ # 若没有该目录,请先执行一次ssh localhost
ssh-keygen -t rsa # 会有提示,都按回车就可以
cat ./id_rsa.pub >> ./authorized_keys # 加入授权
1.4关闭防火墙
systemctl stop firewalld.service
//开机不启动
systemctl disable firewalld.service
2.安装hadoop
选择一个安装目录,我安装在:/usr/local
cd /usr/local
//下载hadoop2.7.1
wget http://apache.fayea.com/hadoop/common/hadoop-2.7.1/hadoop-2.7.1.tar.gz
//解压
tar -zxvf hadoop-2.7.1.tar.gz
3.配置分布式文件系统hdfs
3.1配置core-site.xml
//进入目录
cd hadoop-2.7.1/etc/hadoop
vim core-site.xml
配置内容如下:
<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://localhost:9000</value>
</property>
<property>
<name>hadoop.tmp.dir</name>
<value>/hadoop/tmp</value>
</property>
</configuration>
3.2配置hdfs-site.xml
vim hdfs-site.xml
配置内容如下:
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
</configuration>
3.3配置hadoop-env.sh
修改Javahome
vim hadoop-env.sh
配置内容如下:
export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.131-2.6.9.0.el7_3.x86_64/
4.配置资源调度yarn
4.1配置mapred-site.xml
//复制模板文件,修改
cp mapred-site.xml.template mapred-site.xml
vim mapred-site.xml
配置内容如下:
<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
</configuration>
4.2配置yarn-site.xml
vim yarn-site.xml
配置内容如下:
<configuration>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
</configuration>
5.启动和关闭
5.1启动
//回到hadoop目录
cd /usr/local/hadoop
//格式化操作
bin/hdfs namenode -format
//启动hdsf
sbin/start-dfs.sh
//启动yarn
sbin/start-yarn.sh
5.2查看
jps
改自己的IP,浏览一下地址:
http://192.168.1.103:8088/
http://192.168.1.103:50070/
5.3关闭
//关闭hdfs
sbin/stop-dfs.sh
//关闭yarn
sbin/stop-yarn.sh