Ubuntu16安装基于Ambari的HDP集群

安装环境

两台干净的Ubuntu16系统分别作为主机和从节点,系统间网络连通,内存最好大于4G;

集群基础配置

1.主机命名 master.example.com node1.example.com node2.example.com(生产环境下建议使用域名服务器进行解析)
三步操作:1 )hostname 主机名 2)修改/etc/hosts 文件对应DNS解析 3)修改/etc/hostname文件 最后使用hostname hostname -A对结果进行检测,要求与设置值一致
2.配置主机ssh免密登录note2。ssh相关配置 (最好使用root用户,普通用户可能会失败)
3.安装ntp : apt-get install -y ntp
4.禁用防火墙 sudo ufw status
5.禁用Transparent Huge Page(禁用大内存页面可以提升MR效率)echo never > /sys/kernel/mm/transparent_hugepage/enabled

    首先查看机器硬件配置信息,包括内存及CPU配置信息,根据配置分配不同的角色:

        cat /proc/meminfo |grep MemTotal 

        cat /proc/cpuinfo |grep “model name” && cat /proc/cpuinfo |grep “physical id”

准备安装包

其中要安装的组件有JDK-1.8 确认一下Python版本为2.7 然后下载Ambari2.7.3对应的组件,其中包括:ambari-2.7.3.0 HDP HDP-UTILS HDP-GPL

首先是Ambari安装包位置:
    选择下载最新版,这样子在版本控制方面选择余地更大
    主页:
        https://docs.hortonworks.com/HDPDocuments/Ambari-2.7.3.0/bk_ambari-installation/content/ambari_repositories.html
        https://docs.hortonworks.com/HDPDocuments/Ambari-2.7.3.0/bk_ambari-installation/content/hdp_31_repositories.html
    下载链接:
        ambari-2.7.3.0  http://public-repo-1.hortonworks.com/ambari/ubuntu16/2.x/updates/2.7.3.0/ambari-2.7.3.0-ubuntu16.tar.gz
        HDP  http://public-repo-1.hortonworks.com/HDP/ubuntu16/3.x/updates/3.1.0.0/HDP-3.1.0.0-ubuntu16-deb.tar.gz
        HDP-UTILS  http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.22/repos/ubuntu16/HDP-UTILS-1.1.0.22-ubuntu16.tar.gz
        HDP-GPL  http://public-repo-1.hortonworks.com/HDP-GPL/ubuntu16/3.x/updates/3.1.0.0/HDP-GPL-3.1.0.0-ubuntu16-gpl.tar.gz

配置环境

需要自己配置本地源 : mkdir -p /var/www/ambari 将上述安装包解压到该目录下,通过Python服务器在该目录启动访问链接:( 以静默的方式启动Python服务器 nohup python -m SimpleHTTPServer 1>out.log 2>&1 &)

mkdir -p /var/www/ambari
    ls /var/www/ambari
    ambari HDP HDP-GPL HDP-UTILS

配置Ubuntu启动源

 		    cd  /etc/apt/sources.list.d
            vi  /etc/apt/sources.lost.d/ambari.list
                deb http://10.1.51.17:8000/ambari/ubuntu16/2.7.3.0-139/ Ambari main
            vi  /etc/apt/sources.list.d/ambari-hdp.list
                deb http://10.1.51.17:8000/HDP/ubuntu16/3.1.0.0-78/ HDP main
                deb http://10.1.51.17:8000/HDP-GPL/ubuntu16/3.1.0.0-78/ HDP-GPL main
                deb http://10.1.51.17:8000/HDP-UTILS/ubuntu16/1.1.0.22/ HDP-UTILS main

        apt-key adv --recv-keys --keyserver keyserver.ubuntu.com B9733A7A07513CAD
        apt-get update
        apt-cache showpkg ambari-server

最后在apt-server服务器上执行:
	    apt-get install ambari-server

安装mysql

在mysql中分别创建数据库ambari,hive和其相应用户,创建相应的表:

CREATE DATABASE ambari;
use ambari;
CREATE USER 'ambari'@'%' IDENTIFIED BY 'ambari';
GRANT ALL PRIVILEGES ON *.* TO 'ambari'@'%';
FLUSH PRIVILEGES;
source /var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql

CREATE DATABASE hive;
use hive;
CREATE USER 'hive'@'%' IDENTIFIED BY 'hive';
GRANT ALL PRIVILEGES ON *.* TO 'hive'@'%';
FLUSH PRIVILEGES;

注:在配置Ambari前先在mysql中建库建表,可以避免执行ambari-server setup时的中断。
2.4. 配置Ambari
执行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_131
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):hdp131.cancer.com
Port (3306):
Database name (ambari):
Username (ambari):
Enter Database Password (bigdata):
Re-Enter password:
(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
Proceed with configuring remote database connection properties [y/n] (y)?
如果使用自己定义的数据库,必须在启动Ambari服务之前导入Ambari的sql脚本。这一点在安装mysql环节提到过。
2.5. 启动Amabri
执行ambari-server start

配置hdp集群

ambari启动的默认端口为8080,我们打开服务器页面。账号密码:admin

进去后第一步:我们选择:Launch Install Wizard 。创建一个自己的集群。
第二部:名字任意。
第三步:Select Stack。这里我们选择 HDP3.1 -》Use Local Repository -》Ubuntu16。分别填入自己的url。
http://:8000/HDP/ubuntu16/2.6.3.0235/http://{主机}:8000/HDP/ubuntu16/2.6.3.0-235/ http://{主机}:8000/HDP-UTILS-1.1.0.21-ubuntu16/
Ubuntu16安装基于Ambari的HDP集群
第四步:Target Hosts填入我们的主机和从机hostname,SSH Private Key填入你主机用户下私钥:~/.ssh/id_rsa。SSH User Account 填入你使用ssh的用户,建议都是root。
Ubuntu16安装基于Ambari的HDP集群
第五步:确认ssh是不是连得上你所有机器。连不上再重新配置再刷新。
第六步:安装你需要的组件,有些必须的你去掉了也是让你选上的。

第七步:选择主从机安装的组件(hive Metastore最好放到有安装mysql的服务器)

第八步:制定服务。这里需要我们测试下hive的连接。我这里是报错找不到JDBC。它提示在ambari-server setup加入启动参数(必须照做)

安装MySQL JDBC驱动

tar -zxvf mysql-connector-java-5.1.38.tar.gz 
cp ./mysql-connector-java-5.1.38/mysql-connector-java-5.1.38-bin.jar /usr/share/java/mysql-connector-java.jar

成功安装:
Ubuntu16安装基于Ambari的HDP集群
安装过程中的问题(部分):

  1. apt-get install ambari-agent 显示已安装 但没有/etc/ambari-agent 文件夹:
    ERROR: Bootstrap of host slave.eulikind fails because previous action finished with non-zero exit code (2)
    ERROR MESSAGE: Connection to slave.eulikind closed.

STDOUT: sed: 无法读取 /etc/ambari-agent/conf/ambari-agent.ini: 没有那个文件或目录
(’’, None)

解决:
apt-get remove ambari-agent
apt-get install ambari-agent
卸载重新安装

常见问题:
https://blog.****.net/xfg0218/article/details/78067541
参考:
https://blog.****.net/yyoc97/article/details/79658378
https://www.cnblogs.com/tianxia2s/p/10143444.html
https://blog.****.net/cwx714/article/details/72652542