以下过程在Redhat 7.6 x64上验证通过。
在一台虚拟机上安装单节点(master和agent在同一个节点)。
一、环境准备
1.1 关闭防火墙
- snippet.bash
[root@bogon ~]# systemctl stop firewalld [root@bogon ~]# systemctl disable firewalld [root@bogon ~]# systemctl status firewalld ● firewalld.service - firewalld - dynamic firewall daemon Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled) Active: inactive (dead) Docs: man:firewalld(1)
1.2 关闭SElinux
SELINUX=enforcing改成SELINUX=disabled
- snippet.bash
[root@bogon ~]# vim /etc/sysconfig/selinux #SELINUX=enforcing SELINUX=disabled [root@bogon ~]# sestatus
1.3 修改主机名
- snippet.bash
[root@bogon ~]# hostnamectl set-hostname yz219.seabox.com [root@bogon ~]# hostnamectl Static hostname: yz219.seabox.com …… Operating System: Red Hat Enterprise Linux Server 7.6 (Maipo) CPE OS Name: cpe:/o:redhat:enterprise_linux:7.6:GA:server Kernel: Linux 3.10.0-957.el7.x86_64 Architecture: x86-64 [root@bogon ~]# cat /etc/hostname yz219.seabox.com
1.4 配置hosts文件
Ambari要求hostname使用FQDN(Fully Qualified Domain Name)。
- snippet.bash
[root@bogon ~]# vim /etc/hosts 192.168.0.219 yz219.seabox.com
1.5 互信
- snippet.bash
[root@yz219 ~]# ssh-keygen [root@yz219 ~]# ssh-copy-id yz219.seabox.com
1.6 安装JDK并修改环境变量
方法请参考:Redhat Linux 7安装JDK8
- snippet.bash
[root@yz219 ~]# vim /etc/profile # Java: export JAVA_HOME=/usr/java/jdk1.8.0_271-amd64/ export PATH=$JAVA_HOME/bin:$PATH export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
1.7 NTP服务
NTP用于集群时间同步。
- snippet.bash
[root@yz219 ~]# yum install ntp [root@yz219 ~]# systemctl start ntpd
1.8 关闭transparent_hugepage
- snippet.bash
[root@yz219 ~]# grubby --update-kernel=ALL --args="transparent_hugepage=never" [root@yz219 ~]# cat /sys/kernel/mm/*transparent_hugepage/enabled always madvise [never]
二、安装Ambari
2.1 版本兼容性
以下站点可以查询Ambari兼容性:
2.2 下载Ambari软件包
2.3 本地源
方法请参考:Redhat Linux制作本地源
ambari源配置文件:
- snippet.bash
[root@yz219 repo]# vim /etc/yum.repos.d/ambari.repo #VERSION_NUMBER=2.7.4.0-120 [ambari-2.7.4.0-120] name=ambary Version - ambari-2.7.4.0-120 baseurl=http://yz219.seabox.com/repo/ambari/centos7/ gpgcheck=0 gpgkey=http://yz219.seabox.com/repo/ambari/centos7/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins enabled=1
HDP源配置文件:
- snippet.bash
[root@yz219 repo]# vim /etc/yum.repos.d/HDP.repo [HDP-3.1.4.0-10] name=HDP-3.1.4.0-10 baseurl=http://yz219.seabox.com/repo/HDP/centos7/ gpgcheck=0 gpgkey=http://yz219.seabox.com/repo/HDP/centos7/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins enabled=1 priority=1
HDP-UTILS源配置文件:
- snippet.bash
[root@yz219 repo]# vim /etc/yum.repos.d/HDP-UTILS.repo [HDP-UTILS-1.1.0.22] name=HDP-UTILS-1.1.0.22 baseurl=http://yz219.seabox.com/repo/HDP-UTILS/centos7/ gpgcheck=0 gpgkey=http://yz219.seabox.com/repo/HDP-UTILS/centos7/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins enabled=1 priority=1
HDP-GPL源配置文件:
- snippet.bash
[root@yz219 repo]# vim /etc/yum.repos.d/HDP-GPL.repo [HDP-GPL-3.1.4.0-315] name=HDP-GPL-3.1.4.0-315 baseurl=http://yz219.seabox.com/repo/HDP-GPL/centos7/ gpgcheck=0 gpgkey=http://yz219.seabox.com/repo/HDP-GPL/centos7/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins enabled=1 priority=1
2.4 安装ambari-server
- snippet.bash
[root@yz219 repo]# yum install ambari-server
三、配置Ambari
3.1 配置Ambari
以下按提示配置ambari-server
- snippet.bash
[root@yz219 ~]# ambari-server setup # 1. 检查SELinux状态。 # 如果是enable状态,则在步骤2输入:n,关闭SELinux后重新执行ambari-server setup。 Using python /usr/bin/python Setup ambari-server Checking SELinux... SELinux status is 'disabled' # 2. 提示是否自定义设置。输入:y Customize user account for ambari-server daemon [y/n] (n)? y # 3. ambari账户,默认是root。 Enter user account for ambari-server daemon (root): Adjusting ambari-server permissions and ownership... # 4. 检查防火墙状态 Checking firewall status... # 5. 检查JDK Checking JDK... [1] Oracle JDK 1.8 + Java Cryptography Extension (JCE) Policy Files 8 [2] Custom JDK ============================================================================== # 6. 选择“Custom JDK”,然后按以上JDK实际配置继续ambari配置。 Enter choice (1): 2 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: Property cannot be blank. Path to JAVA_HOME: /usr/java/jdk1.8.0_271-amd64/ Validating JDK on Ambari Server...done. Check JDK version for Ambari Server... JDK version found: 8 Minimum JDK version is 8 for Ambari. Skipping to setup different JDK for Ambari Server. Checking GPL software agreement... GPL License for LZO: https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html # 7. 下载GPL协议,输入:y。 Enable Ambari Server to download and install GPL Licensed LZO packages [y/n] (n)? y Completing setup... Configuring database... # 8. 配置(存储ambari数据的)数据库,输入:y。 Enter advanced database configuration [y/n] (n)? y Configuring database... ============================================================================== Choose one of the following options: [1] - PostgreSQL (Embedded) [2] - Oracle [3] - MySQL / MariaDB [4] - PostgreSQL [5] - Microsoft SQL Server (Tech Preview) [6] - SQL Anywhere [7] - BDB ============================================================================== # 这里根据实际情况配置数据库,这里选择PostgreSQL作为数据库。 Enter choice (1): 4 Hostname (localhost): Port (5432): Database name (ambari): Postgres schema (ambari): Username (ambari): Enter Database Password (bigdata): Configuring ambari database... Configuring remote database connection properties... WARNING: Before starting Ambari Server, you must run the following DDL directly from the database shell to create the schema: /var/lib/ambari-server/resources/Ambari-DDL-Postgres-CREATE.sql # 9. 准备连接数据库创建ambari数据库 Proceed with configuring remote database connection properties [y/n] (y)? y Extracting system views... ambari-admin-2.7.4.0.118.jar .... Ambari repo file doesn t contain latest json url, skipping repoinfos modification Adjusting ambari-server permissions and ownership... # 10. 完成 Ambari Server 'setup' completed successfully.
3.2 创建数据库
先创建数据库及用户:
- snippet.sql
[postgres@yz219 ~]$ psql -d postgres postgres=# CREATE DATABASE ambari; postgres=# CREATE USER ambari WITH PASSWORD 'bigdata'; postgres=# GRANT ALL PRIVILEGES ON DATABASE ambari TO ambari; postgres=# \CONNECT ambari; ambari=# CREATE SCHEMA ambari AUTHORIZATION ambari; ambari=# ALTER SCHEMA ambari OWNER TO ambari; ambari=# ALTER ROLE ambari SET search_path TO 'ambari', 'public';
再执行DDL脚本:
- snippet.sql
[postgres@yz219 ~]$ psql -d ambari -U ambari ambari=> \i /var/lib/ambari-server/resources/Ambari-DDL-Postgres-CREATE.sql
3.3 验证PostgreSQL数据库
本示例以PostgreSQL作为Ambari的后台数据库,在以下初始化Ambari数据库之前,需要先验证使用root用户是否可以远程连接PostgreSQL。
在PostgreSQL服务已经启动的情况下,使用root用户安装以下方法连接PostgreSQL,如果成功,验证通过。
- snippet.bash
[root@yz219 ~]# psql -h yz219.seabox.com -d ambari -U ambari
四、启动Ambari服务
主节点上启动ambari-server服务。
4.1 启动服务
以上步骤没有错误的情况下,现在尝试启动Ambari服务了:
- snippet.bash
[root@yz219 ~]# ambari-server start …… Ambari Server 'start' completed successfully.
Ambari服务启动成功后,使用浏览器测试连接 http://192.168.0.219:8080/。Username和Password都是admin。
4.2 停止服务与查询服务状态
- snippet.bash
[root@yz219 ~]# ambari-server status Using python /usr/bin/python Ambari-server status Ambari Server running Found Ambari Server PID: 37807 at: /var/run/ambari-server/ambari-server.pid [root@yz219 ~]# ambari-server stop
五、Ambari代理服务
5.1 配置从节点代理
在所有从节点上安装ambari-agent(本文示例主从节点在同一个服务器上):
- snippet.bash
[root@yz219 ~]# yum install ambari-agent
修改配置文件ambari-agent.ini:
- snippet.bash
[root@yz219 ~]# vim /etc/ambari-agent/conf/ambari-agent.ini hostname=yz219.seabox.com
5.2 启动从节点Ambari代理服务
- snippet.bash
[root@yz219 ~]# ambari-agent start …… Ambari Agent successfully started
如果启动失败,则根据log排查原因。
六、安装HDP
按照向导指示,一步一步完成HDP安装与配置。以下为步骤摘要。
下图选择“Use Local Respository”,因为将使用本地源。
下图填写需要安装代理服务的所有host。
- Provide your SSH Private Key to automatically register hosts:选择主节点的ssh key文件,这样Ambari会自动在所有从节点安装代理服务。
- Perform manual registion on hosts and do not use SSH:选择此项,则需要手动在从节点安装ambari-agent,本示例使用此选项。
组件选择,可以先选最基本的,例如:HDFS,Zookeeper,Ambari Metrics。等安装成功后再添加。
看到下图,则表示HDP安装成功了。
安装成功后,可以查看Dashboard了:
七、问题与解决方法
7.1 启动顺序
重启系统后,有部分Components(组件)无法启动,此时需要注意Ambari启动顺序:
- 启动PostgreSQL服务
- ambari-server start
- ambari-agent start
可以单独重启 ambari-agent 以尝试解决问题。
7.2 无法连接数据库
在ambari-server start阶段失败,查看日志有以下报错。
- snippet.bash
[root@yz219 ~]# vim /var/log/ambari-server/ambari-server.log 2020-11-03 11:45:23,557 ERROR [main] AmbariServer:1119 - Failed to run the Ambari Server javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.6.2.v20151217-774c696): org.eclipse.persistence.exceptions.DatabaseException Internal Exception: org.postgresql.util.PSQLException: Connection to yz219.seabox.com:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections. Error Code: 0
原因与解决方法:
因为PostgreSQL默认禁止远程连接。需要先设置允许远程连接。解决方法请参考:PostgreSQL允许远程访问设置
7.3 consistency check found warnings
ambari-server启动时warning:
- snippet.bash
[root@yz219 ~]# ambari-server start …… Server started listening on 8080 DB configs consistency check found warnings. See /var/log/ambari-server/ambari-server-check-database.log for more details.
检查日志:
- snippet.bash
[root@yz219 services]# vim /var/log/ambari-server/ambari-server-check-database.log 2020-11-03 08:53:16,523 INFO - Checking for configs that are not mapped to any service 2020-11-03 08:53:16,549 WARN - You have config(s): sc_sdadmin-bbe75542-af33-46f8-9523-e1aeac6b9e2a, …… that is(are) not mapped (in serviceconfigmapping table) to any service! 2020-11-03 08:53:16,549 INFO - Checking for more than 1 configuration of the same type being enabled.
解决方法:
如果是 2.7.x 版本,登录ambari后台数据库:
- snippet.sql
CREATE TEMPORARY TABLE orphaned_configs AS (SELECT config_id,type_name,version_tag FROM clusterconfig WHERE unmapped != 1 AND type_name NOT IN ('cluster-env') AND config_id NOT IN ( SELECT cc.config_id FROM clusterconfig cc, serviceconfig sc, serviceconfigmapping scm WHERE cc.type_name != 'cluster-env' AND cc.config_id = scm.config_id AND scm.service_config_id = sc.service_config_id)); UPDATE clusterconfig SET unmapped = 1 WHERE config_id IN (SELECT config_id FROM orphaned_configs); DROP TABLE orphaned_configs;
如果是 2.6.x 版本,登录ambari后台数据库:
- snippet.sql
SELECT cc.config_id, cc.type_name, cc.version_tag FROM ambari.clusterconfig cc, ambari.clusterconfig ccm WHERE cc.config_id NOT IN (SELECT scm.config_id FROM ambari.serviceconfigmapping scm) AND cc.type_name != 'cluster-env' AND cc.type_name = ccm.type_name AND cc.version_tag = ccm.version_tag; CREATE TEMPORARY TABLE orphaned_configs AS (SELECT cc.config_id FROM ambari.clusterconfig cc WHERE cc.config_id NOT IN (SELECT scm.config_id FROM ambari.serviceconfigmapping scm) AND cc.type_name != 'cluster-env'); DELETE FROM ambari.clusterconfig WHERE config_id IN (SELECT config_id FROM orphaned_configs);
7.4 配置文件及日志
配置文件主要集中在:/etc/ambari-server/conf/
日志文件在:/var/log/ambari-server/ 以及 /var/log/ambari-agent/