Centos7部署 Ambari2.7.5+HDP3.1.5集群

一、环境准备

安装包准备

  官网连接不能,需要收费,用到的软件包全部整理在这里,下载连接:https://www.aliyundrive.com/s/oCPRph5LnXm,需要注册的点击这个连接:https://pages.aliyundrive.com/mobile-page/web/beinvited.html?code=e01ec49

备用连接:链接:https://pan.baidu.com/s/1NlCsNUsgqB51kns5JjwSLA  提取码:1315

1、虚拟机:

192.168.112.126 hdp01.bbdops.com
192.168.112.127 hdp02.bbdops.com
192.168.112.128 hdp03.bbdops.com
192.168.112.129 hdp04.bbdops.com
192.168.112.130 hdp05.bbdops.com

2、安装包准备

ambari-2.7.5.0-centos7.tar.gz
HDP-3.1.5.0-centos7-rpm.tar.gz
HDP-GPL-3.1.5.0-centos7-gpl.tar.gz
HDP-UTILS-1.1.0.22-centos7.tar.gz
jdk-8u211-linux-x64.tar.gz
mysql-5.7.32-1.el7.x86_64.rpm-bundle.zip

二、安装相关工具

1、安装jdk(所有主机)

1)卸载本机原有jdk

rpm -qa|grep java                                                                   查看版本
rpm -e --nodeps java-1.8.0-openjdk-headless-1.8.0.161-0.b14.el7_4.x86_64            下载旧版jdk
rpm -e --nodeps java-1.8.0-openjdk-1.8.0.161-0.b14.el7_4.x86_64

2)、上传jdk

版本:jdk-8u211-linux-x64.tar.gz

scp jdk-8u211-linux-x64.tar.gz root@192.168.112.126:/usr/local/
scp jdk-8u211-linux-x64.tar.gz root@192.168.112.127:/usr/local/
解压后路径:/usr/local/jdk-8u211

3)、配置JDk
每个节点都需要配置,且配置JDK的内容相同,末尾加入下配置:

vim /etc/profile
export JAVA_HOME=/usr/local/jdk1.8.0_211
export CLASSPATH=$:CLASSPATH:$JAVA_HOME/lib/
export PATH=$PATH:$JAVA_HOME/bin

(5)jdk生效

source /etc/profile

2、关闭THP

首先检查THP的启用状态

[root@hdp01.bbdops.com~]# cat /sys/kernel/mm/transparent_hugepage/defrag
[always] madvise never
[root@hdp01.bbdops.com ~]# cat /sys/kernel/mm/transparent_hugepage/enabled
[always] madvise never

关闭编辑rc.local文件:

[root@hdp01.bbdops.com ~]# vim /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

保存退出,然后赋予rc.local文件执行权限:

[root@hdp01.bbdops.com~]# chmod +x /etc/rc.d/rc.local 
reboot                                                         重启生效
最后重启系统,以后再检查THP应该就是被禁用了
[root@hdp01.bbdops.com~]# cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]
[root@hdp01.bbdops.com ~]# cat /sys/kernel/mm/transparent_hugepage/defrag 
always madvise [never]

3、设置主机名(所有主机)

hostnamectl set-hostname hdp01.bbdops.com           修改节点一主机名
hostnamectl set-hostname hdp02.bbdops.com           修改节点二主机名
hostnamectl set-hostname hdp03.bbdops.com           修改节点三主机名
su                                              生效

4、修改hosts文件(所有主机)

vim /etc/hosts
每个节点的hosts文件中添加如下配置:
192.168.112.126         hdp01.bbdops.com 
192.168.112.127         hdp02.bbdops.com 
192.168.112.128         hdp03.bbdops.com
192.168.112.129         hdp04.bbdops.com 
192.168.112.130         hdp05.bbdops.com

5、修改network(所有主机)

vim /etc/sysconfig/network
添加如下配置:
# Created by anaconda
NETWORKING=yes
HOSTNAME=hdp01.bbdops.com

