0429-如何在Redhat7.4安装HDP3.0.1

别说谁变了你拦得住时间么 提交于 2020-02-19 00:27:44

温馨提示:如果使用电脑查看图片不清晰,可以使用手机打开文章单击文中的图片放大查看高清原图。
Fayson的github:
https://github.com/fayson/cdhproject
提示:代码块部分可以左右滑动查看噢

1.文档编写目的


7月13日,Hortonworks在其官网宣布发布HDP3.0,相关介绍可以参考Fayson昨天的文章《Hortonworks正式发布HDP3.0》,最近又更新到了HDP3.0.1。本文档Fayson主要描述如何在Redhat7.4安装HDP3.0.1。HDP与CDH的安装步骤一致,主要包括以下四部分:

1.安全前置准备,包括安装操作系统、关闭防火墙、同步服务器时钟等;

2.外部数据库如MySQL安装

3.安装Ambari;

4.安装HDP集群;

  • 本次Fayson的测试环境为

1.Ambari2.7.1

2.HDP3.0.1

3.Redhat7.4

4.JDK1.8.0_141

5.MariaDB-5.5.56

6.root用户安装

2.前置准备

2.1.hostname及hosts配置


集群中各个节点之间能互相通信使用静态IP地址。IP地址和主机名通过/etc/hosts配置,主机名通过/etc/hostname进行配置。

以Ambari节点(172.31.13.10)为例:

  • hostname配置

/etc/hostname文件如下:

ip-172-31-13-10.ap-southeast-1.compute.internal

(可左右滑动)

或者你可以通过命令修改立即生效

[root@ip-172-31-13-10 ~]$ hostnamectl set-hostname ip-172-31-13-10.ap-southeast-1.compute.internal

(可左右滑动)

  • hosts配置

/etc/hosts文件如下:

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

172.31.13.10 ip-172-31-13-10.ap-southeast-1.compute.internal
172.31.15.170 ip-172-31-15-170.ap-southeast-1.compute.internal
172.31.8.219 ip-172-31-8-219.ap-southeast-1.compute.internal
172.31.0.246 ip-172-31-0-246.ap-southeast-1.compute.internal

(可左右滑动)

以上两步操作,在集群中其它节点做相应配置。确认需要安装的4台主机的hosts文件:

2.2.禁用SELinux


在所有节点执行setenforce 0 命令,此处使用批处理shell执行:

[root@ip-172-31-13-10 shell]# sh ssh_do_all.sh node.list "setenforce 0"

(可左右滑动)

集群所有节点修改/etc/selinux/config文件如下:

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

(可左右滑动)

2.3.关闭防火墙


集群所有节点执行 systemctl stop命令,此处通过shell批量执行命令如下:

[root@ip-172-31-13-10 shell]# sh ssh_do_all.sh node.list "systemctl stop firewalld"
[root@ip-172-31-13-10 shell]# sh ssh_do_all.sh node.list "systemctl disable firewalld"
[root@ip-172-31-13-10 shell]# sh ssh_do_all.sh node.list "systemctl status firewalld"

(可左右滑动)

2.4.集群时钟同步


在Redhat7.x的操作系统上,已经默认的安装了chrony,我们这里先卸载chrony,然后安装ntp。使用ntp来配置各台机器的时钟同步,将Ambari(172.31.13.10)服务作为本地ntp服务器,其它3台服务器与其保持同步。

1.所有机器卸载chrony

[root@ip-172-31-13-10 shell]# sh ssh_do_all.sh node.list "yum -y remove chrony"

(可左右滑动)

2.所有机器安装ntp

[root@ip-172-31-13-10 shell]# sh ssh_do_all.sh node.list "yum -y remove chrony"

(可左右滑动)

3.Ambari机器配置时钟与自己同步

[root@ ip-172-31-13-10 shell]# vim /etc/ntp.conf
#server 0.rhel.pool.ntp.org iburst
#server 1.rhel.pool.ntp.org iburst
#server 2.rhel.pool.ntp.org iburst
#server 3.rhel.pool.ntp.org iburst
server  127.127.1.0     # local clock
fudge   127.127.1.0 stratum 10

(可左右滑动)

4.集群其它节点,配置找Ambari机器去同步

