1. 程式人生 > >搭建ambari叢集

搭建ambari叢集

Ambari叢集部署手冊

(ambari離線安裝)

 

 

 

 

一、名詞介紹:

Ambari 叢集管理工具

HDP 叢集軟體儲存庫

Mysql 元資料庫

JDK 開發工具包

https://blog.csdn.net/microhhh/article/details/81239738

二、應用包以及伺服器準備:

1. 伺服器準備:

1.1主機名(ip在前,name在後)

(1)修改hostname:

hostnamectl set-hostname ambari

 

(2)vi  /etc/hosts

192.168.3.212 192-168-3-212.baicheng.com

192.168.3.133   192-168-3-133.baicheng.com(建立ambari使用者,密碼ambari)

192.168.3.134   192-168-3-134.baicheng.com

192.168.3.135   192-168-3-135.baicheng.com

192.168.3.136   192-168-3-136.baicheng.com

192.168.3.137   192-168-3-137.baicheng.com

192.168.3.138   192-168-3-138.baicheng.com

192.168.3.139   192-168-3-139.baicheng.com

1.2配置FQDN

ambari節點為例

vi /etc/sysconfig/network

NETWORKING=yes

HOSTNAME=ambari

1.3防火牆

臨時關閉所有節點防火牆

systemctl disable firewalld

systemctl stop firewalld

1.4 SELinux

臨時關閉所有SELinux

setenforce 0

永久關閉:

修改配置檔案需要重啟機器:

vi /etc/sysconfig/selinux

SELINUX=disabled

檢視SELinux狀態:

sestatus

 

1.5免密

其中ambari對其他6臺伺服器以及本伺服器(ambari)進行免密登入

主節點裡root使用者登入執行如下步驟

ssh-keygen

cd ~/.ssh/

cat id_rsa.pub >>authorized_keys

chmod  777 ~/.ssh

chmod  777 ~/.ssh/authorized_keys

先在從節點登入root執行命令

mkdir ~/.ssh/

分發主節點裡配置好的authorized_keys到各從節點

scp /root/.ssh/authorized_keys [email protected]:/root/.ssh/authorized_keys

 

 

ssh-keygen -t rsa

ssh-copy-id 192.168.200.128

 

1.6時間同步

1.7修改映象檔案編碼格式

修改檔案 vi  /etc/locale.conf 

將LANG="zh_CN.UTF-8"

修改為

LANG="en_US.UTF-8"

重啟

 

1.8 開啟NTP服務(每次啟動ambari之前確保ntp服務已開啟)

所有叢集上節點都需要操作

Centos 7 命令

yum  install ntp

systemctl is-enabled ntpd

systemctl enable ntpd

systemctl start ntpd

檢視狀態

systemctl status ntpd

 

安裝步驟如下:

1,執行命令如下:yum -y install ntp

2,安裝完成過後執行:vi /etc/ntp.conf

註釋掉所有server *.*.*的指向,新新增一條可連線的ntp伺服器(百度一下ntp伺服器,我選的是上海交大的)

server ntp1.aliyun.com iburst

啟動時間同步服務service ntpd start

執行命令 ntpdate -u ntp1.aliyun.com

重啟時間同步服務 service ntpd restart

通過ntpstat檢視 當前時間同步狀態

synchronised to NTP server (120.25.115.19) at stratum 3

   time correct to within 1043 ms

 

注意:

建議硬碟50G以上

192.168.80.144   ambari01   (部署Ambari-server和Mirror server)(分配1G,我這裡只是體驗過程,當然你可以分配更多或更小) 

  192.168.80.145   ambari02  (部署Agent)

  192.168.80.146   ambari03  (部署Agent)(分配1G,我這裡只是體驗過程,當然你可以分配更多或更小)

192.168.80.147   ambari04 (部署Agent)

配置ip:

vi  /etc/sysconfig/network-scripts/ifcfg-eth0

 

2.應用包準備:

jdk-8u151-linux-x64.tar.gz(推薦1.7+)

http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html  

mysql-5.6.33-linux-glibc2.5-x86_64.tar(推薦5.6+)

https://www.mysql.com/downloads/

 

Python2.6/2.7(centos自帶)

 

HDP-UTILS-1.1.0.21-centos7.tar.gz(可作為迅雷下載連結)

http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.21/repos/centos7/HDP-UTILS-1.1.0.21-centos7.tar.gz

 

HDP-2.6.3.0-centos7-rpm.tar.gz(可作為迅雷下載連結)

http://public-repo-1.hortonworks.com/HDP/centos7/2.x/updates/2.6.3.0/HDP-2.6.3.0-centos7-rpm.tar.gz

 

ambari-2.6.0.0-centos7.tar.gz(可作為迅雷下載連結)

