一. IP和主机名称配置
1.配置ip
vim /etc/sysconfig/network-scripts/ifcfg-ens33
2.配置主机名称
vim /etc/hostname
3.主机名称的映射
vim /etc/hosts
二. 安装jdk
1.查找并卸载系统自带的jdk
rpm -qa | grep -i java | xargs -n1 rpm -e –nodeps
2.上传压缩包
3.解压到指定的module文件夹
tar -zxvf jdk-8u212-linux-x64.tar.gz -C /opt/module/
4.配置jdk环境变量
cd /etc/profile.d/
vim my_env.sh
5.验证是否成功
三. 安装hadoop
1.解压到指定的module文件夹
tar -zxvf hadoop-3.1.3.tar.gz -C /opt/module/
2.配置hadoop环境变量
vim /etc/profile.d/my_env.sh
3.验证是否成功
四. 配置伪分布式
1.hadoop-env.sh
更改jdk环境变量和hadoop的安装目录
vim hadoop-env.sh
2.core-site.xml
vim core-site.xml
3.hdfs-site.xml
vim hdfs-site.xml
4.mapred-site.xml
vim mapred-site.xml
5.yarn-site.xml
vim yarn-site.xml
6.配置workers
vim /opt/module/hadoop-3.1.3/etc/hadoop/workers
7.格式化namenode
hadoop namenode -format
8.启动hadoop
start-dfs.sh
start-yarn.sh
或start-all.sh
9.检查集群
10.网页查看:IP:50070
补充:伪分布式环境搭建中所遇到的问题
一. 启动hadoop后报错:
sbin/start-dfs.sh
ERROR: Attempting to operate on hdfs namenode as root
ERROR: but there is no HDFS_NAMENODE_USER defined. Aborting operation.
Starting datanodes
ERROR: Attempting to operate on hdfs datanode as root
ERROR: but there is no HDFS_DATANODE_USER defined. Aborting operation.
Starting secondary namenodes [hadoop1]
ERROR: Attempting to operate on hdfs secondarynamenode as root
ERROR: but there is no HDFS_SECONDARYNAMENODE_USER defined. Aborting operation.
解决方法:
1.对于start-dfs.sh和stop-dfs.sh文件,添加下列参数:
HDFS_DATANODE_USER=root
HDFS_DATANODE_SECURE_USER=hdfs
HDFS_NAMENODE_USER=root
HDFS_SECONDARYNAMENODE_USER=root
2. 对于start-yarn.sh和stop-yarn.sh文件,添加下列参数:
YARN_RESOURCEMANAGER_USER=root
HADOOP_SECURE_DN_USER=yarn
YARN_NODEMANAGER_USER=root
二. 开启hadoop后,查看jps,显示只有resource manager一个进程
解决方法:配置ssh免密登录