#server 0.rhel.pool.ntp.org iburst
#server 1.rhel.pool.ntp.org iburst
#server 2.rhel.pool.ntp.org iburst
#server 3.rhel.pool.ntp.org iburst
server 172.31.13.10

(可左右滑动)

2.重启所有机器的ntp服务

[root@ ip-172-31-13-10 shell]# sh ssh_do_all.sh node.list "systemctl restart ntpd"
[root@ ip-172-31-13-10 shell]# sh ssh_do_all.sh node.list "systemctl status ntpd"

(可左右滑动)

6.验证始终同步,在所有节点执行ntpq -p命令,如下使用脚本批量执行

[root@ ip-172-31-13-10 shell]# sh ssh_do_all.sh node.list "ntpq -p"

(可左右滑动)

左边出现*号表示同步成功。

2.5.设置swap


所有节点执行

[root@ ip-172-31-13-10 shell]# sh ssh_do_all.sh node.list "echo vm.swappiness = 10 >> /etc/sysctl.conf"
[root@ ip-172-31-13-10 shell]# 

(可左右滑动)

2.6.设置透明大页面


所有节点执行:

[root@ ip-172-31-13-10 shell]# sh ssh_do_all.sh node.list "echo never > /sys/kernel/mm/transparent_hugepage/defrag "
[root@ ip-172-31-13-10 shell]# sh ssh_do_all.sh node.list  "echo never > /sys/kernel/mm/transparent_hugepage/enabled"

(可左右滑动)

设置开机自关闭

将如下脚本添加到/etc/rc.d/rc.local文件中

if test -f /sys/kernel/mm/transparent_hugepage/enabled; then echo never > /sys/kernel/mm/transparent_hugepage/enabled fi if test -f /sys/kernel/mm/transparent_hugepage/defrag; then echo never > /sys/kernel/mm/transparent_hugepage/defrag fi

(可左右滑动)

同步到所有节点

2.7.配置操作系统repo


Fayson用的是AWS的环境,这步是可以省略的,放在这里供物理机部署的兄弟们参考。

  • 挂载操作系统iso文件
[ec2-user@ip-172-31-2-159 ~]$ sudo mkdir /media/DVD1
[ec2-user@ip-172-31-2-159 ~]$ sudo mount -o loop 
CentOS-7-x86_64-DVD-1611.iso /media/DVD1/

(可左右滑动)

  • 配置操作系统repo
[ec2-user@ip-172-31-2-159 ~]$ sudo vim /etc/yum.repos.d/local_os.repo
[local_iso]    
name=CentOS-$releasever - Media
baseurl=file:///media/DVD1
gpgcheck=0
enabled=1
[ec2-user@ip-172-31-2-159 ~]$ sudo yum repolist

(可左右滑动)

2.8.安装http服务


  • 安装httpd服务
[ec2-user@ip-172-31-2-159 ~]$ sudo yum -y install httpd

(可左右滑动)

  • 启动httpd服务
[ec2-user@ip-172-31-2-159 ~]$ sudo systemctl start httpd

(可左右滑动)

  • 安装完httpd后,重新制作操作系统repo,换成http的方式方便其它服务器也可以访问
