利用 ambari 安装 hadoop 集群是很是方便的。前端图形化,点点就搞定了。可是hadoop的配置仍是要本身来定义的。html
实验环境:前端
10.111.32.115 hdp115.hfln.com ambari-serverjava
10.111.32.162 hdp115.hfln.com ambari-agent
node
10.111.32.163 hdp115.hfln.com ambari-agentpython
10.111.32.183 hdp115.hfln.com ambari-agentmysql
32.115 作为 master 已经实现了与其余主机的名密钥登陆了,这里 32.162 规划为 resourcemanager,因此也要实现与其余主机的名密钥登陆。sql
下载离线安装所需的包文件。docker
# 这个是下载 ambari 的一个仓库文件,利用这个仓库文件能够从公网上下载 ambari-server 等相关包,这里由于有数据库
ambari-2.1.0-centos6.tar.gzcentos
这个包,一会作成本身本地源,因此若是你不下,本身写也是没问题的。
下面的 hdp.repo 也是如此。可下可不下。其余三个就是必须下。
[root@hdp115 hdp]# wget http://public-repo-1.hortonworks.com/ambari/centos6/2.x/updates/2.1.0/ambari.repo [root@hdp115 hdp]# wget http://public-repo-1.hortonworks.com/HDP/centos6/2.x/updates/2.3.0.0/hdp.repo [root@hdp115 hdp]# wget http://public-repo-1.hortonworks.com/ambari/centos6/ambari-2.1.0-centos6.tar.gz [root@hdp115 hdp]# wget http://public-repo-1.hortonworks.com/HDP/centos6/2.x/updates/2.3.0.0/HDP-2.3.0.0-centos6-rpm.tar.gz [root@hdp115 hdp]# wget -c http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.20/repos/centos6/HDP-UTILS-1.1.0.20-centos6.tar.gz
这个下载地址能够尝试变换一下,好比你想下载 1.7 版的 ambari,就能够写成
[root@hdp115 hdp]# wget http://public-repo-1.hortonworks.com/ambari/centos6/ambari-1.7.0-centos6.tar.gz
有些太老的估计就下不了了。
2. 创建本地仓库,这里使用 httpd 来创建,安装启动httpd省略。解压三个包到 /var/www/html 目录下。
[root@hdp115 hdp]# tar xf ambari-2.1.0-centos6.tar.gz -C /var/www/html/ [root@hdp115 hdp]# tar xf HDP-2.3.0.0-centos6-rpm.tar.gz -C /var/www/html/ [root@hdp115 hdp]# tar xf HDP-UTILS-1.1.0.20-centos6.tar.gz -C /var/www/html/
## 修改 ambari.repo 与 hdp.repo 中的路径,使之与 yum源机器匹配,如上个人IP 为10.111.32.115,那么将
[root@hdp115 hdp]# cat ambari.repo #VERSION_NUMBER=2.1.0-1470 [Updates-ambari-2.1.0] name=ambari-2.1.0 - Updates baseurl=http://public-repo-1.hortonworks.com/ambari/centos6/2.x/updates/2.1.0 gpgcheck=1 gpgkey=http://public-repo-1.hortonworks.com/ambari/centos6/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins enabled=1 priority=1
##修改后的文件内容。 要注意的是 ambari-2.1.0-centos6.tar.gz 解压后的名字为 ambari-2.1.0, 而 ambari.repo 中的路径没带版本号,因此还须要将 ambari-2.1.0 更名为: ambari
[root@hdp115 hdp]# cat ambari.repo #VERSION_NUMBER=2.1.0-1470 [Updates-ambari-2.1.0] name=ambari-2.1.0 - Updates baseurl=http://10.111.32.115/ambari/centos6/ gpgcheck=1 gpgkey=http://10.111.32.115/ambari/centos6/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins enabled=1 priority=1
3. 安装设置 ambari-server.
将 ambari.repo 复制到 /etc/yum.repos.d/ 目录下,安装 ambari-server。
[root@hdp115 yum.repos.d]# yum install ambari-server
安装好以后,配置ambari-server, 配置包括
1. 检查系统环境
2. 选择jdk, 这里已经本身部署了jdk_1.8.0_73, 选择他的,下载的巨慢。
3. 选择数据库,若是默认,将使用 postgresql.这里选择了本身安装mysql.
[root@hdp115 yum.repos.d]# ambari-server setup Using python /usr/bin/python2.6 Setup ambari-server Checking SELinux... SELinux status is 'disabled' Customize user account for ambari-server daemon [y/n] (n)? y Enter user account for ambari-server daemon (root): 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: /usr/jdk64/jdk1.7.0_67 Validating JDK on Ambari Server...done. 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 [4] - PostgreSQL [5] - Microsoft SQL Server (Tech Preview) ============================================================================== Enter choice (1): 3 Hostname (localhost): Port (3306): Database name (ambari): Username (ambari): Enter Database Password (bigdata): Configuring ambari database... Copying JDBC drivers to server resources... 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)? Extracting system views... ...ambari-admin-2.1.0.1470.jar ... Adjusting ambari-server permissions and ownership... Ambari Server 'setup' completed successfully.
当选择 mysql 以后,他会提示你,要导入相关的 sql 文件,还会尝试用 jdbc 去链接数据库,因此要
1. 把 /var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql 导入数据库
2. 开通相关权限,按照上面的提示
3. 安装 jdbc
设置好以后就能够启动 ambari-server 了,启动方式与通常的服务启动同样。
[root@hdp115 ~]# /etc/init.d/ambari-server start
4. 利用 ambari 安装 HDP 集群
这个时候你能够看你的 8080 端口是否在监听了,尝试在浏览器打开此连接
登陆ambary, user:admin, pass: admin
点击 launch install wizard ,开始建立一个集群
输入集群名称,此处为 beyond
选择版本号:注意下面的“Advanced Repository Options” 按钮,上面的选择会显示出下面所对应的版本,这里选择 HDP 2.3(由于咱们下载的包文件就是2.3的),下面的仓库选项,选择相应版本,并修改成本身的本地的仓库地址,注意要修改正确为本身定义的路径,这个修改好的仓库会被分发到各个节点的 /etc/yum.repos.d/ 目录下
这里添写要加入集群的机器的 fqdn ,还有将ambari 的私钥文件上传
这个步骤会在相关机器上安装ambar-agent来实现跟ambari-server 通讯。--这里已经安装ambar-agent 成功。注:若是安装失败,在success 的地方会变成 Failed, 那么请点开查看错误缘由。
通常来讲,有如下几点:
1. ambari-server 主机与 agent 不能使用密钥文件 登陆,即没法联通。请手动检查是否能够无密码在远程机器上执行命令。
2.yum 安装时失败,到/etc/yum.repos.d/ 目录下检查,有没有ambari.repo 仓库文件。尝试用 yum clean all 清除过时的缓存,再次尝试安装。
3.此前安装过 ambari等相关的功能,没有清理干净,又从新安装的,那么检查一下残留文件,删除重试便可。
错误缘由仍是很详细的,要视状况而处理。
上图底下有个“ Click hereto see the warnings.” 按钮,打开后会显示主机上的各类警告信息,
虽然已经安装了 ambari-agent,但是还有其余可能致使安装集群失败的潜在不足,好比 ntp没作,或防火墙规则存在,虽然放行了 ssh,可是等安装hadoop集群,须要打开不少的tcp 端口,可能会致使错误发生。本身视状况检查吧(我这个环境由于安装过HDP,许多提示都是说已经安装了某包,有某些配置文件已存在等等)
有些问题不重要,若是没解决,这里会有提示,直接确认便可。
这一步,选择安装什么组件,本身看着选吧,我选了最基本的。hdfs + yarn+mapreduce2 + zookeeper + pig + tez +ambari_Metrics
调整每一个机器上所安装的组件
选择在哪里安装 datanode ,等组件
调整各服务配置选项,在实际环境中,这就是在打开 xml的配置文件在配置
确认检查,选择 deploy 开始安装
成功以后像这样子,本例中忘了裁下引图片。
安装成功。
终于搞定啦。方法没错,只是原来的机器,已经安装过屡次hadoop, 由于有些东西没能清理干净而致使步骤出错,只要看日志细心排查就会OK的,但愿 ambari 也能有卸载的功能就行了。
另外在此过程当中还有sql 导入出错的问题:
1.导入 /var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql时,说是某数据类型太大,不支持。个人mysql 版本是 5.1.7的,遂更新至 5.6.30 ,导入成功
2.启动ambari-server 时不成功,看了日志说是jdbc 的版本太低,又更新了
mysql-connector-java-5.1.25.解决成功。
在使用 docker 建立hadoop 安装环境的 centos6.8 容器时,在根下建立了 /hadoop:/hadoop 数据卷。
这个是颇有必要的,在前端进行安装时,给出了目录不足的警告,由于 docker 的容器默认只有10G 的大小,容器并非主要用来存储数据的。因此任何跟数据有关的必定要记得使用数据卷功能。