转载请务必注明原创地址为:http://dongkelun.com/2018/04/25/ambariConf/html
本文是讲如何在centos7(64位) 安装ambari+hdp,若是在装有原生hadoop等集群的机器上安装,须要先将集群服务停掉,而后将不须要的环境变量注释掉便可,若是不注释掉,后面虽然能够安装成功,可是在启动某些服务的时候可能会有异常,好比最后提到的hive启动异常。本文适合系统: RedHat七、CentOS七、Oracle Linux7(都是64位)java
注意:centos7中文系统有bug(python脚本中文识别问题),须要使用英文系统。python
本文仅做参考(基本每一个配置博客都有局限性和坑~),推荐先参考官方文档:mysql
如下均在root用户下执行。linux
建议您将浏览器(本身使用的windows既可)更新至最新的稳定版本ajax
1.2.1 yum和rpm 1.2.2 scp, curl, unzip, tar、 wget 1.2.3 OpenSSL(v1.01,build 16或更高版本) 1.2.4 python:2.7(注意若是有使用python3.x的需求,不要改变python环境变量,不然3.x会报错) 1.2.5 jdk:1.8 1.2.6 mysql:5.6(官网上写的5.6,不肯定更高版本有没有问题,也可使用其余数据库,根据本身习惯) 1.2.7 内存要求:Ambari主机应该至少有1 GB RAM,500 MB空闲,(但若是使用的话,建议内存8g以上,我本身的虚拟机内存4g搭好后跑起来会很卡,配置低的话警告也会不少) 1.2.8 检查最大打开文件描述符,推荐的最大打开文件描述符数为10000或更多 1.2.9 mysql-connector-java
以上软件大部分系统自带,其他可参考:CentOS 初始环境配置sql
只需master 免密到其余节点(包含自身),不须要互通,参考:linux ssh 免密登陆shell
yum install -y ntp systemctl enable ntpd
vim /etc/hosts
本文只是在我的虚拟机上进行安装测试,因此只选择两个节点,在公司真实环境下多个节点安装是同样的,ambari对内存要求较高,若是我的电脑配置不高的话,建议学习一下便可。数据库
192.168.44.138 ambari.master.com 192.168.44.139 ambari.slave1.com
其中后面的如ambari.master.com为彻底限定域名(FQDN)(经过符号“.”),不能简单的设为master等,若是该文件里有其余映射,如上面的配置必需要在最前面(自带的localhost下面一行),不然后面安装会报错。
以ambari.master.com为例
2.4.1
hostname ambari.master.com
2.4.2
vim /etc/hostname
ambari.master.com
两步缺一不可,经过命令验证
hostname hostname -f
两个必须都为ambari.master.com才行
vim /etc/sysconfig/network
修改HOSTNAME属性为FQDN
NETWORKING=yes HOSTNAME=ambari.master.com
systemctl disable firewalld service firewalld stop
2.7.1 临时禁用
setenforce 0
2.7.2 永久禁用(重启机器)
vim /etc/sysconfig/selinux
将SELINUX改成disabled
SELINUX=disabled
这样服务器或虚拟机重启也没有问题。
由于ambari 和 hdp 安装文件比较大,若是在线安装的话会很慢,因此最好选择本地源。
(能够在集群能够访问的任何机器上制做本地源)
yum install yum-utils createrepo
yum install httpd -y systemctl enable httpd && systemctl start httpd
mkdir -p /var/www/html/hdp/HDP-UTILS
其中包括Ambari、HDP、HDP-UTILS,因为HDP-GPL较小只有几百k,因此没有配置为本地源。
wget http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.6.1.5/ambari-2.6.1.5-centos7.tar.gz wget http://public-repo-1.hortonworks.com/HDP/centos7/2.x/updates/2.6.4.0/HDP-2.6.4.0-centos7-rpm.tar.gz wget http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.22/repos/centos7/HDP-UTILS-1.1.0.22-centos7.tar.gz
tar -zxvf ambari-2.6.1.5-centos7.tar.gz -C /var/www/html tar -zxvf HDP-2.6.4.0-centos7-rpm.tar.gz -C /var/www/html/hdp/ tar -zxvf HDP-UTILS-1.1.0.22-centos7.tar.gz -C /var/www/html/hdp/HDP-UTILS/
缘由:该目录下index.xml使用了 https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js 国内访问不了谷歌,将index.xml注释掉便可
cd /var/www/html/hdp/HDP/centos7/2.6.4.0-91 mv index.xml index.xml.bak
此时应该能够在浏览器访问下面的地址了,能够验证一下
http://ambari.master.com/ambari/centos7/2.6.1.5-3/ http://ambari.master.com/hdp/HDP/centos7/2.6.4.0-91 http://ambari.master.com/hdp/HDP-UTILS
cp /var/www/html/ambari/centos7/2.6.1.5-3/ambari.repo /etc/yum.repos.d/ cp /var/www/html/hdp/HDP/centos7/2.6.4.0-91/hdp.repo /etc/yum.repos.d/
将每一个repo里的baseurl和gpgkey的地址修改成本地的
vim /etc/yum.repos.d/ambari.repo
#VERSION_NUMBER=2.6.1.5-3 [ambari-2.6.1.5] name=ambari Version - ambari-2.6.1.5 baseurl=http://ambari.master.com/ambari/centos7/2.6.1.5-3 gpgcheck=1 gpgkey=http://ambari.master.com/ambari/centos7/2.6.1.5-3/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins enabled=1 priority=1
vim /etc/yum.repos.d/hdp.repo
#VERSION_NUMBER=2.6.4.0-91 [HDP-2.6.4.0] name=HDP Version - HDP-2.6.4.0 baseurl=http://ambari.master.com/hdp/HDP/centos7/2.6.4.0-91 gpgcheck=1 gpgkey=http://ambari.master.com/hdp/HDP/centos7/2.6.4.0-91/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://ambari.master.com/hdp/HDP-UTILS gpgcheck=1 gpgkey=http://ambari.master.com/hdp/HDP/centos7/2.6.4.0-91/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins enabled=1 priority=1
yum clean all yum list update yum makecache yum repolist
yum install yum-plugin-priorities -y vim /etc/yum/pluginconf.d/priorities.conf
[main] enabled = 1 gpgcheck=0
yum install ambari-server -y
ambari-server setup --jdbc-db=mysql --jdbc-driver=/usr/share/java/mysql-connector-java.jar
(若是使用mysql做为hive的元数据库)
建立ambari数据库及用户,登陆root用户执行下面语句:
mysql -uroot -pRoot-123
create database ambari character set utf8 ; CREATE USER 'ambari'@'%'IDENTIFIED BY 'Ambari-123'; GRANT ALL PRIVILEGES ON *.* TO 'ambari'@'%'; FLUSH PRIVILEGES;
若是要安装Hive,再建立Hive数据库和用户,再执行下面的语句:
create database hive character set utf8 ; CREATE USER 'hive'@'%'IDENTIFIED BY 'Hive-123'; GRANT ALL PRIVILEGES ON *.* TO 'hive'@'%'; FLUSH PRIVILEGES;
hive用户能够不用指定所有库的权限。
ambari-server setup
如下为所有的配置过程,其中主要是自定义jdk,输入JAVA_HOME路径,自定义数据库选mysql,输入数据库用户名,密码等
ambari-server setup Using python /usr/bin/python2 Setup ambari-server Checking SELinux... SELinux status is 'enabled' SELinux mode is 'permissive' WARNING: SELinux is set to 'permissive' mode and temporarily disabled. OK to continue [y/n] (y)? y Customize user account for ambari-server daemon [y/n] (n)? y Enter user account for ambari-server daemon (root):ambari Adjusting ambari-server permissions and ownership... Checking firewall status... Checking JDK... [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 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: /opt/jdk1.8.0_151 Validating JDK on Ambari Server...done. 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)? y 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 (1): 3 Hostname (localhost): Port (3306): Database name (ambari): Username (ambari): Enter Database Password (bigdata): Re-enter password: Configuring ambari database... Configuring remote database connection properties... 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 Proceed with configuring remote database connection properties [y/n] (y)? y Extracting system views... ambari-admin-2.6.1.5.3.jar ........... Adjusting ambari-server permissions and ownership... Ambari Server 'setup' completed successfully.
mysql -uambari -pAmbari-123 use ambari; source /var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql
ambari-server start
用户名,密码为admin admin
其中HDP-GPL较小,用默认的便可
其中下面的为master上ssh的私钥(~/.ssh/id_rsa)
若是失败或者卡住不动可根据日志解决,若是warn根据提示信息解决,知道所有为Success才能够进行下一步。
若是有依赖其余组件选择ok便可,如安装hive依赖tez,pig等
其中红色的必需要改,大体是设置路径,密码等,如hive要设置hive元数据的数据库信息,我用的master上的mysql
测试一下链接
没有了红色的便可进行下一步,如遇到warn,可根据提示信息进行修改配置,也能够忽略警告,等装完之后再改。
这里由于我的电脑配置较低,浏览器有点卡,进度条没有显示出来。
若最后出现警告,能够装完重启全部服务,再检查看看有没有问题,若有警告或启动失败,可根据日志排查缘由,一开始安装的的组件较多的话,出现警告的可能性会大一些,因此能够先装几个必要的组件,以后一个一个组件装。
此次安装重启以后发现hive等服务启动不成功,我就把hive等卸载而后重装,原本觉得是开始是hive没安装成功,可是重装后hive仍是启动不成功,看了一下日志,发现是以前手动安装的原生的hive的环境变量没有注释掉,注释掉,重启ambari以后,再启动全部服务,就成功了(再在hive shell 里建表、插入数据、查询验证一下),因此若是在已经安装好的大数据集群上安装ambari,最好先把以前配的环境变量注释掉。