[ec2-user@ip-172-31-2-159 ~]$ sudo mkdir /var/www/html/iso
[ec2-user@ip-172-31-2-159 ~]$ sudo scp -r /media/DVD1/* /var/www/html/iso/
[ec2-user@ip-172-31-2-159 ~]$ sudo vim /etc/yum.repos.d/os.repo 
[osrepo]
name=os_repo
baseurl=http://172.31.2.159/iso/
enabled=true
gpgcheck=false
[ec2-user@ip-172-31-2-159 ~]$ sudo yum repolist

(可左右滑动)

2.9.安装MariaDB


1.安装MariaDB

[root@ ip-172-31-13-10 ~]# yum -y install mariadb
[root@ ip-172-31-13-10 ~]# yum -y install mariadb-server

(可左右滑动)

2.启动并配置MariaDB

[root@ ip-172-31-13-10 ~]# systemctl start mariadb
[root@ ip-172-31-13-10 ~]# /usr/bin/mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] Y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] Y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] n
 ... skipping.

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] Y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] Y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

(可左右滑动)

3.建立Ambari,Hive等需要的用户和数据库

[root@ip-172-31-13-10 ~]# mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 9
Server version: 5.5.56-MariaDB MariaDB Server

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> 

create database metastore default character set utf8;  CREATE USER 'hive'@'%' IDENTIFIED BY 'password';   GRANT ALL PRIVILEGES ON metastore. * TO 'hive'@'%';   FLUSH PRIVILEGES;  create database ambari default character set utf8;  CREATE USER 'ambari'@'%' IDENTIFIED BY 'password';   GRANT ALL PRIVILEGES ON ambari. * TO 'ambari'@'%';   FLUSH PRIVILEGES; 

(可左右滑动)

  • 安装jdbc驱动
[root@ip-172-31-13-10 shell]# mkdir -p /usr/share/java/
[root@ip-172-31-13-10 ~]# mv mysql-connector-java-5.1.34.jar /usr/share/java/
[root@ip-172-31-13-10 ~]# cd /usr/share/java
[root@ip-172-31-13-10 java]# chmod 777 mysql-connector-java-5.1.34.jar
[root@ip-172-31-13-10 java]# ln -s mysql-connector-java-5.1.34.jar mysql-connector-java.jar
[root@ip-172-31-13-10 java]# ll
total 940
-rwxrwxrwx. 1 root root 960372 May 16 15:53 mysql-connector-java-5.1.34.jar
lrwxrwxrwx. 1 root root     31 May 16 15:53 mysql-connector-java.jar -> mysql-connector-java-5.1.34.jar

(可左右滑动)

3.安装Ambari

3.1.配置本地repo源


1.下载Ambari2.7.1的安装包,地址为:

http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.7.1.0/ambari-2.7.1.0-centos7.tar.gz

(可左右滑动)

2.下载HDP3.0.1的安装包,地址为:

http://public-repo-1.hortonworks.com/HDP/centos7/3.x/updates/3.0.1.0/HDP-3.0.1.0-centos7-rpm.tar.gz
http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.22/repos/centos7/HDP-UTILS-1.1.0.22-centos7.tar.gz
http://public-repo-1.hortonworks.com/HDP-GPL/centos7/3.x/updates/3.0.1.0/HDP-GPL-3.0.1.0-centos7-gpl.tar.gz

(可左右滑动)

3.将Ambari和HDP相关的安装包下载到/var/www/html目录,并解压,解压完毕后删除原始gz压缩文件。

4.制作repo文件

[root@ip-172-31-13-10 ~]# vim /etc/yum.repos.d/ambari.repo
[ambarirepo]
name = ambari_repo
baseurl = http://172.31.13.10/ambari/centos7/2.7.1.0-169
enable = true
gpgcheck = false 
[root@ip-172-31-13-10 ~]# vim /etc/yum.repos.d/hdp.repo
[hdprepo]
name = hdp_repo
baseurl = http://172.31.13.10/HDP/centos7/3.0.1.0-187
enable = true
gpgcheck = false
[root@ip-172-31-13-10 ~]# vim /etc/yum.repos.d/hdp_gpl.repo
[hdpgplrepo]
name = hdp_gpl_repo
baseurl = http://172.31.13.10/HDP-GPL/centos7/3.0.1.0-187
enable = true
gpgcheck = false
[root@ip-172-31-13-10 ~]# vim /etc/yum.repos.d/hdp_utls_repo.repo
[hdputilsrepo]
name = hdp_utls_repo
baseurl = http://172.31.13.10/HDP-UTILS/centos7/1.1.0.22
enable = true
gpgcheck = false
[root@ip-172-31-13-10 yum.repos.d]# yum repolist

(可左右滑动)

5.验证安装JDK

下载地址为:

https://archive.cloudera.com/cm6/6.0.0/redhat7/yum/RPMS/x86_64/oracle-j2sdk1.8-1.8.0+update141-1.x86_64.rpm

(可左右滑动)

安装JDK

[root@ip-172-31-13-10 ~]# rpm -ivh oracle-j2sdk1.8-1.8.0+update141-1.x86_64.rpm

(可左右滑动)

在其他节点也安装JDK

3.2.安装Ambari


1.通过yum安装Ambari Server

yum -y install ambari-server

(可左右滑动)

2.建立Ambari与MySQL驱动的连接

[root@ip-172-31-13-10 yum.repos.d]# ambari-server setup --jdbc-db=mysql --jdbc-driver=/usr/share/java/mysql-connector-java.jar

(可左右滑动)

3.3.初始化Ambari Server


主要操作步骤说明:

1.输入y按回车

2.不用自定义ambari server的用户,输入n按回车

3.需要自定义Java目录,选择y,随后选择2,然后输入JDK的路径

4.自定义元数据库的设置,选择MySQL,选择MySQL服务器主机, 端口,数据库,用户名,密码等。

5.输入y按回车。

3.4.初始化Ambari数据库


在Ambari也即是MySQL节点执行以下命令

[root@ip-172-31-13-10 shell]# mysql -uroot -p -Dambari < /var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql
Enter password: 
[root@ip-172-31-13-10 shell]#

(可左右滑动)

检查是否初始化成功

3.5.启动Ambari


1.执行以下启动命令

ambari-server start
netstat -lnpt | grep 8080

(可左右滑动)

2.查看Ambari页面访问成功,http://18.136.106.240:8080/#/login

4.HDP安装


1.admin/admin登录到Ambari,点击“Launch Install Wizard”

2.任意输入一个集群名,点击Next

3.选择HDP版本3.0.1

仓库选择本地模式Use Local Repository

删掉不用的OS,Fayson这里的OS都是Redhat7.4

输入HDP-3.0,HDP-3.0-GPL,HDP-UTILS-1.1.0.22的http地址,点击Next

4.输入4台主机的主机名

选择登录各个节点的私钥文件,点击REGISTER AND CONFIRM

5.开始安装Ambari服务到各个节点

确认主机检查都通过,然后点击NEXT

6.选择要安装的服务,点击NEXT

7.跳出Ranger/ATLAS/警告,点击PROCEED ANYWAY,依旧不安装

8.分配Master角色,点击NEXT

9.分配Slave角色,点击NEXT

10.输入Hive数据库的用户名和密码,包括设置Grafana和Activity Explorer’s Admin的密码,点击NEXT

11.输入Hive元数据相关的信息,点击TEST CONNECTION,测试通过后点击NEXT

12.相关服务的目录,全部默认后点击NEXT

13.服务账号相关,保持默认,点击NEXT

14.所有服务相关配置,保持默认,点击NEXT,注意需要单独点击到Hive的DATABASE页面再次测试一下数据库连接,否则会报警告。

15.点击DEPLOY

16.等待安装完毕,如果集群缺少libtirpc的包,会安装失败,可以参考最后面的“常见问题”,点击NEXT

17.查看Summary,点击COMPLETE

18.安装成功,回到主页。

5.常见问题


1.安装HDP到各个节点是报错缺少libtirpc-devel包

2.下载libtirpc-devel和libtirpc两个包,下载地址:

http://mirror.centos.org/centos/7/os/x86_64/Packages/libtirpc-0.2.4-0.10.el7.x86_64.rpm
http://mirror.centos.org/centos/7/os/x86_64/Packages/libtirpc-devel-0.2.4-0.10.el7.x86_64.rpm

(可左右滑动)

3.执行createrepo

4.创建repo文件并分发到所有节点

[root@ip-172-31-13-10 yum.repos.d]# vim libtirpc.repo
[libtirpcrepo]
name = libtirpc_repo
baseurl = http://172.31.13.10/libtirpc
enable = true
gpgcheck = false

[root@ip-172-31-13-10 yum.repos.d]# yum repolist

[root@ip-172-31-13-10 shell]# sh bk_cp.sh node.list /etc/yum.repos.d/libtirpc.repo /etc/yum.repos.d

(可左右滑动)

5.安装libtirpc

sh ssh_do_all.sh node.list "yum -y install libtirpc"

(可左右滑动)

6.安装libtirpc-devel

[root@ip-172-31-13-10 shell]# sh ssh_do_all.sh node.list "yum -y install libtirpc-devel"

(可左右滑动)

提示:代码块部分可以左右滑动查看噢
为天地立心,为生民立命,为往圣继绝学,为万世开太平。
温馨提示:如果使用电脑查看图片不清晰,可以使用手机打开文章单击文中的图片放大查看高清原图。

推荐关注Hadoop实操,第一时间,分享更多Hadoop干货,欢迎转发和分享。

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!