http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.6.0.0/ambari-2.6.0.0-centos7.tar.gz

 

hdp.repo

http://public-repo-1.hortonworks.com/HDP/centos7/2.x/updates/2.6.3.0/HDP.repo

 

ambari.repo

http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.6.0.0/ambari.repo

 

三、部署安裝:

1.   jdk安裝

本地上傳jdk-8u151-linux-x64.tar.gz到/usr/local/目錄下

cd /usr/local

解壓該檔案

tar -zxvf jdk-8u151-linux-x64.tar.gz

刪除jdk-8u151-linux-x64.tar.gz壓縮包

rm -rf jdk-8u151-linux-x64.tar.gz

配置jdk環境變數

vi /etc/profile

在檔案底部追加

export JAVA_HOME=/usr/local/jdk1.8.0_151

export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

export PATH=$PATH:$JAVA_HOME/bin

傳送到其他主機

scp -r /etc/profile [email protected]:/etc/profile

scp -r jdk1.8.0_151 [email protected]:`pwd`

環境變數生效(所有主機)

source /etc/profile

測試,命令列直接鍵入java,出現以下情況及完成jdk安裝

 

2.   製作本地源(ambari節點上進行即可)

2.1安裝Apache HTTP伺服器

2.1.1安裝HTTP伺服器

允許http服務通過防火牆(永久)

yum install httpd -y

firewall-cmd --add-service=http

firewall-cmd --permanent --add-service=http

2.1.2 Apache服務自動啟動

新增Apache服務到系統層隨系統自動啟動

systemctl start httpd.service

systemctl enable httpd.service

2.2安裝本地源製作工具

yum install yum-utils createrepo -y

2.3安裝httpd網站

2.3.1建立目錄ambari

在httpd網站根目錄(/var/www/html)下建立目錄ambari

cd /var/www/html/

mkdir ambari

cd /var/www/html/ambari

mkdir HDP-UTILS

2.3.2上傳檔案

上傳HDP-UTILS-1.1.0.21-centos7.tar.gz,HDP-2.6.3.0-centos7-rpm.tar.gz,ambari-2.6.0.0-centos7.tar.gz到cd /var/www/html/ambari/目錄下

2.3.3解壓

1、在/var/www/html/ambari/目錄下解壓

tar -zxvf ambari-2.6.0.0-centos7.tar.gz

tar -zxvf HDP-2.6.3.0-centos7-rpm.tar.gz

 

mv HDP-UTILS-1.1.0.21-centos7.tar.gz /var/www/html/ambari/HDP-UTILS/

cd /var/www/html/ambari/HDP-UTILS/

tar -zxvf HDP-UTILS-1.1.0.21-centos7.tar.gz

mv HDP-UTILS-1.1.0.21-centos7.tar.gz /var/www/html/ambari/

 

 

2.3.4檢視httpd網站

使用links命令(yum install -y links)或者瀏覽器訪問

links命令:

links http://192.168.3.133/ambari/

瀏覽器:

 

 

2.4配置本地源

將ambari.repo,hdp.repo上傳到/etc/yum.repos.d/目錄下

2.4.1配置ambari.repo

(url地址為解壓檔案中的路徑)

修改baseurl為:

baseurl=http://192.168.3.133/ambari/ambari/centos7/2.6.0.0-267

修改gpgkey為:

gpgkey=http://192.168.3.133/ambari/ambari/centos7/2.6.0.0-267/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins

 

 

檔案內容如下:

#VERSION_NUMBER=2.6.0.0

[ambari-2.6.0.0]

name=ambari Version - ambari-2.6.0.0

baseurl=http://192.168.200.10/ambari/ambari/centos7/2.6.0.0-267

gpgcheck=0

gpgkey=http://192.168.200.10/ambari/ambari/centos7/2.6.0.0-267/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins

enabled=1

priority=1

 

2.4.2配置hdp.repo

修改HDP-2.6.3.0下baseurl為:

baseurl=http://192.168.3.133/ambari/HDP/centos7/2.6.3.0-235

修改HDP-2.6.3.0下gpgkey為:

gpgkey=http://192.168.3.133/ambari/HDP/centos7/2.6.3.0-235/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins

 

修改HDP-UTILS-1.1.0.21下baseurl為:(注意,若版本號不一致,需要更改為當前版本號)

baseurl=http://192.168.3.133/ambari/HDP-UTILS/

修改HDP-UTILS-1.1.0.21下gpgkey為:

gpgkey=http://192.168.3.133/ambari/HDP-UTILS/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins

 

檔案內容如下:

#VERSION_NUMBER=2.6.3.0-235

[HDP-2.6.3.0]

name=HDP Version - HDP-2.6.3.0

baseurl=http://192.168.200.10/ambari/HDP/centos7/2.6.3.0-235

gpgcheck=0

gpgkey=http://192.168.200.10/ambari/HDP/centos7/2.6.3.0-235/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins

enabled=1

priority=1

 

[HDP-UTILS-1.1.0.21]

name=HDP-UTILS-1.1.0.21

baseurl=http://192.168.200.10/ambari/HDP-UTILS/

gpgcheck=0

gpgkey=http://192.168.200.10/ambari/HDP-UTILS/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins

enabled=1

priority=1

2.4.3移動檔案

(如果上傳位置不在上述地址,需要將配置完成後的ambari.repo以及hdp.repo檔案移動到/etc/yum.repos.d/下)

mv ambari.repo /etc/yum.repos.d/

mv hdp.repo/etc/yum.repos.d/

依次執行以下命令:

yum clean all

yum list update

yum makecache

yum repolist

2.5安裝Mysql資料庫

Ambari安裝會將安裝等資訊寫入資料庫,建議使用自己安裝的Mysql資料庫,也可以不安裝而使用預設資料庫PostgreSQL

安裝完成後,使用root使用者登入執行以下命令:

3.5 安裝Mysql資料庫

  Ambari安裝會將安裝等資訊寫入資料庫,建議使用自己安裝的MySQL資料庫,也可以不安裝而使用預設資料庫PostgreSQL。

  Mysql資料庫安裝過程如下:

  3.5.1. 下載mysql的repo源(CentOS 7.2的yum源中預設沒有mysql,要先下載mysql的repo源)

 

 wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm

  3.5.2. 安裝mysql57-community-release-el7-8.noarch.rpm包

 

rpm -ivh mysql57-community-release-el7-8.noarch.rpm  --nodeps --force

  安裝這個包後,會獲得兩個mysql的yum repo源:

 

/etc/yum.repos.d/mysql-community.repo

 

3/etc/yum.repos.d/mysql-community-source.repo

yum -y remove mariadb-libs

 

  3.5.3.安裝mysql

 yum install mysql-server

  3.5.4. 啟動mysql服務

  檢視MySQL服務是否已啟動:

 service mysqld status

  啟動服務:

systemctl start mysqld

 

  3.5.5. 重置root密碼

  MySQL5.7會在安裝後為root使用者生成一個隨機密碼,而不是像以往版本的空密碼。 可以安全模式修改root登入密碼或者用隨機密碼登入修改密碼。下面用隨機密碼方式

MySQL為root使用者生成的隨機密碼通過mysqld.log檔案可以查詢到:

grep 'temporary password' /var/log/mysqld.log

  修改root使用者密碼:(MySQL的密碼策略比較複雜,過於簡單的密碼會被拒絕)

 

mysql -u root -p

 

set global validate_password_policy=0;

set global validate_password_length=4;

set PASSWORD=PASSWORD('123456');

mysql> Enter password: (輸入剛才查詢到的隨機密碼)

mysql> update mysql.user set authentication_string=password('1234') where user='root'

mysql> exit

用root新密碼登入:

 

1mysql -u root -p 1234

2.5.1建立ambari資料庫

建立ambari資料庫以及ambariuser資料庫使用者並授權

create database ambari character set utf8 ; 

CREATE USER 'ambariuser'@'%'IDENTIFIED BY '123456';

GRANT ALL PRIVILEGES ON *.* TO 'ambariuser'@'%';

FLUSH PRIVILEGES;

GRANT ALL PRIVILEGES ON *.* TO 'ambari'@'%';

FLUSH PRIVILEGES;

 

2.5.2建立hive資料庫

建立hive資料庫以及hiveuser資料庫使用者並授權

create database hive character set utf8 ; 

CREATE USER 'hiveuser'@'%'IDENTIFIED BY '123456';

GRANT ALL PRIVILEGES ON *.* TO 'hiveuser'@'%';

FLUSH PRIVILEGES;

GRANT ALL PRIVILEGES ON *.* TO 'hive'@'%';

FLUSH PRIVILEGES;

如果需要安裝其他服務如Oozie,則建立相應的資料庫及使用者

2.5.3安裝mysql jdbc驅動

yum install mysql-connector-java -y

3.   安裝Ambari

3.1安裝Ambari2.6.0.0

3.1.1安裝ambari服務

yum install -y ambari-server

3.1.2執行安裝

ambari-server setup

  1. 檢查SELinux是否關閉,如果關閉不用操作

Using python  /usr/bin/python

Setup ambari-server

Checking SELinux...

SELinux status is 'disabled'

  1. 進入自定義設定,輸入:y

Customize user account for ambari-server daemon [y/n] (n)? y

3.      輸入ambari-server賬號,輸入:ambari(ambari主機上建立的使用者)