6、打开安全限制 (所有主机)

vim /etc/security/limits.conf
文件末尾新增如下:
# End of file
* soft nofile 65536
* hard nofile 65536
* soft nproc 131072
* hard nproc 13107

7、关闭防火墙 (所有主机)

[root@hdp01.bbdops.com~]#systemctl disable firewalld
[root@hdp01.bbdops.com~]#systemctl stop firewalld
另外所有机器还需修改
setenforce 0 临时关闭
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config 永久关闭

8、同步时钟(所有主机)

1)、安装chrony服务

yum -y install chrony

2)、设置hdp01.bbdops.com为主服务器,开启nptd服务(主服务器)

主服务器上该配置文件修改项如下:

[root@hdp01.bbdops.com ~]#vim /etc/chrony.conf
server ntp6.aliyun.com iburst
allow 192.168.112.0/24 
local stratum 10

修改保存后执行:

[root@hdp01.bbdops.com ~]# systemctl restart chronyd.service #启动服务
[root@hdp01.bbdops.com ~]# systemctl enable chronyd.service #开机自启动

查看时间同步状态:

chronyc -a makestep
chronyc sourcestats
chronyc sources -v

3)、子节点时间同步配置

vim /etc/chrony.conf
注释原来的server并新增如下配置即可然后重启服务:
server 192.168.112.126 iburst

4)、重启服务

[root@hdp02.bbdops.com ~]# systemctl restart chronyd.service #启动服务
[root@hdp02.bbdops.com ~]# systemctl status chronyd.service #开机自启动

9、配置SSH免密钥登录(主节点)

1)、免密钥操作

[root@hdp01.bbdops.com ~]# ssh-keygen -t rsa 连接提示选yes ,密码提示填登录密码
[root@hdp01.bbdops.com ~]# ssh-copy-id hdp02.bbdops.com
[root@hdp01.bbdops.com ~]# ssh-copy-id hdp03.bbdops.com
[root@hdp01.bbdops.com ~]# ssh-copy-id hdp01.bbdops.com
测试是否实现了无密码登录:
[root@hdp01.bbdops.com ~]# ssh hdp01.bbdops.com date ;ssh hdp02.bbdops.com date;ssh hdp03.bbdops.com date;ssh hdp04.bbdops.com date;ssh hdp05.bbdops.com date;
2020年 11月 10日 星期二 15:00:50 CST 2020年 11月 10日 星期二 15:00:51 CST 2020年 11月 10日 星期二 15:00:51 CST

2)、保存密钥
将创建的秘钥拷贝出来,因为后面ambari安装的时候需要上传这个秘钥。创建秘钥是在隐藏文件夹/root/.ssh/下面的,所以需要先把秘钥拷贝到可见区域,然后拷贝到电脑上。

[root@hdp01.bbdops.com ~]# cd /root/.ssh/
[root@hdp01.bbdops.com .ssh]# ls
authorized_keys id_rsa id_rsa.pub known_hosts
[root@hdp01.bbdops.com .ssh]# cp id_rsa /root/
[root@hdp01.bbdops.com .ssh]# ls /root/
anaconda-ks.cfg id_rsa jdk-8u161-linux-x64.rpm

10、为每个用户设置NMASK(所有主机)

root@hdp01.bbdops.com ~]# sudo sh -c "echo umask 0022 >> /etc/profile"

  11、修改系统最大打开文件数

[root@hdp01.bbdops.com ~]# vim /etc/systemd/system.conf
[Manager]
DefaultLimitNOFILE=1024000          #这里需要修改 
DefaultLimitNPROC=1024000           #这里也需要修改,修改完成重启生效
[root@hdp01.bbdops.com ~]# ulimit -a          查看
[root@hdp01.bbdops.com ~]# ulimit -n 10000    临时修改
[root@hdp01.bbdops.com ~]# ulimit -Sn         
10000
[root@hdp01.bbdops.com ~]# ulimit -Hn
10000

三、开始安装基础服务

1、安装httpd服务 (主服务器)

