1 前言
Apache Ambari是一种基于Web的工具,支持Apache Hadoop集群的供应、管理和监控。ambari项目的出现使得hadoop系列的组件可以在webUI中定制安装,并提供管理功能。
本文转自我个人的公众号:天目星 ,请大家多多关注。
一、使用的软件版本与架构图
linux:CentOS 7.5.1804
ambari:ambari-2.7.3
java:jdk-8u201-linux-x64.rpm
前提:已经配置好hosts文件、ntp服务、并安装相应的依赖包
使用三台主机搭建测试环境,角色如下
角色 | ambari | mysql | other |
node1 | √ | √ | √ |
node2 | × | × | √ |
node3 | × | × | √ |
二、安装
三台主机配置好hosts文件,并配置ssh免密登录
三台主机都需要配置,并拷贝密匙到其他两台主机
$ ssh-keygen
$ ssh-copy-id $hostname
需要安装JDK,本例使用了RPM包安装
$ rpm -ivh jdk-8u201-linux-x64.rpm
$ java -version
java version "1.8.0_201"
Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)
本例使用的数据库是mariadb来存储ambri的数据
$ vim /etc/yum.repos.d/mariadb.repo
#
[mariadb]
name=MariaDB
baseurl=http://yum.mariadb.org/10.2/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
#
在node1中安装
$ yum install MariaDB-server
$ systemctl enable mariadb.service
安装mysql to java连接器
$ yum install mysql-connector-java
新建ambari的账号用于读写数据库
$ mysql -uroot -p
MariaDB [(none)]> CREATE USER 'ambari'@'%' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> GRANT ALL ON *.* TO 'ambari'@'%';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
ambari建议的最大打开文件描述符数为10000或更多
修改打开文件描述符
$ echo "* hard nofile 65535" >>/etc/security/limits.conf
$ echo "* soft nofile 65535" >>/etc/security/limits.conf
重启生效或使用以下命令临时生效
$ ulimit -n 6553
ambari可以使用公共存储库来安装也可以使用本地存储库来安装
PS:对于无法上网的用户,可以提前下载好所有文件并搭建本地库
安装yum套件
$ yum install -y yum-utils
添加ambari的公共库
yum-config-manager --add-repo \
http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.7.3.0/ambari.repo
使用yum源安装ambari
$ yum repolist
$ yum install ambari-server
三、配置
使用ambari设置服务器
$ ambari-server setup
1.如果您尚未暂时禁用SELinux,则可能会收到警告。接受默认值(y)
Using python /usr/bin/python
Setup ambari-server
Checking SELinux...
SELinux status is 'disabled'
Customize user account for ambari-server daemon [y/n] (n)? y
2.默认使用root权限运行ambari-server
Enter user account for ambari-server daemon (root):
3.设置JDK,我们选择本机已经安装好的,选2,并设置jdk路径
Checking JDK...
[1] Oracle JDK 1.8 + Java Cryptography Extension (JCE) Policy Files 8
[2] Custom JDK
==============================================================================
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: /usr/java/latest
4.使用LZO安装的话需要启用GPL授权,默认为不启用
Checking GPL software agreement...
GPL License for LZO: https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html
Enable Ambari Server to download and install GPL Licensed LZO packages [y/n] (n)? n
5.自定义数据库配置,选择y来定制
Completing setup...
Configuring database...
Enter advanced database configuration [y/n] (n)? y
6.我们使用mysql数据库,选择3
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
========================================================
Enter choice (1): 3
Hostname (localhost): c7-hadoop1
Port (3306):
Database name (ambari):
Username (ambari): root
Enter Database Password (bigdata): 输入你设置好的密码
Re-enter password: 验证你输入的密码
Configuring ambari database...
Should ambari use existing default jdbc /usr/share/java/mysql-connector-java.jar [y/n] (y)?
7.注意,弹出以下提示需新建好数据库并导入sql语句,再点击回车
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-MySQL-CREATE.sql
Proceed with configuring remote database connection properties [y/n] (y)?
点击确认前先在数据库中完成以下操作
MariaDB [(none)]> CREATE DATABASE ambari;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> use ambari
Database changed
MariaDB [ambari]> source /var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql
Query OK, 0 rows affected (0.00 sec)
...省略...
Query OK, 56 rows affected (0.01 sec)
8.完成以上配置后安装完毕并显示以下信息
Extracting system views...
.....
Ambari repo file contains latest json url
http://public-repo-1.hortonworks.com/HDP/hdp_urlinfo.json,
updating stacks repoinfos with it...
Adjusting ambari-server permissions and ownership...
Ambari Server 'setup' completed successfully.
篇幅有限,下期将讲解ambari Web UI的使用
未完待续。。。