Ambari Environment Building (Offline Building)

Time:2019-9-17

Ambari offline deployment

Ambari introduction

Ambari is a top-level open source project of Apache Software Foundation and a tool for centralized deployment, management and monitoring of Hadoop distributed clusters. But here Hadoop is a broad concept, not just Hadoop (HDFS, MapReduce), but Hadoop ecosystem (including Spark, Hive, Hbase, Sqoop, Zookeeper, Flume, etc.). Ambari can make Hadoop big data software easier to use, and can easily integrate our own services. Ambari unified management.

  • Deployment: Automated deployment of Hadoop software can automatically handle dependencies between services and components (e.g. HBase depends on HDFS, when DataNode starts, it needs NameNode to start first, etc.).
  • Management: Start, stop, restart of Hadoop service components, multi-version management of configuration files.
  • Monitoring: The current status of Hadoop services (component node survival, YARN task execution, etc.), the current status of the host (memory, hard disk, CPU, network, etc.), and can customize alarm events.

Ambari Environment Building (Offline Building)

Ambari version correspondence table

This time, HDP 2.5 version is adopted.

Ambari Environment Building (Offline Building)

Cluster planning

Cluster hostname Software installation
nn1 ambari-agent,namenode,datanode,zookeeper
nn2 ambari-agent,namenode,datanode,zookeeper
rm ambari-server,resourcemanager,historyserver,datanode

Install Ambari-Server

The prerequisite is to download the required offline packages.
And upload these packages to the node rm.
Offline package description required:

  • HDP-UTILS-1.1.0.21-centos7.tar.gz (HDP Toolkit)
  • Ambari-2.4.1.0-centos7.tar.gz (ambari offline package)
  • HDP-2.5.0.0-centos7-rpm.tar.gz (official download link address)
  • CentOS-7-x86_64-DVD-1503-01.iso (Centos7 offline package)
  • jdk

Centos7 64 System Software Requirements

  • yum and rpm
  • scp,curl,unzip,tar,and wget
  • openSSL
  • Python 2.7.x
  • JDK 1.8.0_77 (official recommendation, but I can use 1.8.0_11 as well)
  • It is recommended to modify the maximum open file description to 10000, temporary changeulimit -n 10000

Permanent change, need to modify the configuration file, and need to restart, the proposal and SELinux shutdown together, and then do restart.

vi /etc/security/limits.conf
Add to
* soft nofile 10000
* hard nofile 10000
  • Language must be default English

Install ansible (optional)

Note: The next step is to use the command of ansible. If you do not install ansible, use the original command.
Example:
ansible all -m command -a 'systemctl stop firewalld'
Equivalent to executing commands on each host
systemctl stop firewalld

Installation and operation of ansible

Configure SSH confidentiality-free

Modify hosts to increase your cluster information. Each configuration is the same.

192.168.0.135   nn1.ambari      nn1
192.168.0.136   nn2.ambari      nn2
192.168.0.137   rm.ambari       rm

On the RM node, execute commandsssh-keygenJust hit enter four times, and then execute

ssh-copy-id nn1
ssh-copy-id nn2
ssh-copy-id rm

Close the firewall

ansible all -m command -a 'systemctl stop firewalld'
ansible all -m command -a 'systemctl disable firewalld'

Close Selinux

Modify / etc / SELinux / config to SELINUX = disable, need to restart

Install JDK

1. Decompression Packet

cd /opt
tar -zxvf  jdk-8u111-linux-x64.tar.gz

2. Add configuration to / etc / profile

export JAVA_HOME=/opt/jdk1.8.0_111
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

3. Copy JDK packages and configuration files to NN1 and nn2 nodes

scp -r jdk1.8.0_111 nn2:/opt/
scp /etc/profile nn2:/etc/
scp -r jdk1.8.0_111 nn1:/opt/
scp /etc/profile nn1:/etc/

4. Verify
java -version

Offline mounting of Centos7 source

1. Create a new directory to be mounted (for the convenience of httpd source later, create it directly on the default directory of httpd)
mkdir -p /var/www/html/centos7
2. Mounting Mirror Files
mount -t iso9660 -o loop /opt/CentOS-7-x86_64-DVD-1511.iso /var/www/html/centos7
3. Back up other repo files and build offline sources

cd /etc/yum.repos.d
mkdir backup
mv Centos-* backup
touch centos-media.repo