[root@hdp01.bbdops.com ~]# yum -y install httpd
[root@hdp01.bbdops.com ~]# systemctl restart httpd
[root@hdp01.bbdops.com ~]# systemctl enable httpd

2、上传三个包放到/var/www/html目录下 (主服务器)

安装完成后,会生成 /var/www/html目录(相当于Tomcat的webapps目录),进入到/var/www/html目录下,创建ambari和hdp目录,用来存放安装文件.

[root@yum ~]# mkdir /var/www/html/ambari
[root@yum ~]# mkdir /var/www/html/hdp
[root@yum ~]# mkdir /var/www/html/hdp/HDP-UTILS-1.1.0.22
[root@yum ~]# mkdir /var/www/html/hdp/HDP-GPL-3.1.5.0 
[root@yum ~]# tar -zxvf ambari-2.7.3.0-centos7.tar.gz -C /var/www/html/ambari/ 
[root@yum ~]# tar -zxvf HDP-3.1.0.0-centos7-rpm.tar.gz -C /var/www/html/hdp/ 
[root@yum ~]# tar -zxvf HDP-UTILS-1.1.0.22-centos7.tar.gz -C /var/www/html/hdp/HDP-UTILS-1.1.0.22
[root@yum ~]# tar -zxvf HDP-GPL-3.1.5.0-centos7-gpl.tar.gz -C /var/www/html/hdp/HDP-GPL-3.1.5.0/

3、启动httpd服务(主服务器)

[root@yum ~]# systemctl start httpd    # 启动httpd
[root@yum ~]# systemctl status httpd    # 查看httpd状态
[root@yum ~]# systemctl enable httpd    # 设置httpd开机自启

测试访问:

http://192.168.112.126/ambari/ 
http://192.168.112.126/hdp/

4、制作本地源(主服务器)

1)、下载ambari.repo文件

[root@hdp01.bbdops.com ambari]# wget -O /etc/yum.repos.d/ambari.repo http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.7.3.0/ambari.repo

2)、修改配置文件

vim /etc/yum.repos.d/ambari.repo

#VERSION_NUMBER=2.7.3.0-139
[ambari-2.7.3.0]
#json.url = http://public-repo-1.hortonworks.com/HDP/hdp_urlinfo.json
name=ambari Version - ambari-2.7.5.0
baseurl=http://192.168.112.126/ambari/ambari/centos7/2.7.5.0-72/
gpgcheck=1
gpgkey=http://192.168.112.126/ambari/ambari/centos7/2.7.5.0-72/RPM-GPG-KEY//RPM-GPG-KEY-Jenkins
enabled=1
priority=1

3)、配置HDP和HDP-TILS

vim /etc/yum.repos.d/HDP.repo

#VERSION_NUMBER=3.1.0.0-78
[HDP-3.1.0.0]
name=HDP Version - HDP-3.1.5.0
baseurl=http://192.168.112.126/hdp/HDP/centos7/3.1.5.0-152/
gpgcheck=1
gpgkey=http://192.168.112.126/hdp/HDP/centos7/3.1.5.0-152/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins
enabled=1
priority=1

[HDP-UTILS-1.1.0.22]
name=HDP-UTILS Version - HDP-UTILS-1.1.0.22
baseurl=http://192.168.112.126/hdp/HDP-UTILS-1.1.0.22/HDP-UTILS/centos7/1.1.0.22/
gpgcheck=1
gpgkey=http://192.168.112.126/hdp/HDP-UTILS-1.1.0.22/HDP-UTILS/centos7/1.1.0.22/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins
enabled=1
priority=1

[HDP-GPL-3.1.5.0]
name=HDP-GPL Version - HDP-GPL-3.1.5.0
baseurl=http://192.168.112.126/hdp/HDP-GPL-3.1.5.0/HDP-GPL/centos7/3.1.5.0-152/
gpgcheck=1
gpgkey=http://192.168.112.126/hdp/HDP-GPL-3.1.5.0/HDP-GPL/centos7/3.1.5.0-152/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins
enabled=1
priority=1

