及官方文檔: https://docs.hortonworks.com/HDPDocuments/Ambari-2.4.2.0/bk_ambari-installation/content/download_the_ambari_repo.html
版本兼容性可參考:
https://docs.hortonworks.com/
(官網)
一:基礎環境配置
1、所有節點關閉防火牆及selinux
systemctl stop firewalld
systemctl disable friewalld
setenforce 0
sed -i ‘s/SELINUX=enforcing/SELINUX=disabled/g’ /etc/selinux/config
2、修改主機名配置hosts文件 及 主節點到各個節點免密登陸
/etc/hosts /etc/hostname
hostname hadoop-dn02
bash
for i in {1..35};do scp /etc/hosts hadoop-dn$i:/etc;done
for i in {45..80};do ssh root@10.205.225.$i “hostnamectl set-hostname hostname ;“done
”
hostnamectl set-hostname hostname
3、打開文件和進程限制,內核參數配置
/etc/security/limits.conf /etc/security/limits.d/20-nproc.conf /etc/sysctl.conf
4、創建你想要安裝的應用的數據目錄(可選)
(一般來說在安裝的時候ambari會自動創建)
mkdir /data/hadoop
mkdir /data/hbase
mkdir /data/zookeeper
5、自建 JDK(所有節點)
(1)卸載自帶JDK
rpm -qa |grep java |xargs -i rpm -e --nodeps {}
(2)安裝1.8 版本JDK
6、時間同步配置
RHEL7開始默認已安裝chrony,而沒有安裝ntpd.
chrony兼容ntpdate,客戶端可以使用ntpdate手動同步時間
systemctl restart chronyd.service
systemctl enable chronyd.service
服務端:
#vim /etc/chrony.conf --修改配置文件
#server 0.rhel.pool.ntp.org iburst --注釋這4行,由於是內網環境,所以無法跟外部時間服務器進行時間同步。
#server 1.rhel.pool.ntp.org iburst
#server 2.rhel.pool.ntp.org iburst
#server 3.rhel.pool.ntp.org iburst
server 127.127.1.0 iburst --添加這一行,表示與本機同步時間
# Allow NTP client access from local network.
allow 192.168.100.0/24 --允許哪些服務器到這台服務器來同步時間
# Serve time even if not synchronized to any NTP server.
local stratum 10 # 默認不開啟,意思是,即使服務端沒有同步到精確的網絡時間,也允許向客戶端同步不精確的時間。
客戶端:
vim /etc/chrony.conf
#server 0.rhel.pool.ntp.org iburst --注釋這4行,由於是內網環境,所以無法跟外部時間服務器進行時間同步。
#server 1.rhel.pool.ntp.org iburst
#server 2.rhel.pool.ntp.org iburst
#server 3.rhel.pool.ntp.org iburst
server 192.168.1.3 iburst --添加這一行,與客戶端同步
7、配置本地yum源,安裝http (主服務器)
上傳 相應版本鏡像 ,掛載
配置本地源 /etc/yum.repos.d/local.repo
yum clean all ;yum repolist
yum -y install httpd ;systemctl enable httpd
8、下載ambari HDP HDP-UTILS 包 並解壓至 /var/www/html/下
9、制作本地源
(1)安裝本地源制作相關工具(主服務器)
yum install yum-utils createrepo yum-plugin-priorities -y
(2)制作ambari hdp hdp-utils源包(各個節點)
主服務器上配置 ambari 和hdp的網絡源
進入/var/www/html/ 中,進入 ambari各個包中執行 (或者創建hdp文件夾在hdp文件夾下執行)
createrepo ./
cd /etc/yum.repos.d
vim ambari.repo
[ambari-2.7.3.0] name=ambari Version - ambari-2.7.3.0 baseurl=http://192.168.200.10/hdp/ambari/centos7/2.7.3.0 gpgcheck=0 enabled=1 [HDP-3.1.0.0] name=HDP Version - HDP-3.1.0.0 baseurl=http://192.168.200.10/hdp/HDP/centos7/3.1.0.0 gpgcheck=0 enabled=1 [HDP-UTILS-1.1.0.22] name=HDP-UTILS Version - HDP-UTILS-1.1.0.22 baseurl=http://192.168.200.10/hdp/HDP-UTILS/centos7/1.1.0.22 gpgcheck=0 enabled=1
vim hdp-gpl.repo
[HDP-GPL-3.1.0.0] name=HDP-GPL Version - HDP-GPL-3.1.0.0 baseurl=http://192.168.200.10/hdp/HDP-GPL/centos7/3.1.0.0 gpgcheck=0 enabled=1
yum celan all;yum makecache;yum repolist
配置完成后分發至各個節點