Write the following in centos-media.repo

[centos7-media]
name=Centos linux 7.0
baseurl=file:///var/www/html/centos7
enabled=1
gpgcheck=0

4. Verify the availability of offline sources.

yum clean all
yum makecache

Configure ambari, HDP offline source

1. Configuration Path

cd /var/www/html
mkdir ambari
mkdir hdp

2. Unpack to the corresponding path

 tar -zxvf /opt/Ambari/ambari-2.4.1.0-centos7.tar.gz -C /var/www/html/ambari/
 tar -zxvf /opt/Ambari/HDP-2.5.0.0-centos7-rpm.tar.gz -C /var/www/html/hdp/
 tar -zxvf /opt/Ambari/HDP-UTILS-1.1.0.21-centos7.tar.gz -C /var/www/html/hdp/

3. Building offline sources

3.1. Building on RM Node

Ambari offline source
vi /etc/yum.repos.d/ambari.repo

[ambari-2.4.1.0]
name=ambari-2.4.1.0 - Updates
baseurl=http://rm/ambari/AMBARI-2.4.1.0/centos7/2.4.1.0-22
gpgcheck=0
#gpgkey=http://public-repo-1.hortonworks.com/ambari/centos7/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins
enabled=1
priority=1

HDP offline source
vi /etc/yum.repos.d/hdp.repo

[HDP-2.5]
name=HDP-2.5
baseurl=http://rm/hdp/HDP/centos7
enabled=1
gpgcheck=0

Hdp-utils offline source
vi /etc/yum.repos.d/hdp-utils.repo

[HDP-UTILS-1.1.0.21]
name=HDP-UTILS-1.1.0.21
baseurl=http://rm/hdp/HDP-UTILS-1.1.0.21/repos/centos7
enabled=1
gpgcheck=0

Install Apache Httpd

1, installation
yum install httpd -y
2. Modify configuration
vi /etc/httpd/conf/httpd.conf

Ambari Environment Building (Offline Building)

Change the red in the figure to
ServerName rm:80

<Directory />
  Options FollowSymLinks
  AllowOverride None
  Order allow,deny
  Allow from all
</Directory>

3. Start httpd
systemctl start httpd
systemctl enable httpd
4. Verify that offline sources are available
Open the browser on your computer, enter rm/centos7 (if the host needs to be configured). The following figure shows the success.

Ambari Environment Building (Offline Building)

Install Chrony time synchronization tool

ansible all -m yum -a "name=chrony"

Modify Chrony configuration file at RM node

Ambari Environment Building (Offline Building)

To modify the configuration files on NN1 and nn2 nodes, you only need to add servers that need to be synchronized.

Ambari Environment Building (Offline Building)

Start the Chrony service
ansible all -m command -a 'systemctl start chronyd'

Check whether the time has been synchronized.

Install ambari-server

1, installation
yum install ambari-server -y
2, configuration
ambari-server setup

Most of them just go down by default.

[[email protected] ~]# 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)? y
Enter user account for ambari-server daemon (root):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: /opt/jdk1.8.0_111
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 / MariaDB
[4] - PostgreSQL
[5] - Microsoft SQL Server (Tech Preview)
[6] - SQL Anywhere
[7] - BDB
==============================================================================
Enter choice (1): 1
Database name (ambari): ambari
Postgres schema (ambari): ambari
Username (ambari): ambari
Enter Database Password (bigdata):
Invalid characters in password. Use only alphanumeric or _ or - characters
Enter Database Password (bigdata):
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...
Connecting to local database...done.
Configuring PostgreSQL...
Restarting PostgreSQL
Extracting system views...
ambari-admin-2.4.1.0.22.jar
...........
Adjusting ambari-server permissions and ownership...
Ambari Server 'setup' completed successfully.

3. Start up
ambari-server start

Install ambari-agent

As ambari-agent condition:

  • Firewall closure
  • SELinux shutdown
  • JDK installation
  • Chrony installation
  • Because this is an offline environment, we need to configure offline sources.

Because of the first four conditions, ambari-server was installed when it was installed.

All you have to do is configure offline sources.