5、清理一下yum的缓存

[root@hdp01.bbdops.com ambari]# yum clean all
[root@hdp01.bbdops.com ambari]# yum makecache
[root@hdp01.bbdops.com ambari]# yum repolist

6、将创建好的文件拷贝到子节点

[root@hdp01.bbdops.com ambari]#cd /etc/yum.repos.d
[root@hdp01.bbdops.com yum.repos.d]# scp ambari.repo HDP.repo hdp02.bbdops.com:$PWD
[root@hdp01.bbdops.com yum.repos.d]# scp ambari.repo HDP.repo hdp03.bbdops.com:$PWD

四、安装ambari-server

  1、安装数据库mysql(主服务器)

mysql包版本:mysql-5.7.27-1.el7.x86_64.rpm-bundle.tar

上传到主节点/usr/local/mysql目录下并解压。

rpm -qa |grep -i mysql
rpm -qa |grep -i mariadb
用rpm -e 删除包
强制卸载mariadb
rpm -e --nodeps mariadb-libs-5.5.44-2.el7.centos.x86_64
这里是为了避免安装mysql时出现依赖错误,提前删除系统已有的mariadb和mysql包!
安装mysql可能用到的工具:
yum -y install libaio
yum -y install net-tools

2、安装mysql-server:按照common–>libs–>client–>server的顺序。若不按照此顺序,也会有一定“依赖”关系的提醒。

rpm -ivh mysql-community-common-5.7.27-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.27-1.el7.x86_64.rpm 
rpm -ivh mysql-community-client-5.7.27-1.el7.x86_64.rpm 
rpm -ivh mysql-community-server-5.7.27-1.el7.x86_64.rpm

3、初始化mysql

[root@hadoop mysql]# mysqld --initialize

4、更改mysql数据库所属于用户及其所属于组

[root@hadoop mysql]# chown mysql:mysql /var/lib/mysql -R

5、启动mysql数据库

[root@hadoop mysql]# cd /var/lib/mysql
[root@hadoop mysql]# systemctl start mysqld.service
[root@hadoop ~]# cd /var/log/
[root@hadoop log]# grep 'password' mysqld.log 
2019-02-26T04:33:06.989818Z 1 [Note] A temporary password is generated for root@localhost: mxeV&htW-3VC,

更改root用户密码,新版的mysql在第一次登录后更改密码前是不能执行任何命令的

[root@hadoop log]# mysql -u root -p

更改密码
mysql> set password=password('123456');
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> grant all privileges on *.* to root@'%' identified by '123456' with grant option;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

6、安装和配置ambari-server

yum -y install ambari-server

7、mysql与ambari-server的连接

mkdir /usr/share/java
cp mysql-connector-java-5.1.40-bin.jar /usr/share/java/mysql-connector-java.jar
cp mysql-connector-java-5.1.40-bin.jar /var/lib/ambari-server/resources/mysql-jdbc-driver.jar
vi /etc/ambari-server/conf/ambari.properties

添加server.jdbc.driver.path=/usr/share/java/mysql-connector-java.jar

8、初始化ambari-server

