ambari使用最全面解析
本文由:binsoo獨自編寫,歡迎喜歡大數據的成員關注本專欄,作者知乎號就是微號。
1.ambari安裝準備
1.1 準備安裝包
安裝文件下載:
ambari地址:http://public-repo-1.hortonworks.com/ambari/centos7/2.x/updates/2.5.1.0/ambari-2.5.1.0-centos7.tar.gz
HDP地址:http://public-repo-1.hortonworks.com/HDP/centos7/2.x/updates/2.6.1.0/HDP-2.6.1.0-centos7-rpm.tar.gz
HDP-utils地址:http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.21/repos/centos7/HDP-UTILS-1.1.0.21-centos7.tar.gz
文件非常的大,所以不建議在線安裝。(沒有的,可以找binsoo拿,知乎號就是微號)
想了解最新版本信息,也下載地址.https://docs.hortonworks.com/
1.2 準備安裝環境
1.2.1 設置無密碼SSH: 在線文檔查看
Red Hat Linux上安裝使用SSH
配置root用戶的ssh登錄
1.2.2 添加DNS
編輯 /etc/hosts 文件
vi /etc/hosts
將做為安裝集群的機器全部加入到hosts文件中
1.2.3 編輯網路配置文件
vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=hu01
1.2.4 禁用防火牆
如果是CentOS 6
chkconfig iptables off 或 /etc/init.d/iptables stop
如果是CentOS 7
systemctl disable firewalld 或 service firewalld stop
1.2.5 安裝jdk
略(下載,然後直接解壓:tar -zvxf jdk-8u121-linux-x64.tar.gz -C /usr/java/)
安裝完之後,配置一下profile
vi /etc/profile
在裡面加如下:
##########java home##########
export JAVA_HOME=/usr/java/jdk-xxx
export PATH=$PATH:${JAVA_HOME}/bin
1.3 安裝ambari
1.3.1 使用本地源安裝時,先要安裝httpd,來搭建源地址
yum install httpd
(沒有網路怎麼辦,實際為下載對應的gz文件,解壓到路徑下.)
用命令,默認安裝的路徑為:
/var/www/下
1.3.2 配置本地源
上傳下載文件到192.168.1.218的root目錄下
準備以root用戶來進行安裝
(安裝時,最好已經放到相鄰伺服器中,方便複製文件)
scp ambari-2.5.1.0-centos7.tar.gz 192.168.1.218:/root
scp HDP-2.6.1.0-centos7-rpm.tar.gz 192.168.1.218:/root
scp HDP-UTILS-1.1.0.21-centos7.tar.gz 192.168.1.218:/root
解壓到 /var/www/html/ 目錄下
命令:
tar -zvxf /root/ambari-2.5.1.0-centos7.tar.gz -C /var/www/html/
tar -zvxf /root/HDP-2.6.1.0-centos7-rpm.tar.gz -C /var/www/html/
tar -zvxf /root/HDP-UTILS-1.1.0.21-centos7.tar.gz -C /var/www/html/HDP-UTILS-1.1.0.21/centos7
配置ambari.repo,相當於製作repo
修改內容:vi /etc/yum.repos.d/ambari.repo
配置httpd的配置文件
修改命令:vi /etc/httpd/conf/httpd.conf
啟動httpd服務
service httpd start
1.3.3 安裝命令
第1步:yum install ambari-server
原因是本地源,相當快下載與安裝的.
第2步:配置ambari
備註:提前安裝好JDK的版本,配置的時候需要,(要不,就是在線安裝).
命令:ambari-server setup
第3步:
輸入:3 為自定義配置jdk
第4步:
接下來是配置mysql資料庫:(要提前安裝好mysql資料庫,並提交準備好對應的mysql的訪問jar包,如:mysql-connector-java-5.1.38.jar)
以上安裝部署時,要根據提示,先執行/var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql文件,這個可以直接在資料庫中執行。
(回到資料庫處,先執行腳本,創建好表之後還可以進行)
配置完成
1.3.3 啟動ambari-server
1.3.4 查看日誌:
mysql的鏈接失敗,是因為配置的driver沒有設置正確.
修改如下:vi /etc/ambari-server/conf/ambari.properties
再次啟動,成功.
1.3.4 打開網頁:http://192.168.1.218:8080 直接到了安裝界面
下一步,配置節點,製作安裝源.
2.大數據組件可視化安裝過程:舉例zookeeper的安裝
2.1
2.2
根據自定義的安裝源,來修改內容如下:
2.3
主要填寫:
1.每行填寫一個host name,對應的是安裝集群的節點
2.提交配置的ssh的私密
填寫完成後
安裝過程時,報錯:
ERROR 2017-09-20 10:55:30,922 main.py:244 - Ambari agent machine hostname (localhost.localdomain) does not match expected ambari server hostname (fb01). Aborting registration. Please check hostname, hostname -f and /etc/hosts file to confirm your hostname is setup correctly
表示:你的hostname沒有修改。
另外,記得關閉防火牆
2.4
安裝ambari-agent 客戶端
2.5
操作:選中要安裝的版本組件。會涉及關聯校驗步驟。
2.6
在上一環節,只選中zookeeper提交後
這個環節,是選擇master
2.7-2.10都直接下一步就可以了
3.大數據組件api介面安裝過程
以zookeeper為例子:
3.1
使用post方式提交數據
url: http://192.168.1.220:8080/api/v1/clusters/amb/services
提交數據:{"ServiceInfo":{"service_name":"ZOOKEEPER"}}
目的:註冊服務名字,方便監控
3.2
使用put方式提交數據
url: http://192.168.1.220:8080/api/v1/clusters/amb
提交數據:(實際內容可以通過json工具查看一下,主要提交的就是配置文件)
[{"Clusters":{"desired_config":[{"type":"zoo.cfg","tag":"version1506065925604","properties":{"autopurge.purgeInterval":"24","autopurge.snapRetainCount":"30","clientPort":"2181","dataDir":"/hadoop/zookeeper","initLimit":"10","syncLimit":"5","tickTime":"3000"},"service_config_version_note":"Initial configurations for ZooKeeper"},{"type":"zookeeper-env","tag":"version1506065925604","properties":{"content":"
export JAVA_HOME={{java64_home}}
export ZOOKEEPER_HOME={{zk_home}}
export ZOO_LOG_DIR={{zk_log_dir}}
export ZOOPIDFILE={{zk_pid_file}}
export SERVER_JVMFLAGS={{zk_server_heapsize}}
export JAVA=$JAVA_HOME/bin/java
export CLASSPATH=$CLASSPATH:/usr/share/zookeeper/*
{% if security_enabled %}
export SERVER_JVMFLAGS="$SERVER_JVMFLAGS -Djava.security.auth.login.config={{zk_server_jaas_file}}"
export CLIENT_JVMFLAGS="$CLIENT_JVMFLAGS -Djava.security.auth.login.config={{zk_client_jaas_file}}"
{% endif %}","zk_log_dir":"/var/log/zookeeper","zk_pid_dir":"/var/run/zookeeper","zk_server_heapsize":"1024m","zk_user":"zookeeper"},"service_config_version_note":"Initial configurations for ZooKeeper"},{"type":"zookeeper-log4j","tag":"version1506065925604","properties":{"content":"
#
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
#
#
#
# ZooKeeper Logging Configuration
#
# DEFAULT: console appender only
log4j.rootLogger=INFO, CONSOLE, ROLLINGFILE
# Example with rolling log file
#log4j.rootLogger=DEBUG, CONSOLE, ROLLINGFILE
# Example with rolling log file and tracing
#log4j.rootLogger=TRACE, CONSOLE, ROLLINGFILE, TRACEFILE
#
# Log INFO level and above messages to the console
#
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.Threshold=INFO
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%d{ISO8601} - %-5p [%t:%C{1}@%L] - %m%n
#
# Add ROLLINGFILE to rootLogger to get log file output
# Log DEBUG level and above messages to a log file
log4j.appender.ROLLINGFILE=org.apache.log4j.RollingFileAppender
log4j.appender.ROLLINGFILE.Threshold=DEBUG
log4j.appender.ROLLINGFILE.File={{zk_log_dir}}/zookeeper.log
# Max log file size of 10MB
log4j.appender.ROLLINGFILE.MaxFileSize={{zookeeper_log_max_backup_size}}MB
# uncomment the next line to limit number of backup files
#log4j.appender.ROLLINGFILE.MaxBackupIndex={{zookeeper_log_number_of_backup_files}}
log4j.appender.ROLLINGFILE.layout=org.apache.log4j.PatternLayout
log4j.appender.ROLLINGFILE.layout.ConversionPattern=%d{ISO8601} - %-5p [%t:%C{1}@%L] - %m%n
#
# Add TRACEFILE to rootLogger to get log file output
# Log DEBUG level and above messages to a log file
log4j.appender.TRACEFILE=org.apache.log4j.FileAppender
log4j.appender.TRACEFILE.Threshold=TRACE
log4j.appender.TRACEFILE.File=zookeeper_trace.log
log4j.appender.TRACEFILE.layout=org.apache.log4j.PatternLayout
### Notice we are including log4js NDC here (%x)
log4j.appender.TRACEFILE.layout.ConversionPattern=%d{ISO8601} - %-5p [%t:%C{1}@%L][%x] - %m%n","zookeeper_log_max_backup_size":"10","zookeeper_log_number_of_backup_files":"10"},"service_config_version_note":"Initial configurations for ZooKeeper"},{"type":"zookeeper-logsearch-conf","tag":"version1506065925604","properties":{"component_mappings":"ZOOKEEPER_SERVER:zookeeper","content":"
{
"input":[
{
"type":"zookeeper",
"rowtype":"service",
"path":"{{default(/configurations/zookeeper-env/zk_log_dir, /var/log/zookeeper)}}/zookeeper*.log"
}
],
"filter":[
{
"filter":"grok",
"conditions":{
"fields":{"type":["zookeeper"]}
},
"log4j_format":"%d{ISO8601} - %-5p [%t:%C{1}@%L] - %m%n",
"multiline_pattern":"^(%{TIMESTAMP_ISO8601:logtime})",
"message_pattern":"(?m)^%{TIMESTAMP_ISO8601:logtime}%{SPACE}-%{SPACE}%{LOGLEVEL:level}%{SPACE}\\[%{DATA:thread_name}\\@%{INT:line_number}\\]%{SPACE}-%{SPACE}%{GREEDYDATA:log_message}",
"post_map_values": {
"logtime": {
"map_date":{
"target_date_pattern":"yyyy-MM-dd HH:mm:ss,SSS"
}
}
}
}
]
}","service_name":"Zookeeper"},"service_config_version_note":"Initial configurations for ZooKeeper"}]}}]
目的:將頁面配置的參數內容做為了欄位提交保存到資料庫,形成配置版本,其中version1506065925604為版本號。
3.3
使用post方式提交數據
url: http://192.168.1.220:8080/api/v1/clusters/amb/services?ServiceInfo/service_name=ZOOKEEPER
提交數據:{"components":[{"ServiceComponentInfo":{"component_name":"ZOOKEEPER_CLIENT"}},{"ServiceComponentInfo":{"component_name":"ZOOKEEPER_SERVER"}}]}
目的:向組件註冊名字,方便監控時名字對應
3.4
使用post方式提交數據
url: http://192.168.1.220:8080/api/v1/clusters/amb/hosts
提交數據:
2次數據提交如下:
第1次:
{"RequestInfo":{"query":"Hosts/host_name=fb02|Hosts/host_name=fb04|Hosts/host_name=fb03"},"Body":{"host_components":[{"HostRoles":{"component_name":"ZOOKEEPER_SERVER"}}]}}
第2次:
{"RequestInfo":{"query":"Hosts/host_name=fb04"},"Body":{"host_components":[{"HostRoles":{"component_name":"ZOOKEEPER_CLIENT"}}]}}
目的:指定需要安裝的節點
3.5
使用put方式提交數據
url: http://192.168.1.220:8080/api/v1/clusters/amb/services?ServiceInfo/service_name.in(ZOOKEEPER)
提交數據:
{"RequestInfo":{"context":"Install Services","operation_level":{"level":"CLUSTER","cluster_name":"amb"}},"Body":{"ServiceInfo":{"state":"INSTALLED"}}}
目的:發起安裝
如要其它組件的安裝api文檔,請聯作者。
4.ambari的api使用說明
安裝api:
http://192.168.1.220:8080/api/v1/clusters/amb/services
監控api:
http://192.168.1.220:8080/api/v1/clusters/amb/hosts/fb02?fields=metrics/cpu
1.內存
http://192.168.1.220:8080/api/v1/clusters/amb/hosts/fb02?fields=metrics/memory
2.cpu
http://192.168.1.220:8080/api/v1/clusters/amb/hosts/fb02?fields=metrics/cpu
3.磁碟
http://192.168.1.220:8080/api/v1/clusters/amb/hosts/fb02?fields=metrics/disk
This is a premium name
沒有,只有cpu等待io 叫 wio,在cpu的api里有數據
5.網路
http://192.168.1.220:8080/api/v1/clusters/amb/hosts/fb02?fields=metrics/network
6.日誌查看
7.應用狀態
http://192.168.1.220:8080/api/v1/clusters/amb/requests?fields=Requests/request_status,Requests/request_context
其中?後面為過濾條件,/後面是取的欄位,多個欄位用,分隔來取
http://192.168.1.220:8080/api/v1/clusters/amb/requests取的每個hosts中的
8.所有組件安裝情況 與 當前情況
http://192.168.1.220:8080/api/v1/clusters/amb/components/?fields=ServiceComponentInfo/service_name,ServiceComponentInfo/category,ServiceComponentInfo/installed_count,ServiceComponentInfo/started_count,ServiceComponentInfo/init_count,ServiceComponentInfo/install_failed_count,ServiceComponentInfo/unknown_count,ServiceComponentInfo/total_count,ServiceComponentInfo/display_name,host_components/HostRoles/host_name&minimal_response=true&_=1506411896857
9.已經安裝的組件安裝配置情況
http://192.168.1.220:8080/api/v1/clusters/amb/
下面有:
1類:Clusters
對應:http://192.168.1.220:8080/api/v1/clusters/amb?fields=Clusters
1.1 health_report
1.2 desired_configs
1.3 desired_service_config_versions
2類: alerts_summary
對應:http://192.168.1.220:8080/api/v1/clusters/amb?fields=alerts_summary
3類: alerts_summary_hosts
對應:http://192.168.1.220:8080/api/v1/clusters/amb?fields=alerts_summary_hosts
4類: config_groups
對應:http://192.168.1.220:8080/api/v1/clusters/amb?fields=config_groups
5類:kerberos_descriptors
對應:http://192.168.1.220:8080/api/v1/clusters/amb?fields=kerberos_descriptors
6類:hosts
對應:http://192.168.1.220:8080/api/v1/clusters/amb?fields=hosts
7類:configurations
對應:http://192.168.1.220:8080/api/v1/clusters/amb?fields=configurations
8類:services
對應:http://192.168.1.220:8080/api/v1/clusters/amb?fields=services
9類:requests
對應:http://192.168.1.220:8080/api/v1/clusters/amb?fields=requests
10類:alerts
對應:http://192.168.1.220:8080/api/v1/clusters/amb?fields=alerts
11類:stack_versions
對應:http://192.168.1.220:8080/api/v1/clusters/amb?fields=stack_versions
12類:service_config_versions
對應:http://192.168.1.220:8080/api/v1/clusters/amb?fields=service_config_versions
13類:alert_definitions
對應:http://192.168.1.220:8080/api/v1/clusters/amb?fields=alert_definitions
5.ambari的框架解析
待續!!!
6.ambari引入的開源包
待續!!!!!!
7.ambari的二次開發
待續!!!!!!!!!
推薦閱讀:
※怎樣理解spark中的partition和block的關係?
※國內哪些互聯網公司在用mesos,哪些互聯網公司在用yarn,兩者前景如何?
※邏輯回歸演算法原理及Spark MLlib調用
※Flume全解析!全!全!全!