一、Ambari 介绍
Apache Ambari是一个开源的管理和监控hadoop集群的web工具,hadoop有多个发行版本,Apache社区版本需要手动安装配置和管理,主要用于学习使用,生产环境一般是几十上百台集群,甚至上千台,社区版本效率低下维护也困难,所以我们一般选择其他版本,本文档使用的是HDP,因为Apache Ambari就是基于这个版本,它安装方式有两种,第一种是拉取源码编译安装,第二种是离线安装,本文介绍的是离线安装方式。
二、Ambari 离线安装
1. 下载以下4个包
- ambari-2.7.3.0-centos7.tar.gz.tar
- HDP-3.1.0.0-centos7-rpm.tar.gz
- HDP-GPL-3.1.0.0-centos7-gpl.tar.gz
- HDP-UTILS-1.1.0.22-centos7.tar.gz
第一个ambari下载地址:
https://docs.cloudera.com/HDPDocuments/Ambari-2.7.3.0/bk_ambari-installation/content/ambari_repositories.html
另外3个关于HDP相关下载地址:
https://docs.cloudera.com/HDPDocuments/Ambari-2.7.3.0/bk_ambari-installation/content/hdp_31_repositories.html
2. jdk1.8
我在测试的时候发现jdk13和jdk9都不支持,所以直接选择了官方推荐的jdk1.8
下载地址:
http://public-repo-1.hortonworks.com/ARTIFACTS/jdk-8u112-linux-x64.tar.gzto/var/lib/ambari-server/resources/jdk-8u112-linux-x64.tar.gz
3. 准备3台机器
3.1. hosts配置,3台机器一致
192.168.56.110 node-1
192.168.56.111 node-2
192.168.56.112 node-3
3.2. 修改主机名,分别为node-1,node-2和node-3
vi /etc/hostname
3.3 关闭防火墙
#停止防火墙
systemctl stop firewalld
#关闭开机启动
systemctl disable firewalld
3.4 禁用selinux
vi /etc/selinux/config
SELINUX=disabled
SELINUXTYPE=targeted
4. 设置免密登录
node-1作为主服务器,ambari需要免密登录到其它机器上进行安装组件和启动服务等
4.1. node-1生成公私钥
ssh-keygen -t rsa
4.2. node-1复制公钥到其它机器的authorized_keys(免密使用的授权)
ssh-copy-id -i ~/.ssh/id_rsa.pub root@node-2
ssh-copy-id -i ~/.ssh/id_rsa.pub root@node-3
5. 制作yum本地源
在第一步将相关包下载完成之后用来制作yum本地源,这样就可以通过yum进行安装了,提高了下载速度
5.1 安装nginx提供yum本地源的路径
使用官方yum源安装:
#Nginx 不在默认的 yum 源中,使用官网的 yum 源
rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
yum install -y nginx
也可以使用epel源:
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum install -y nginx
然后
#启动nginx
systemctl start nginx
#开机启动
systemctl enable nginx
nginx安装后默认访问目录在/usr/share/nginx/html,在这个目录建立yum目录,并且将第一步下载的包解压到yum目录中,/usr/share/nginx/html看起来应该像下面这样:
接下来设置源,在解压的包中含有yum源的配置文件,将baseurl和gpgkey改为自己nginx访问的地址,然后复制到/etc/yum.repos.d 目录中。
5.1.1 修改ambari
vi /usr/share/nginx/html/yum/ambari/centos7/2.7.3.0-139/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.3.0
#baseurl=http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.7.3.0
baseurl=http://192.168.56.110/yum/ambari/centos7/2.7.3.0-139
gpgcheck=1
gpgkey=http://192.168.56.110/yum/ambari/centos7/2.7.3.0-139/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins
enabled=1
priority=1
cp /usr/share/nginx/html/yum/ambari/centos7/2.7.3.0-139/ambari.repo /etc/yum.repos.d
5.1.2 修改HDP
vi /usr/share/nginx/html/yum/HDP/centos7/3.1.0.0-78/hdp.repo
#VERSION_NUMBER=3.1.0.0-78
[HDP-3.1.0.0]
name=HDP Version - HDP-3.1.0.0
#baseurl=http://public-repo-1.hortonworks.com/HDP/centos7/3.x/updates/3.1.0.0
baseurl=http://192.168.56.110/yum/HDP/centos7/3.1.0.0-78
gpgcheck=1
gpgkey=http://192.168.56.110/yum/HDP/centos7/3.1.0.0-78/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.56.110/yum/HDP-UTILS/centos7/1.1.0.22
gpgcheck=1
gpgkey=http://192.168.56.110/yum/HDP-UTILS/centos7/1.1.0.22/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins
enabled=1
priority=1
cp /usr/share/nginx/html/yum/HDP/centos7/3.1.0.0-78/hdp.repo /etc/yum.repos.d
5.1.3 修改HDP-GPL
vi /usr/share/nginx/html/yum/HDP-GPL/centos7/3.1.0.0-78/hdp.gpl.repo
#VERSION_NUMBER=3.1.0.0-78
[HDP-GPL-3.1.0.0]
name=HDP-GPL Version - HDP-GPL-3.1.0.0
baseurl=http://192.168.56.110/yum/HDP-GPL/centos7/3.1.0.0-78
gpgcheck=1
gpgkey=http://192.168.56.110/yum/HDP-GPL/centos7/3.1.0.0-78/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins
enabled=1
priority=1
~
cp /usr/share/nginx/html/yum/HDP-GPL/centos7/3.1.0.0-78/hdp.gpl.repo /etc/yum.repos.d
6. 安装mysql5.7
因为ambari会将安装的组件和配置信息存到数据库中,所以安装时会要求你填入数据库的连接地址并设置驱动路径,下面是安装mysql的步骤
#下载mysql源安装包
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
#安装mysql源
rpm -ivh mysql57-community-release-el7-10.noarch.rpm
#yum 安装mysql
yum -y install mysql-community-server
#启动服务
systemctl start mysqld
#查看root默认密码(启动后才能看到密码)
grep 'A temporary password' /var/log/mysqld.log
#登录
mysql -uroot -p
#首次进入后mysql要求必须修改密码才能做其他操作,因安全策略很高要包含大小字母、数字和字符
ALTER USER USER() IDENTIFIED BY 'Jxxxxx12!';
#现在修改安全策略
set global validate_password_policy=0;
set global validate_password_length=1;
#然后就可以把密码修改为简单密码
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY '123456' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
mysql驱动下载,安装ambari的时候会让你填驱动路径
https://jhxz-oss.oss-cn-chengdu.aliyuncs.com/download/mysql-connector-java-8.0.16.jar
7. 安装ambari
#安装
yum install -y ambari-server
#开始配置
ambari-server setup
#上面命令执行后会打印下面相关信息,并做一些交互设置
Using python /usr/bin/python
Setup ambari-server
Checking SELinux...
SELinux status is 'disabled'
Customize user account for ambari-server daemon [y/n] (n)? #问是否自定义登录账户名称,不需要,直接回车即可
Do you want to change Oracle JDK [y/n] (n)? y #问是否改变JDK,选y
[1] Oracle JDK 1.8 + Java Cryptography Extension (JCE) Policy Files 8
[2] Custom JDK
==============================================================================
Enter choice (1): #这里选择2,自定义JDK
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: #这里填入JDK路径
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
Enable Ambari Server to download and install GPL Licensed LZO packages [y/n] (n)? #直接回车
Completing setup...
Configuring database...
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
==============================================================================
Enter choice (3): #这里选择3,使用mysql
Enter choice (3): 3
Hostname (localhost):
Port (3306):
Database name (ambari):
Username (root):
Enter Database Password (xxx):#输入密码
Configuring ambari database...
Enter full path to custom jdbc driver: #设置mysql驱动路径
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)?#需要将上面的SQL脚本放到数据库执行,执行完了选y
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-server start
然后可以通过http://192.168.56.110:8080 进行访问了,默认账号密码admin/admin
node:
通过web界面安装的hadoop配置文件在这个路径中 /usr/hdp/3.1.0.0-78/hadoop/conf,主节点在/etc/hadoop/conf