Offline Source Configuration
Delete default repo
rm -f /etc/yum.repos.d/*.repo

Duplicate rm’s offline source to other nodes

scp /etc/yum.repos.d/ambari.repo nn1:/etc/yum.repos.d/
scp /etc/yum.repos.d/ambari.repo nn2:/etc/yum.repos.d/
scp /etc/yum.repos.d/hdp.repo nn2:/etc/yum.repos.d/
scp /etc/yum.repos.d/hdp.repo nn1:/etc/yum.repos.d/
scp /etc/yum.repos.d/hdp-utils.repo nn1:/etc/yum.repos.d/
scp /etc/yum.repos.d/hdp-utils.repo nn2:/etc/yum.repos.d/

3.3 Verify on NN1 and nn2

yum makecache

New ambari-agent

You need to reconfigure the preceding environment mentioned earlier.

In addition, you need to modify ambari-server’s / etc / hosts to add new machines and execute them.ssh-copy-id $new_hostname

Installing clusters on ambari-web

Open the browser, enter the IP/HostName:8080 of the node where ambari-server is located, and then operate directly on the interface.

Just pay attention to some pits.

Because the screen was forgotten on this side of the interface, give me a link – deploy a Hadoop 2.X cluster as a reference.

When installing, snappy package will be wrong

resource_management.core.exceptions.Fail: Execution of '/usr/bin/yum -d 0 -e 0 -y install snappy-devel' returned 1. Error: Package: snappy-devel-1.0.5-1.el6.x86_64 (HDP-UTILS-1.1.0.21)
           Requires: snappy(x86-64) = 1.0.5-1.el6
           Installed: snappy-1.1.0-3.el7.x86_64 (@anaconda)
               snappy(x86-64) = 1.1.0-3.el7
           Available: snappy-1.0.5-1.el6.x86_64 (HDP-UTILS-1.1.0.21)
               snappy(x86-64) = 1.0.5-1.el6
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

Unloading the snappy
ansible all -m yum -a 'name=snappy state=removed'
Install snappy-devel
ansible all -m yum -a 'name=snappy-devel'

Installation of ambari on docker

This is very convenient. A test cluster can be built in 10 minutes, but the drawback is that the source of the author is not offline. To build the cluster, it needs a network environment.

1. Installing docker
2. Download GitHub docker ambari
github docker-ambari
3. Deploy it simply according to the readme document on the web site.

3.1 decompression package  
3.2 Enter Unpackaged Packet Directory  
`. ambari-functions or source ambari-functions`   
3.3 Start Cluster  
`amb-start-cluster 3`  

![](../images/ambari/ambari_docker_github_result.jpg)

Residual problem

The author mentioned in Readme
Ambari containers started by ambari-function are using bridge networking. This means that you will not be able to communicate with containers directly from host unless you specify the route to containers. You can do this with:

# Getting the IP of docker-machine or boot2docker
docker-machine ip <name-of-docker-vm>
# or
boot2docker ip

# Setting up the
sudo route add -net 172.17.0.0/16 <docker-machine or boot2docker>
# e.g:
sudo route add -net 172.17.0.0/16 192.168.99.100

In general, it means that 172.17.0 network can be connected by configuring routes locally. That is to say, the author did not map out the ports. I configure my own network route, but it can not be connected.

The next step is to start ambari-server by modifying the docker’s command to start ambari-server, and then enter the host IP: mapping port number to access the ambari-server image created by the author. As shown in the picture:

Ambari Environment Building (Offline Building)

Ambari Environment Building (Offline Building)

Docker builds ambari offline

1. Put ambari and HDP offline sources on the host and decompress them.
2. Start building Dockerfile

The preparation documents are as follows

ambari.repo           
Dockerfile                 
hdp.repo                   
hdp-utils.repo             
httpd.conf                 
jdk-8u111-linux-x64.tar.gz 
supervisord.conf           

Dockerfile content

FROM centos

MAINTAINER linjk

Install JDK
ADD jdk-8u111-linux-x64.tar.gz /usr/local/src/
ENV JAVA_HOME=/usr/local/src/jdk1.8.0_111
ENV PATH=$PATH:$JAVA_HOME/bin
ENV CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

# Install httpd and other necessary tools
RUN yum makecache Fast \
        && yum install httpd openssh-server net-tools chrony -y
# Install Supervisor
RUN yum -y install python-setuptools \
                && easy_install supervisor \
                && mkdir -p /etc/supervisor
COPY supervisord.conf /etc/supervisor/
COPY httpd.conf /etc/httpd/conf/httpd.conf

RUN mkdir -p /var/www/html/centos/ \
        && mkdir -p /var/www/html/ambari/ \
        && mkdir -p /var/www/html/hdp/
COPY *.repo /etc/yum.repos.d/

# Install MariaDB and mariadb-server
yum install -y mariadb mariadb-server mysql-connector-java

EXPOSE 22 80 9001 8080 3306

CMD supervisord -c /etc/supervisor/supervisord.conf

Ambari. repo content

[ambari-2.4.1.0]
name=ambari-2.4.1.0 - Updates
baseurl=http://ambari-server/ambari/AMBARI-2.4.1.0/centos7/2.4.1.0-22
gpgcheck=0
#gpgkey=http://public-repo-1.hortonworks.com/ambari/centos7/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins
enabled=1
priority=1

Hdp. repo content

[HDP-2.5]
name=HDP-2.5
baseurl=http://ambari-server/hdp/HDP/centos7
enabled=1
gpgcheck=0

Hdp-utils.repo content

[HDP-UTILS-1.1.0.21]
name=HDP-UTILS-1.1.0.21
baseurl=http://ambari-server/hdp/HDP-UTILS-1.1.0.21/repos/centos7
enabled=1
gpgcheck=0

Contents modified by httpd.conf

ServerName ambari-server:80

#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
<Directory />
  Options FollowSymLinks
  AllowOverride None
  Order allow,deny
  Allow from all
</Directory>

Supervisor content

unix_http_server]
file=/var/run/supervisor.sock

[supervisord]
nodaemon=true

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
serverurl=unix:///var/run/supervisor.sock

[inet_http_server]
port=*:9001

[program:sshd]
command=/usr/sbin/sshd -D

[program:httpd]
command=/usr/sbin/httpd

3. Build mirror ambari-server (previously compressed packages placed under / opt / ambari and / opt / hdp/)
docker run -d -P -v /opt/ambari/:/var/www/html/ambari/ -v /opt/hdp/:/var/www/html/hdp/ -h ambari-server --name as ambari-server /usr/sbin/init

4. Enter the container to start and configure mariaDB

4.1. Start-up
systemctl start mariadb
4.2. Set up boot start
systemctl enable mariadb
4.3. Configuration
mysql_secure_installation

There will be an interactive interface, basically all the way back, set the password interface

The first is to set the password, which will be prompted to enter first.
Enter current password for root (enter for none): < -- Direct return for initial operation

Set password
Set root password? [Y/n] < --- Do you set the root user password, enter y and return or return directly?
New password: <-Set the password for root users
Re-enter new password: <-Enter the password you set again

Other configurations
Remove anonymous users? [Y/n] < --- Delete anonymous users and return
Disallow root login remotely? [Y/n] < --- Do you prohibit root remote login and return?
Remove test database and access to it? [Y/n] < --- Delete test database and return
Reload privilege tables now? [Y/n] <- Do you reload the permission table and return?

4.4, (optional) Configure the character set of MariaDB
vi /etc/my.cnf
4.5. Adding User Setting Permissions

create database ambari;
use ambari;
CREATE USER 'ambari'@'%' IDENTIFIED BY 'bigdata';
GRANT ALL PRIVILEGES ON *.* TO 'ambari'@'%';
CREATE USER 'ambari'@'ambari-server' IDENTIFIED BY 'bigdata';
GRANT ALL PRIVILEGES ON *.* TO 'ambari'@'ambari-server';

5. Install ambari-server and configure and start it
5.1. Installation
yum install ambari-server
5.2. Configuration
ambari-server setup

Interactive interface appears

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)? y
Enter user account for ambari-server daemon (root):root
Adjusting ambari-server permissions and ownership...
Checking firewall status...
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
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 o
Path to JAVA_HOME: /usr/local/src/jdk1.8.0_111
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 / MariaDB
[4] - PostgreSQL
[5] - Microsoft SQL Server (Tech Preview)
[6] - SQL Anywhere
[7] - BDB
==============================================================================
Enter choice (3): 3
Hostname (ambari-server):
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)? y
Extracting system views...
ambari-admin-2.4.1.0.22.jar
...........
Adjusting ambari-server permissions and ownership...
Ambari Server 'setup' completed successfully.

According to the warning to MYSQL to execute SQL statements, pay attention to use ambari;

use ambari;
source  /var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql

Verify that some ambari configuration tables are generated

show tables;

6. Start up
ambari-server start
7, validation
Open $Host IP: Mapping Port in Browser