Enter user account for ambari-server daemon (root):ambari

  1. 選擇JDK,輸入:3

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

  1. 鍵入JDK PATH,輸入:/usr/local/jdk1.8.0_151

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/local/jdk1.8.0_151

Validating JDK on Ambari Server...done.

  1. 資料庫配置,輸入:y

Configuring database...

Enter advanced database configuration [y/n] (n)? y

  1. 選擇資料庫,輸入:3

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

  1. 資料庫具體配置資訊,如果和預設相同直接回車(下面的IP代表資料庫所在的節點)

Hostname (localhost): 192.168.3.212

Port (3306):

Database name (ambari):

Username (ambari): ambariuser

Enter Database Password (bigdata): 123456

Re-enter password: 123456

Configuring ambari database...

  1. 啟動Ambari服務前,需要將Ambari的sql指令碼匯入資料庫

用Ambari使用者(上面設定的使用者,無密碼)登入mysql

mysql -u ambari -p

use ambari

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

  1. 啟動Ambari

ambari-server start

4.   叢集配置

4.1登入          

瀏覽器訪問http://192.168.3.133:8080/ 使用者名稱:admin 密碼:admin

 

 

4.2新增叢集         

4.2.1叢集配置

點選Launch Install Wizard按鈕進行叢集配置

 

4.2.2設定叢集名稱

 

4.2.3設定HDP安裝源

選擇HDP2.6.3.0,使用Use Local Repository,選擇redhat7,Base URL內容填寫與HDP.repo中的URL地址一致

 

4.2.4設定叢集節點

Target Hosts中填入需要加入叢集的主機名

點選“瀏覽”按鈕,上傳id_rsa檔案(該檔案需要從192.168.3.133節點中/root/.ssh/目錄中獲取)

 

4.2.5主機確認

 

K可能遇到的問題;

檢視 openssl 版本:

 

    [[email protected] ~]# openssl version

    OpenSSL 1.0.2k-fips  26 Jan 2017

 

    [[email protected] ~]# rpm -qa | grep openssl

    openssl-libs-1.0.2k-12.el7.x86_64

    openssl-1.0.2k-12.el7.x86_64

 

 

如果低於 openssl-1.0.1e-16.el6.x86_64 版本,則需要更新到 openssl-1.0.1e-16.el6.x86_64 及以上版本

 

檢視 Python 版本:

    [[email protected] ~]# python -V

    Python 2.7.5

如果低於 Python 2.7 版本,則升級 Python 2.7 及以上版本。

編輯 /etc/python/cert-verification.cfg 配置檔案,將 [https] 節的 verify 項設為禁用:

    [[email protected] ~]# vi /etc/python/cert-verification.cfg

    # Possible values are:

    # 'enable' to ensure HTTPS certificate verification is enabled by default

    # 'disable' to ensure HTTPS certificate verification is disabled by default

    # 'platform_default' to delegate the decision to the redistributor providing this particular Python version

    # For more info refer to https://www.python.org/dev/peps/pep-0493/

    [https]

    verify=disable

儲存退出。

編輯 /etc/ambari-agent/conf/ambari-agent.ini 配置檔案,在 [security] 節部分,確保設定如下兩個值,其它值保持不變:

    [[email protected] ~]# vi /etc/ambari-agent/conf/ambari-agent.ini

    [security]

    ssl_verify_cert=0

    force_https_protocol=PROTOCOL_TLSv1_2

儲存退出,重啟 ambari-agent

    [[email protected] ~]# ambari-agent restart

重新執行確認主機步驟(Confirm Hosts),即可通過確認主機並完成註冊。

 

 

禁用selinux

檢視當前SELinux狀態

/usr/sbin/sestatus

在當前終端禁用SELinux

setenforce 0

永久禁用SELinux

vim /etc/selinux/config

#確認SELINUX為禁用狀態

 

      SELINUX=disabled

   重啟計算機

      sudo reboot

2禁用PackageKit

 

通常在centosredhat中為開啟

vim /etc/yum/pluginconf.d/refresh-packagekit.conf

 #確認packagekit為禁用狀態

enabled=0

檢查UMASK

檢查系統UMASK

umask

設定當前UMASK

umask 0022

永久生效

echo umask 0022 >> /etc/profile

八、安裝Ambari-agent

線上安裝只需要執行如下命令便可

yum install ambari-agent

4.2.6選擇需要安裝的服務

 

4.2.7配置Slaves和Clients節點

(日誌與資料資訊統一儲存在/Data/work/local目錄下)

 

 

 

4.2.8使用者服務配置

 

 

 

 

4.2.9配置資訊確認

 

4.2.10安裝

 

 

 

4.2.11完成

 

 

5.   參考文件

http://blog.csdn.net/daiyutage/article/details/52210830

http://www.cnblogs.com/boyzgw/p/6525313.html