概述
Ambari是Hortonworks開源的Hadoop平台的管理軟件,具備Hadoop組件的安裝、管理、運維等基本功能,提供Web UI進行可視化的集群管理,簡化了大數據平台的安裝、使用難度。
功能列表
操作級別:
- Host Level Action(機器級別的操作)
- Component Level Action(模塊級別的操作)
基於角色的用戶管理,角色分為:
- Cluster User。 查看集群和Service的信息,如配置、service狀態、健康狀態等。Read-only
- Service Operator。 能夠操作Service的生命周期,如啟動,停止,也可以進行一些如Rebalance DataNode和YARN refresh的操作
- Service Administrator。 在Service Operator的基礎上增加了配置service,移動NameNode,啟用HA等操作
- Cluster Operator。 在Service Administrator的基礎上增加了對hosts和components的操作,如增加,刪除等
- Cluster Administrator。集群的超級管理員,擁有無上的權利,可以操作任何組件。
Dashboard 監控 :
-
Roll Start功能。根據Service的依賴關系,按照一定的順序啟動每個Service。比如HBase依賴HDFS和Zookeeper,Ambari會先啟動HDFS和Zookeeper,之后啟動HBase。
-
關鍵的運維指標(metrics)–metrics 是“度量,指標”的意思
-
在左側的 Service 列表,中間部分是 Service 的模塊(Component)信息,也就是該 Service 有哪些模塊及其數目。右上角有個 Service Action 的按鈕,包括service的啟動、停止、刪除等操作。
-
Quick links(導向組件原生管理界面)
- NameNode UI、ResourceManage UI、HBase Master UI
- HDFS的NameNode的logs
- YARN的ResourceManage 的logs
- Hbase的logs
Alert介紹:
- Alert 告警級別 Status:
OK 、Warning、Critical、Unknown、None - Alert 告警類型:
WEB、Port、Metric、Aggregate 和 Script - Ambari 中的 Alert 類型對比
類型 | 用途 | 告警級別 | 閥值是否可配置 | 單位 |
---|---|---|---|---|
PORT | 用來監測機器上的一個端口是否可用 | OK, WARN, CRIT | 是 | 秒 |
METRIC | 用來監測 Metric 相關的配置屬性 | OK, WARN, CRIT | 是 | 變量 |
AGGREGATE | 用於收集其他某些 Alert 的狀態 | OK, WARN, CRIT | 是 | 百分比 |
WEB | 用於監測一個 WEB UI(URL)地址是否可用 | OK, WARN, CRIT | 否 | 無 |
SCRIPT | Alert 的監測邏輯由一個自定義的 python 腳本執行 | OK, CRIT | 否 | 無 |
一、環境准備
1.版本介紹
Centos7
JDK1.8.0_212
Mysql5.7.25
Ambari2.6.2.2
HDP-2.6.5.0-292
HDP-GPL-2.6.5.0
HDP-UTILS-1.1.0.22
2.配置hosts
修改/etc/hosts
文件,將hosts文件拷貝至其他節點
xxx1 ambari
xxx2 nname1
xxx3 nname2
xxx4 dnode1
xxx5 dnode2
xxx6 dnode3
xxx7 dnode4
xxx8 dnode5
xxx9 dnode6
3.配置SSH
執行ssh_auto.sh
腳本,自動創建秘鑰,發送秘鑰到其他節點
#!/bin/bash
set -e
#所需變量
#取得集群的所有主機名,這里需要注意:/etc/hosts配置的IP和主機名只能用一個空格分割
hostList=$(cat /etc/hosts | tail -n +2 | cut -d ' ' -f 2)
pingCount=5
logPre=TDP
#服務器密碼
passwd=xxxx
set timeout 60
#秘鑰生成函數
ssh-keygen(){
echo "======>$host ssh-keygen... \n"
/usr/bin/expect <<EOF
spawn ssh-keygen
expect {
"Enter file in which to save the*" { send "\r"; exp_continue}
"Overwrite*" { send "n\r" ; exp_continue}
"Enter passphrase*" { send "\r"; exp_continue}
"Enter same passphrase again:" { send "\r" ; exp_continue}
}
EOF
}
#拷貝公鑰函數
ssh-copy-id(){
echo "======>$host ssh-copy-id... \n"
/usr/bin/expect <<EOF
spawn ssh-copy-id $host
expect {
"*yes/no*" {send "yes\r" ; exp_continue}
"*password*" {send "$passwd\r" ; exp_continue}
}
EOF
}
ssh-keygen
for host in $hostList
do
echo "----------------$host-----------------"
#檢測主機的連通性
unPing=$(ping $host -c $pingCount | grep 'Unreachable' | wc -l)
if [ "$unPing" == "$pingCount" ]; then
echo -e "$logPre======>$host is Unreachable,please check '/etc/hosts' file"
continue
fi
echo "$logPre======>$host "
ssh-copy-id $host
echo "$logPre======>$host is done! "
done
wait
echo "------hosts done--------"
4.配置firewall&selinux
配置防火牆需要開放的端口
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --zone=public --add-port=1024-65535/tcp --permanent
firewall-cmd --reload
firewall-cmd --list-all
修改/etc/selinux/config
配置文件,永久關閉selinux
sed -i "s/^SELINUX=.*$/SELINUX=disabled/" /etc/selinux/config
修改完后重啟系統,查看selinux
sestatus
5.配置時間同步
安裝ntp服務
yum install -y ntp
開啟ntp服務
systemctl start ntpd
開啟開機自啟ntp服務
systemctl enable ntpd
修改時區
timedatectl set-timezone Asia/Shanghai
6.安裝JDK
解壓安裝
tar -xvf jdk-8u112-linux-x64.tar.gz -C /opt/
連接軟連接
ln -s jdk1.8.0_112/ jdk
配置環境變量
sed -i '$a \export JAVA_HOME=/opt/jdk\nexport JAVA_BIN=$JAVA_HOME/bin\nexport CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/tools.jar\nexport PATH=.:$JAVA_BIN:$PATH' /etc/profile
重載環境變量
source /etc/profile
查看java版本
java -version
7.安裝mysql
解壓到指定目錄
tar -xzvf mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz -C /opt/server/
移動並修改文件名
mv /opt/server/mysql-5.7.25-linux-glibc2.12-x86_64 /usr/local/mysql
創建數據倉庫目錄
mkdir -p /opt/server/mysql/data
新建mysql用戶組
groupadd mysql
新建msyql用戶禁止登錄shell
useradd -r -s /sbin/nologin -g mysql mysql -d /usr/local/mysql
改變目錄屬有者
chown -R mysql:mysql /usr/local/mysql
chown -R mysql:mysql /opt/server/mysql
進入/usr/local/mysql
目錄,配置mysql參數
bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/opt/server/mysql/data
上邊命令執行完成后,會生成mysql的臨時密碼,要注意!!!
bin/mysql_ssl_rsa_setup --datadir=/opt/server/mysql/data
修改系統配置文件
cd /usr/local/mysql/support-files
cp mysql.server /etc/init.d/mysql
sed -i "s/^basedir=.*$/basedir=/usr/local/mysql/" /etc/init.d/mysql
sed -i "s/^datadir=.*$/datadir=/opt/server/mysql/data/" /etc/init.d/mysql
建立軟連接
ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
啟動mysql
/etc/init.d/mysql start
登錄mysql
mysql -hlocalhost -uroot -p
修改用戶密碼並授權
mysql> set password=password('root');
mysql> grant all privileges on *.* to 'root'@'%' identified by 'root';
mysql> flush privileges;
mysql> exit;
配置mysql開機自啟
chmod 755 /etc/init.d/mysql
chkconfig --add mysql
chkconfig --level 345 mysql on
8.配置本地yum源
8.1安裝httpd服務
安裝httpd
yum -y install httpd
啟動服務
systemctl start httpd
開機自啟
systemctl enable httpd
8.2制作本地倉庫
下載ambri&hdp包
wget -O /var/www/html/ambari-2.6.2.2-centos7.tar.gz http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.6.2.2/ambari-2.6.2.2-centos7.tar.gz
wget -O /var/www/html/HDP-2.6.5.0-centos7-rpm.tar.gz http://public-repo-1.hortonworks.com/HDP/centos7/2.x/updates/2.6.5.0/HDP-2.6.5.0-centos7-rpm.tar.gz
wget -O /var/www/html/HDP-UTILS-1.1.0.22-centos7.tar.gz http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.22/repos/centos7/HDP-UTILS-1.1.0.22-centos7.tar.gz
wget -O /var/www/html/HDP-GPL-2.6.5.0-centos7-gpl.tar.gz http://public-repo-1.hortonworks.com/HDP-GPL/centos7/2.x/updates/2.6.5.0/HDP-GPL-2.6.5.0-centos7-gpl.tar.gz
將包進行解壓
tar xvf ambari-2.6.2.2-centos7.tar.gz
tar xvf HDP-2.6.5.0-centos7-rpm.tar.gz
tar xvf HDP-UTILS-1.1.0.22-centos7.tar.gz
tar xvf HDP-GPL-2.6.5.0-centos7-gpl.tar.gz
修改文件,將下圖中的5個文件中yum源文件地址都改為本地搭建的yum源地址
8.3配置本機yum源
下載本地ambari&hdp的yum源文件
wget -O /etc/yum.repos.d/ambari.repo http://host/ambari/centos7/2.6.2.2-1/ambari.repo
wget -O /etc/yum.repos.d/hdp.repo http://host/HDP/centos7/2.6.5.0-292/hdp.repo
wget -O /etc/yum.repos.d/hdp.gpl.repo http://host/HDP-GPL/centos7/2.6.5.0-292/hdp.gpl.repo
8.4附加
下載官方ambari&hdp的yum源文件
wget -O /etc/yum.repos.d/ambari.repo http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.6.2.2/ambari.repo
wget -O /etc/yum.repos.d/hdp.repo http://public-repo-1.hortonworks.com/HDP/centos7/2.x/updates/2.6.5.0/hdp.repo
wget -O /etc/yum.repos.d/hdp.gpl.repo http://public-repo-1.hortonworks.com/HDP-GPL/centos7/2.x/updates/2.6.5.0/hdp.gpl.repo
清除yum緩存
yum clean all
重新建立緩存
yum makecache
9.安裝ambari
安裝ambari-server
yum install ambari-server -y
配置ambari數據庫
mysql> create database ambari default charset='utf8';
mysql> grant all privileges on ambari.* to 'ambari'@'%' identified by 'ambari';
mysql> flush privileges;
mysql> use ambari;
mysql> source /var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql;
配置ambari-server
ambari-server setup
##ambari-server配置項
Customize user account for ambari-server daemon [y/n] :n 是表示選擇root用戶
=============================================================================
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 :3 #是自己安裝的jdk,輸入/opt/jdk
Enable Ambari Server to download and install GPL Licensed LZO packages [y/n] :y
#y是代表用自己安裝的數據庫(n是代表ambari自帶的PostgreSQL,不建議)
Enter advanced database configuration [y/n]:y
==============================================================================
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 #是自己安裝的mysql
Hostname:localhost
Port:3306
Database name:ambari
Username:ambari
Enter Database Password:ambari
Re-enter Password:ambari
#"Ambari Server 'setup' completed successfully" 看到這句話就說明配置完成了
添加jdbc驅動
sed -i '$a \server.jdbc.driver.path=/usr/share/java/mysql-connector-java-5.1.37.jar' /etc/ambari-server/conf/ambari.properties
啟動ambari-server
ambari-server start
關閉ambari-server
ambari-server stop
查看ambari-server運行狀態
ambari-server status
登錄ambari web界面(admin/admin)
http://host:8080
附加:修改默認端口
client.api.port=