008-Centos 7.x安装 Ambari 2.2.2 + HDP 2.4.2 搭建Hadoop集群

时间:2023-03-08 21:59:27
008-Centos 7.x安装 Ambari 2.2.2 + HDP 2.4.2 搭建Hadoop集群

1.安装环境说明

安装前先安装好 Centos 7.2, jdk-8u91, mysql5.7.13

一共有3台机器,一个是主节点192.168.111.10,两个是从:192.168.111.11,192.168.111.12

2.操作系统环境准备

2.1 配置SSH免密码登录

主节点里root用户登录执行如下步骤

ssh-keygen
cd ~/.ssh/
cat id_rsa.pub >>authorized_keys
chmod ~/.ssh
chmod ~/.ssh/authorized_keys

先在从节点登录root执行命令

mkdir ~/.ssh/

分发主节点里配置好的authorized_keys到各从节点

scp /root/.ssh/authorized_keys root@192.168.111.11:/root/.ssh/authorized_keys
scp /root/.ssh/authorized_keys root@192.168.111.12:/root/.ssh/authorized_keys

2.2 创建ambari系统用户和用户组

只在主节点操作

添加ambari安装、运行用户和用户组,也可以不创建新用户,直接使用root或者系统其他账号

adduser ambari
passwd ambari

2.3 开启NTP服务

所有集群上节点都需要操作

Centos 7 命令

yum  install ntp
systemctl is-enabled ntpd
systemctl enable ntpd
systemctl start ntpd

Centos 6 命令

yum install ntpd
chkconfig --list ntpd
chkconfig ntpd
service ntpd start

2.4 检查DNS和NSCD

所有节点都要设置

ambari在安装时需要配置全域名,所以需要检查DNS。为了减轻DNS的负担, 建议在节点里用 Name Service Caching Daemon (NSCD)

vi /etc/hosts
192.168.111.10 bjlhx1510 bjlhx1510.hadoop
192.168.111.11 bjlhx1511 bjlhx1511.hadoop
192.168.111.12 bjlhx1512 bjlhx1512.hadoop

每台节点里配置FQDN,如下以主节点为例

vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=bjlhx1510.hadoop

2.5 关闭防火墙

所有节点都要设置

Centos 7 命令

systemctl disable firewalld
systemctl stop firewalld

Centos 6 命令

chkconfig iptables off
/etc/init.d/iptables stop

2.6 关闭SELinux

所有节点都要设置

查看SELinux状态:

sestatus

如果SELinux status参数为enabled即为开启状态 
SELinux status: enabled

临时关闭,不用重启机器:

setenforce 

修改配置文件需要重启机器:

vi /etc/sysconfig/selinux
SELINUX=disabled

3.制作本地源

制作本地源只需在主节点上进行即可

3.1 相关准备工作

3.1.1安装 Apache HTTP 服务器

安装HTTP 服务器,允许 http 服务通过防火墙(永久)

yum install httpd
firewall-cmd --add-service=http
firewall-cmd --permanent --add-service=http

添加 Apache 服务到系统层使其随系统自动启动

systemctl start httpd.service
systemctl enable httpd.service
3.1.2 安装本地源制作相关工具
yum install yum-utils createrepo

3.2 下载安装资源

下载 Ambari 2.2.2 , HDP 2.4.2 的安装资源,本次安装是在Centos 7 上,只列出centos7的资源,其他系统的请现在对用系统的资源

Ambari 2.2.2 下载资源

OS Format URL
CentOS 7 Base URL http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.2.2.0
CentOS 7 Repo File http://public-repo-1.hortonworks.com/ambari/centos6/2.x/updates/2.2.2.0/ambari.repo
CentOS 7 Tarball md5 asc http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.2.2.0/ambari-2.2.2.0-centos7.tar.gz

HDP 2.4.2 下载资源

OS Repository Name Format URL
CentOS 7 HDP Base URL http://public-repo-1.hortonworks.com/HDP/centos7/2.x/updates/2.4.2.0
CentOS 7 HDP Repo File http://public-repo-1.hortonworks.com/HDP/centos7/2.x/updates/2.4.2.0/hdp.repo
CentOS 7 HDP Tarball md5 asc http://public-repo-1.hortonworks.com/HDP/centos7/2.x/updates/2.4.2.0/HDP-2.4.2.0-centos7-rpm.tar.gz
CentOS 7 HDP-UTILS Base URL http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.20/repos/centos7
CentOS 7 HDP-UTILS Repo File http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.20/repos/centos7/HDP-UTILS-1.1.0.20-centos7.tar.gz

下载上面列表的中的压缩包, 
需要下载的压缩包如下:

#Ambari 2.2.
axel http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.2.2.0/ambari-2.2.2.0-centos7.tar.gz
#HDP 2.4.
axel http://public-repo-1.hortonworks.com/HDP/centos7/2.x/updates/2.4.0.0/HDP-2.4.0.0-centos7-rpm.tar.gz
#HDP-UTILS 1.1.
axel http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.20/repos/centos7/HDP-UTILS-1.1.0.20-centos7.tar.gz

在httpd网站根目录,默认是即/var/www/html/,创建目录ambari,

并且将下载的压缩包解压到/var/www/html/ambari目录

cd /var/www/html/
mkdir ambari
cd /var/www/html/ambari/
tar -zxvf ambari-2.2.2.0-centos7.tar.gz
tar -zxvf HDP-2.4.2.0-centos7-rpm.tar.gz
tar -zxvf HDP-UTILS-1.1.0.20-centos7.tar.gz

验证httd网站是否可用,可以使用links 命令或者浏览器直接访问下面的地址:

links http://172.31.83.171/ambari/

结果如下

008-Centos 7.x安装 Ambari 2.2.2 + HDP 2.4.2 搭建Hadoop集群

3.3 配置ambari、HDP、HDP-UTILS的本地源

首先下载上面资源列表中的相应repo文件,

axel http://public-repo-1.hortonworks.com/ambari/centos6/2.x/updates/2.2.2.0/ambari.repo
axel http://public-repo-1.hortonworks.com/HDP/centos7/2.x/updates/2.4.2.0/hdp.repo

修改其中的URL为本地的地址,相关配置如下: