使用Docker在Apache Ambari上进行安装

由于在个人服务器上拥有Hadoop集群的环境会带来高昂的成本,所以即使规格稍低也无妨,我希望在个人本地PC上尽可能地进行构建。
本次我将根据以下文章编写Dockerfile,并尝试在Docker容器中启动Ambari。
Apache Ambari安装指南。

写Dockerfile

    1. 我将尝试使用CentOS 7。

 

    1. 我将安装一些可能会用到的命令。

 

    1. 为了在CentOS 7中使用service命令,我会安装initscripts。

 

    1. 我会提前下载Ambari仓库。

 

    我会安装Ambari Server。
# 1
FROM centos:centos7
LABEL maintainer "blueskyarea"

USER root

# 2. Install commands
RUN yum install -y curl tar rsync wget

# 3. Install initscripts for service command
RUN yum -y install initscripts && yum clean all

# 4. Download Ambari repository
RUN wget -nv http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.6.2.0/ambari.repo -O /etc/yum.repos.d/ambari.repo

# 5. Install Ambari server
RUN yum install -y ambari-server

制作Docker映像

这次我们将图像名称指定为”ambari262″。

$ docker build -t ambari262 .
double free or corruption (out)
SIGABRT: abort
PC=0x7fe1348bde97 m=0 sigcode=18446744073709551610
signal arrived during cgo execution
(中略)
Complete!
Removing intermediate container 7b98ea9a218a
 ---> 7003da2b64b7
Successfully built 7003da2b64b7
Successfully tagged ambari262:latest

已经创建了一个Docker镜像。

$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
ambari262           latest              7003da2b64b7        4 minutes ago       1.27GB

启动容器

在Ambari服务器中,默认使用内置的postgres。为了启动postgres,似乎需要使用systemctl命令,但在Centos7中,似乎需要执行/sbin/init。(附注)由于在构建集群时需要指定主机名,因此我们将定义主机名。此外,为了确保起见,我们将绑定Ambari Server默认使用的端口。
8440:Ambari Agents与Ambari Server之间的握手端口
8441:Ambari Agents与Ambari Server之间的注册和心跳端口

$ docker run -d -h host01.blueskyarea -p 8440:8440 -p 8441:8441 --privileged ambari262 /sbin/init
84c36c37ff468532962121011002ecb324f3df8edf3f16ae0e7016ac1dcd3033

然后,在该容器上启动 bash。

$ docker exec -it 84c36c37ff46 /bin/bash

安装Ambari服务器

我将按照手册进行设置。
需要注意的是,在回答”Enter advanced database configuration y/n?”的问题时,选择No(n)。
如果选择Yes(y),并手动选择要使用的数据库,则需要自己启动数据库并进行模式创建等操作。
※因为我在这一步卡住了,所以重新创建了容器来重试。

[root@84c36c37ff46 /]# ambari-server setup
Using python  /usr/bin/python
Setup ambari-server
Checking SELinux...
WARNING: Could not run /usr/sbin/sestatus: OK
Customize user account for ambari-server daemon [y/n] (n)? 
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): 
To download the Oracle JDK and the Java Cryptography Extension (JCE) Policy Files you must accept the license terms found at http://www.oracle.com/technetwork/java/javase/terms/license/index.html and not accepting will cancel the Ambari Server setup and you must install the JDK and JCE files manually.
Do you accept the Oracle Binary Code License Agreement [y/n] (y)? 
Downloading JDK from http://public-repo-1.hortonworks.com/ARTIFACTS/jdk-8u112-linux-x64.tar.gz to /var/lib/ambari-server/resources/jdk-8u112-linux-x64.tar.gz
jdk-8u112-linux-x64.tar.gz... 100% (174.7 MB of 174.7 MB)
Successfully downloaded JDK distribution to /var/lib/ambari-server/resources/jdk-8u112-linux-x64.tar.gz
Installing JDK to /usr/jdk64/
Successfully installed JDK to /usr/jdk64/
Downloading JCE Policy archive from http://public-repo-1.hortonworks.com/ARTIFACTS/jce_policy-8.zip to /var/lib/ambari-server/resources/jce_policy-8.zip

Successfully downloaded JCE Policy archive to /var/lib/ambari-server/resources/jce_policy-8.zip
Installing JCE policy...
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)? 
Configuring database...
Default properties detected. Using built-in database.
Configuring ambari database...
Checking PostgreSQL...
Running initdb: This may take up to a minute.
Initializing database ... OK

About to start PostgreSQL
Configuring local database...
Configuring PostgreSQL...
Restarting PostgreSQL
Creating schema and user...
done.
Creating tables...
done.
Extracting system views...
.........ambari-admin-2.6.2.0.155.jar
..
Adjusting ambari-server permissions and ownership...
Ambari Server 'setup' completed successfully.

Ambari服务器的启动

[root@84c36c37ff46 /]# ambari-server start
Using python  /usr/bin/python
Starting ambari-server
Ambari Server running with administrator privileges.
Organizing resource files at /var/lib/ambari-server/resources...
Ambari database consistency check started...
Server PID at: /var/run/ambari-server/ambari-server.pid
Server out at: /var/log/ambari-server/ambari-server.out
Server log at: /var/log/ambari-server/ambari-server.log
(中略)

我将检查容器的IP地址,并尝试通过8080端口访问。

$ docker inspect --format '{{.NetworkSettings.IPAddress}}' 84c36c37ff46
172.17.0.2
ambari-login.PNG
ambari-dashboard.PNG
广告
将在 10 秒后关闭
bannerAds