二:安裝ambari-server
1、首先 yum -y install ambari-server 下載ambari-server
然后安裝mysql5.7
2 安裝好MySQL之后的配置:創建ambari-server需要用到的庫表
create database ambari character set utf8 ;
CREATE USER 'ambari'@'%'IDENTIFIED BY 'ambari';
GRANT ALL PRIVILEGES ON *.* TO 'ambari'@'%';
FLUSH PRIVILEGES;
導入ambari需要的表
use ambari
source /var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql
show tables;

如果還要搭其他服務 比如hive
create database hive character set utf8 ;
CREATE USER 'hive'@'%'IDENTIFIED BY 'hive';
GRANT ALL PRIVILEGES ON *.* TO 'hive'@'%';
FLUSH PRIVILEGES;
建立mysql與ambari-server的連接
網上下載mysql-connector-java-8.0.18.jar放到root文件下,注意目錄必須按照下面規定得否則無法啟動
yum -y install mysql-connector-java
mkdir /usr/share/java mv mysql-connector-java-8.0.18.jar mysql-connector-java.jar cp mysql-connector-java.jar /usr/share/java/mysql-connector-java.jar cp /usr/share/java/mysql-connector-java.jar /var/lib/ambari-server/resources/mysql-jdbc-driver.jar
vim /etc/ambari-server/conf/ambari.properties
添加
server.jdbc.driver.path=/usr/share/java/mysql-connector-java.jar
安裝hive的話一定要執行(不安裝也可以執行)
ambari-server setup --jdbc-db=mysql --jdbc-driver=/usr/share/java/mysql-connector-java.jar
3、開始配置ambari
[root@master ~]# 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] Custom JDK
==============================================================================
Enter choice (1): 3
如果上面選擇3自定義JDK,則需要設置JAVA_HOME。輸入:/usr/local/java/jdk1.8.0_121
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: /home/tools/jdk1.8.0_121
Validating JDK on Ambari Server...done.
Completing setup...
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...
(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):
Port (3306):
Database name (ambari):
Username (ambari):
Enter Database Password (bigdata):ambari
Re-Enter password: ambari
Should ambari use existing default jdbc /usr/share/java/mysql-connector-java.jar [y/n] (y)? y
Configuring remote database connection properties...
(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-setup有一個略過GPL認證的選項!!!!(安裝LZO需要)
啟動
ambari-server start
chkconfig --add ambari-server
啟動日志查看
tail -f /var/log/ambari-server/ambari-server.log
所有節點安裝ambari-agent
[root@master ~]# yum -y install ambari-agent
啟動命令 ambari-agent start /status/ stop
[root@master ~]# chkconfig --add ambari-agent
chkconfig --add ambari-server
然后再進入ambari-server管理界面
賬號密碼默認都為admin
日志位置位於 /var/log/ambari-*
這兩個包是在安裝集群的時候需要的(在部署集群之前批量分發到每個節點rpm安裝)
https://files.cnblogs.com/files/zgngg/libtripc.zip
rpm -ivh libtirpc-0.2.4-0.16.el7.x86_64.rpm libtirpc-devel-0.2.4-0.16.el7.x86_64.rpm
三、安裝配置部署HDP集群
1、訪問Ambari web頁面
默認端口8080,Username:admin;Password:admin;http://192.168.0.171:8080

2、開始集群安裝

3、配置集群名稱

4、版本選擇、添加本地源鏈接
Enable Ambari Server to download and install GPL Licensed LZO packages [y/n] (n)? y
GPL認證 選擇是在前面 ambari-setup 中選擇的 ,就會出現GPL的源配置

tips:搭建完成后如有源包位置變動、需要修改配置,在
admin → Manage Ambari → Clusters 下的 Versions → 點擊右側出來界面的版本號,進入即可看到

5、集群目前擁有的節點和密鑰配置 id_rsa

6、主機確認
注意此處的檢查信息,一定要為綠色通過,不然后續可能會有問題
如果是黃色或者紅色,點進去看具體節點問題,排查解決后,重新檢查

7、選擇需要安裝的組件

8、資源節點分配

9、分配從屬和客戶端

10、定制服務
配置 路徑 、資源等(資源分配根據集群資源)


11、安裝完成后下一步則進入監控界面


五:HA搭建
進入 ambari界面上 ,選擇hdfs服務 ,最左側actions 點開,會有一個 HA namenode的選項,點進去之后,類似前面創建步驟 創建namenode HA即可

兩個NameNode為了數據同步,會通過一組稱作
JournalNodes的獨立進程進行相互通信。當active狀態的NameNode的命名空間有任何修改時,會告知大部分的JournalNodes進程。standby狀態的NameNode有能力讀取JNs中的變更信息,並且一直監控edit log的變化,把變化應用於自己的命名空間。standby可以確保在集群出錯時,命名空間狀態已經完全同步了。
