官方文档: https://hadoop.apache.org/docs/r2.8.5/
安装文档:https://hadoop.apache.org/docs/r2.8.5/hadoop-project-dist/hadoop-common/SingleCluster.html
hadoop,hbase,jdk版本对应:https://hbase.apache.org/2.1/book.html
1.准备安装先决条件
[root@localhost ~]# hostnamectl set-hostname node1 --每台机器设置主机名,重启系统
[root@localhost ~]# vim /etc/hosts --将主机名添加到host解析
172.16.8.23 node1
172.16.8.24 node2
172.16.8.178 node3
172.16.8.179 node4
[root@node1 ~]# ssh-keygen -t rsa --每台主机生成密钥
[root@node1 ~]# ssh-copy-id node1 --将每台主机的密钥传到node1节点上
[root@node1 ~]# scp /root/.ssh/authorized_keys node2:/root/.ssh/ --将node1的authorized_keys文件传到其它node上
[root@node1 ~]# ssh node1 date --node1节点与其它节点全部免登陆
2019年 03月 16日 星期六 15:41:35 CST
[root@node1 ~]# ssh node2 date
2019年 03月 16日 星期六 15:41:40 CST
[root@node1 ~]# ssh node3 date
2019年 03月 16日 星期六 15:41:43 CST
[root@node1 ~]# ssh node4 date
2019年 03月 16日 星期六 15:41:46 CST
[root@node1 ~]#
2.启用NTP时间服务器
[root@node1 ~]# yum install ntp -y --在node1搭建ntp服务器
[root@node1 ~]# vim /etc/ntp.conf
restrict 172.16.8.0 mask 255.255.255.0
server 172.16.8.23
[root@node1 ~]# systemctl restart ntpd
[root@node2 ~]# vim /etc/ntp/step-tickers --在客户端设置ntp服务端的主机名
node1
[root@node2 ~]#
3.下载解压hadoop安装包(在各节点上安装jdk和hadoop)
[root@node1 ~]# wget https://download.oracle.com/otn-pub/java/jdk/8u202-b08/1961070e4c9b4e26a04e7f5a083f551e/jdk-8u202-linux-x64.rpm?
AuthParam=1552723272_02cde009ff2384cfcf01e2c377d085cc
[root@node1 ~]# wget http://mirrors.shu.edu.cn/apache/hadoop/common/hadoop-2.8.5/hadoop-2.8.5.tar.gz
[root@node1 ~]# scp jdk-8u202-linux-x64.rpm node2:/root/ --将jdk传到各节点上
[root@node1 ~]# rpm -ivh jdk-8u202-linux-x64.rpm --在各节点安装jdk
[root@node1 ~]# tar xvf hadoop-2.8.5.tar.gz -C /opt/
[root@node1 ~]# cd /opt/hadoop-2.8.5/etc/hadoop/
[root@node1 hadoop]# vim hadoop-env.sh
export JAVA_HOME=/usr/java/jdk1.8.0_202-amd64/
[root@node1 hadoop]# vim core-site.xml
fs.defaultFS hdfs://node1:9000 --数据上传下载端口(rpc协议) hadoop.tmp.dir /opt/hadoop-2.8.5/tmp --需要新建一个目录
[root@node1 hadoop]# vim hdfs-site.xml
dfs.namenode.secondary.http-address --使用node1的50090端口可以访问HDFS数据 node1:50090 dfs.namenode.secondary.https-address node1:50091
[root@node1 hadoop]# cat masters --配置namenode节点
node1
[root@node1 hadoop]# cat slaves --配置datanode节点
node2
node3
node4
[root@node1 hadoop]# vim mapred-site.xml
mapreduce.framework.name yarn
[root@node1 hadoop]# vim yarn-site.xml
yarn.nodemanager.aux-services mapreduce_shuffle
[root@node1 hadoop]# cd /opt/
[root@node1 opt]# scp -r hadoop-2.8.5 node2:/opt/ --将hadoop复制到其它node节点
4.配置环境变量
[root@node1 ~]# vim /etc/profile
export JAVA_HOME=/usr/java/jdk1.8.0_202-amd64
export HADOOP_HOME=/opt/hadoop-2.8.5
export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$JAVA_HOME/bin
[root@node1 ~]# source /etc/profile
[root@node1 ~]# scp /etc/profile node2:/etc/ --将环境变量文件复制到其它node节点
5.在master节点格式化磁盘
[root@node1 opt]# hdfs namenode -format
[root@node1 opt]# start-dfs.sh
Starting namenodes on [node1]
node1: starting namenode, logging to /opt/hadoop-2.8.5/logs/hadoop-root-namenode-node1.out
node2: starting datanode, logging to /opt/hadoop-2.8.5/logs/hadoop-root-datanode-node2.out
node4: starting datanode, logging to /opt/hadoop-2.8.5/logs/hadoop-root-datanode-node4.out
node3: starting datanode, logging to /opt/hadoop-2.8.5/logs/hadoop-root-datanode-node3.out
Starting secondary namenodes [node1]
node1: starting secondarynamenode, logging to /opt/hadoop-2.8.5/logs/hadoop-root-secondarynamenode-node1.out
[root@node1 opt]# jps
5152 SecondaryNameNode
5320 Jps
3929 DataNode
4926 NameNode
[root@node1 opt]# start-yarn.sh
starting yarn daemons
starting resourcemanager, logging to /opt/hadoop-2.8.5/logs/yarn-root-resourcemanager-node1.out
node2: starting nodemanager, logging to /opt/hadoop-2.8.5/logs/yarn-root-nodemanager-node2.out
node4: starting nodemanager, logging to /opt/hadoop-2.8.5/logs/yarn-root-nodemanager-node4.out
node3: starting nodemanager, logging to /opt/hadoop-2.8.5/logs/yarn-root-nodemanager-node3.out
[root@node1 opt]# jps
8517 ResourceManager
3929 DataNode
8042 NameNode
8269 SecondaryNameNode
8813 Jps
[root@node1 opt]#
6.其它datanode节点
[root@node2 opt]# jps
5411 NodeManager
5607 Jps
5259 DataNode
[root@node2 opt]#
7.使用web页面
http://node1:50070
http://node1:8088
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/25854343/viewspace-1394651/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/25854343/viewspace-1394651/