[root@hdp01.bbdops.com ~]# ambari-server setup
1) 提示是否自定义设置。输入:y
Customize user account for ambari-server daemon [y/n] (n)? y
(2)ambari-server 账号。
Enter user account for ambari-server daemon (root):
如果直接回车就是默认选择root用户
如果输入已经创建的用户就会显示:
Enter user account for ambari-server daemon (root):ambari
Adjusting ambari-server permissions and ownership...
(3)检查防火墙是否关闭
Adjusting ambari-server permissions and ownership...
Checking firewall...
WARNING: iptables is running. Confirm the necessary Ambari ports are accessible. Refer to the Ambari documentation for more details on ports.
OK to continue [y/n] (y)?
直接回车
(4)设置JDK。输入:3
Checking JDK...
Do you want to change Oracle JDK [y/n] (n)? y
[1] Oracle JDK 1.8 + Java Cryptography Extension (JCE) Policy Files 8
[2] Oracle JDK 1.7 + Java Cryptography Extension (JCE) Policy Files 7
[3] Custom JDK
==============================================================================
Enter choice (1): 3
如果上面选择3自定义JDK,则需要设置JAVA_HOME。输入:/usr/java/jdk1.8.0_161
WARNING: JDK must be installed on all hosts and JAVA_HOME must be valid on all hosts.
WARNING: JCE Policy files are required for configuring Kerberos security. If you plan to use Kerberos,please make sure JCE Unlimited Strength Jurisdiction Policy Files are valid on all hosts.
Path to JAVA_HOME: /usr/java/jdk1.8.0_131
Validating JDK on Ambari Server...done.
Completing setup...
(5)数据库配置。选择:y
Configuring database...
Enter advanced database configuration [y/n] (n)? y
(6)选择数据库类型。输入:3
Configuring database...
==============================================================================
Choose one of the following options:
[1] - PostgreSQL (Embedded)
[2] - Oracle
[3] - MySQL
[4] - PostgreSQL
[5] - Microsoft SQL Server (Tech Preview)
[6] - SQL Anywhere
==============================================================================
Enter choice (3): 3
(7)设置数据库的具体配置信息,根据实际情况输入,如果和括号内相同,则可以直接回车。如果想重命名,就输入。
Hostname (localhost): hdp01.bbdops.com
Port (3306): 3306
Database name (ambari): ambari
Username (ambari): ambari
Enter Database Password (bigdata):ambari123
Re-Enter password: ambari123
(8)将Ambari数据库脚本导入到数据库
WARNING: Before starting Ambari Server, you must run the following DDL against the database to create the schema: /var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql 这个sql后面会用到,导入数据库
Proceed with configuring remote database connection properties [y/n] (y)? y

错误处理:
如果出现错误,请注意查看日志,根据具体的错误内容进行处理,默认ambari-server的日志在/var/log/ambari-server/ambari-server.log里面。如果在处理日志的过程中或者后面安装的过程中出现一些莫名的错误,可以重置的安装。
如果上面进行的默认数据库的配置,可以使用下面的代码重置ambari-server。

  9、登录mysql创建ambari安装所需要的库

设置的账号后面配置ambari-server的时候会用到!

CREATE DATABASE ambari; 
use ambari; 
CREATE USER 'ambari'@'%' IDENTIFIED BY 'ambari123'; 
GRANT ALL PRIVILEGES ON *.* TO 'ambari'@'%'; 
CREATE USER 'ambari'@'localhost' IDENTIFIED BY 'ambari123'; 
GRANT ALL PRIVILEGES ON *.* TO 'ambari'@'localhost'; 
CREATE USER 'ambari'@'hdp01.bbdops.com' IDENTIFIED BY 'ambari123'; 
GRANT ALL PRIVILEGES ON *.* TO 'ambari'@'hdp01.bbdops.com'; 

source /var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql 
show tables; 
use mysql; 
select host,user from user where user='ambari'; 
CREATE DATABASE hive; 
use hive; 
CREATE USER 'hive'@'%' IDENTIFIED BY 'hive'; 
GRANT ALL PRIVILEGES ON *.* TO 'hive'@'%'; 
CREATE USER 'hive'@'localhost' IDENTIFIED BY 'hive'; 
GRANT ALL PRIVILEGES ON *.* TO 'hive'@'localhost'; 
CREATE USER 'hive'@'hdp01.bbdops.com' IDENTIFIED BY 'hive'; 
GRANT ALL PRIVILEGES ON *.* TO 'hive'@'hdp01.bbdops.com'; 

CREATE DATABASE oozie; 
use oozie; 
CREATE USER 'oozie'@'%' IDENTIFIED BY 'oozie'; 
GRANT ALL PRIVILEGES ON *.* TO 'oozie'@'%'; 
CREATE USER 'oozie'@'localhost' IDENTIFIED BY 'oozie'; 
GRANT ALL PRIVILEGES ON *.* TO 'oozie'@'localhost'; 
CREATE USER 'oozie'@'hdp01.bbdops.com' IDENTIFIED BY 'oozie'; 
GRANT ALL PRIVILEGES ON *.* TO 'oozie'@'hdp01.bbdops.com'; 
FLUSH PRIVILEGES;

10、启动ambari服务

[root@hdp01.bbdops.com ~]# ambari-server stop
[root@hdp01.bbdops.com ~]# ambari-server reset
[root@hdp01.bbdops.com ~]# ambari-server setup
[root@hdp01.bbdops.com ~]# ambari-server start                        启动服务
Using python /usr/bin/python
Starting ambari-server
Ambari Server running with administrator privileges.
Organizing resource files at /var/lib/ambari-server/resources...
Ambari database consistency check started...
Server PID at: /var/run/ambari-server/ambari-server.pid
Server out at: /var/log/ambari-server/ambari-server.out
Server log at: /var/log/ambari-server/ambari-server.log
Waiting for server start..................................
Server started listening on 8080

DB configs consistency check: no errors and warnings were found.
Ambari Server 'start' completed successfully.

11、所有节点安装ambari-agent

yum install ambari-agent
systemctl start ambari-agent

五、部署集群

1、登录界面:http://192.168.112.126:8080

Centos7部署-Ambari2.7.5HDP3.1.5集群1

默认管理员账户登录, 账户:admin 密码:admin

2、选择版本,配置yum源

1)选择Launch Install Wizard

2)配置集群名称

3)选择版本并修改本地源地址

选HDP-3.1(Default Version Definition);
选Use Local Repository;
选redhat7:

HDP-3.1: http://192.168.112.126/hdp/HDP/centos7/3.1.0.0-78/
HDP-3.1-GPL: http://192.168.112.126/HDP-GPL/centos7/3.x/updates/3.1.0.0/
HDP-UTILS-1.1.0.22: http://192.168.112.126/hdp/HDP-UTILS-1.1.0.22/HDP-UTILS/centos7/1.1.0.22/

Centos7部署-Ambari2.7.5HDP3.1.5集群2

3、配置节点和密钥

Centos7部署-Ambari2.7.5HDP3.1.5集群3

从主节点的/root目录下下载密钥id_rsa,并上传即可!点击下一步,进入确认主机界面

4、开始检查准备

Centos7部署-Ambari2.7.5HDP3.1.5集群4

5、勾选需要安装的服,后期需要可以再装

6、分配服务,保持默认

7、选择节点安装的服务

8、设置相关服务的密码

9、连接数据库

Centos7部署-Ambari2.7.5HDP3.1.5集群9

执行以下语句,再去测试连接

[root@hdp01.bbdops.com ~]# ambari-server setup --jdbc-db=mysql --jdbc-driver=/usr/share/java/mysql-connector-java.jar 
Using python  /usr/bin/python
Setup ambari-server
Copying /usr/share/java/mysql-connector-java.jar to /var/lib/ambari-server/resources/mysql-connector-java.jar
If you are updating existing jdbc driver jar for mysql with mysql-connector-java.jar. Please remove the old driver jar, from all hosts. Restarting services that need the driver, will automatically 
copy the new jar to the hosts.
JDBC driver was successfully initialized.
Ambari Server 'setup' completed successfully.
Centos7部署-Ambari2.7.5HDP3.1.5集群10

测试通过,我们点击下一步

10、查看配置文件,要是服务有问题,会在这里报异常,解决了才能往下

Centos7部署-Ambari2.7.5HDP3.1.5集群11

下一步,查看你的配置,告诉你系统会默认创建的用户

Centos7部署-Ambari2.7.5HDP3.1.5集群12

11、点击继续

Centos7部署-Ambari2.7.5HDP3.1.5集群13

12、验证你的配置文件,点击下方部署按钮开始部署

正在部署,此过程比较漫长,慢慢等待!

1 comment

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注