如何解決Ambari自定義服務(wù)啟動(dòng)成功后依舊顯示停止?fàn)顟B(tài)問(wèn)題

如何解決Ambari 自定義服務(wù)啟動(dòng)成功后依舊顯示停止?fàn)顟B(tài)問(wèn)題,針對(duì)這個(gè)問(wèn)題,這篇文章詳細(xì)介紹了相對(duì)應(yīng)的分析和解答,希望可以幫助更多想解決這個(gè)問(wèn)題的小伙伴找到更簡(jiǎn)單易行的方法。

創(chuàng)新互聯(lián)專(zhuān)注于揭陽(yáng)網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗(yàn)。 熱誠(chéng)為您提供揭陽(yáng)營(yíng)銷(xiāo)型網(wǎng)站建設(shè),揭陽(yáng)網(wǎng)站制作、揭陽(yáng)網(wǎng)頁(yè)設(shè)計(jì)、揭陽(yáng)網(wǎng)站官網(wǎng)定制、小程序開(kāi)發(fā)服務(wù),打造揭陽(yáng)網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供揭陽(yáng)網(wǎng)站排名全網(wǎng)營(yíng)銷(xiāo)落地服務(wù)。

1、概述

如果遇到該情況,首先前往 /var/log/ambari-agent/ambari-agent.log 查看日志輸出。

服務(wù)安裝后,每隔大約 60s 會(huì)執(zhí)行 status() 方法。如果執(zhí)行 status() 方法的過(guò)程中報(bào)錯(cuò),則在 Ambari 頁(yè)面上會(huì)顯示服務(wù)已停止。如果執(zhí)行 status() 方法的過(guò)程中沒(méi)報(bào)錯(cuò),則在 Ambari 頁(yè)面上顯示服務(wù)正常。

通常在 status() 方法中,我們會(huì)使用 Ambari 提供的 resource_management 模塊里的 check_process_status() 來(lái)判斷服務(wù)的狀態(tài)。

check_process_status() 通過(guò)檢測(cè)一個(gè) pid 文件里面的進(jìn)程號(hào),來(lái)判斷服務(wù)的啟動(dòng)狀態(tài)。通常 pid 文件內(nèi)只有一個(gè)進(jìn)程號(hào),如 12168 。

 

2、問(wèn)題示例分析

 
2.1、報(bào)錯(cuò)

以自定義服務(wù) JanusGraph 為例,status() 方法是這樣寫(xiě)的:

from resource_management import *

def status(self, env):
    import graphexp_params
    env.set_params(graphexp_params)
    check_process_status(graphexp_params.graphexp_nginx_pid_file)
 

graphexp_params.py 文件的局部?jī)?nèi)容:

from resource_management import *

config = Script.get_config()
# graphexp的nginx pid文件路徑
graphexp_pid_dir = config['configurations']['graphexp-server']['graphexp_pid_dir']
# graphexp的nginx pid文件路徑
graphexp_nginx_pid_file = os.path.join(graphexp_pid_dir, 'graphexp_nginx.pid')
 

上述代碼是動(dòng)態(tài)獲取 Ambari 頁(yè)面上的 graphexp_pid_dir 配置項(xiàng),然后拼湊成一個(gè) pid 文件路徑,這個(gè) pid 文件內(nèi)容只有 graphexp 組件的進(jìn)程號(hào)。

結(jié)果出錯(cuò)了,根據(jù) /var/log/ambari-agent/ambari-agent.log 日志輸出,發(fā)現(xiàn)在 status_params.py 里面獲取 graphexp-server.xml 文件內(nèi)的參數(shù)值報(bào)錯(cuò),如下圖所示:

如何解決Ambari 自定義服務(wù)啟動(dòng)成功后依舊顯示停止?fàn)顟B(tài)問(wèn)題

 
2.2、問(wèn)題排查

在 status() 方法下,輸出 config['configurations'] 發(fā)現(xiàn)只能打印出:

ams-hbase-env,infra-solr-env,hbase-env,ams-env,elastic-env,janusgraph-env,ams-grafana-env,hadoop-env,zookeeper-env,cluster-env
 

以上這些值,沒(méi)有 graphexp-server 項(xiàng)。

而在 start() 方法里面打印有很多,所有的 configurations 的 xml 文件都被加載到了:

ranger-hdfs-audit,ssl-client,infra-solr-log4j,ranger-hdfs-policymgr-ssl,ams-hbase-site,elastic-config,ranger-hbase-audit,hdfs-logsearch-conf,ams-grafana-env,ranger-hdfs-security,ams-ssl-client,infra-solr-env,ranger-hdfs-plugin-properties,hbase-policy,ams-logsearch-conf,ams-hbase-security-site,hdfs-site,ams-env,ams-site,ams-hbase-policy,janusgraph-env,hadoop-metrics2.properties,hadoop-policy,hdfs-log4j,hbase-site,infra-logsearch-conf,ranger-hbase-plugin-properties,ams-grafana-ini,graphexp-server,ams-ssl-server,infra-solr-xml,ams-log4j,ams-hbase-env,core-site,infra-solr-security-json,gremlin-server,janusgraph-hbase-solr,infra-solr-client-log4j,hbase-logsearch-conf,hadoop-env,zookeeper-log4j,hbase-log4j,postgresql,ssl-server,hbase-env,zoo.cfg,elastic-env,ranger-hbase-policymgr-ssl,zookeeper-logsearch-conf,cluster-env,zookeeper-env,ams-hbase-log4j,ranger-hbase-security
 

所以猜測(cè)在 status() 方法里面,只能識(shí)別 xxx-env.xml 里面的配置內(nèi)容。但是 ambari2.7 的自定義服務(wù)沒(méi)有這個(gè)問(wèn)題,只在 ambari2.6 上出現(xiàn)了。

 
2.3、解決辦法

新建 graphexp-env.xml 文件,將 graphexp_pid_dir 配置項(xiàng)添加到該文件內(nèi)。graphexp_params.py 文件的 graphexp_pid_dir 寫(xiě)法修改為:

# graphexp的nginx pid文件路徑
graphexp_pid_dir = config['configurations']['graphexp-env']['graphexp_pid_dir']
# graphexp的nginx pid文件路徑
graphexp_nginx_pid_file = os.path.join(graphexp_pid_dir, 'graphexp_nginx.pid')
    在 status() 方法內(nèi),獲取 graphexp-env.xml 文件內(nèi)的配置,只有 xxx-env.xml 的內(nèi)容才可以被 status() 方法加載到。

3、status()方法調(diào)試建議

由于 status() 是輪詢(xún)調(diào)用,且目前還不知道日志輸出的具體位置(沒(méi)有輸出到 ambari-agent.log 里面),所以可以用 Execute("echo {0} >> /tmp/test.log".format(status_params.gtm_standby_pid_file)) 命令來(lái)輸出需要的參數(shù)值。同時(shí)也可以根據(jù)上述 Execute 語(yǔ)句位置來(lái)判斷代碼具體的報(bào)錯(cuò)行數(shù),方便定位代碼報(bào)錯(cuò)地點(diǎn)。 

關(guān)于如何解決Ambari 自定義服務(wù)啟動(dòng)成功后依舊顯示停止?fàn)顟B(tài)問(wèn)題問(wèn)題的解答就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,如果你還有很多疑惑沒(méi)有解開(kāi),可以關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道了解更多相關(guān)知識(shí)。

分享題目:如何解決Ambari自定義服務(wù)啟動(dòng)成功后依舊顯示停止?fàn)顟B(tài)問(wèn)題
當(dāng)前路徑:http://muchs.cn/article4/geciie.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供營(yíng)銷(xiāo)型網(wǎng)站建設(shè)、網(wǎng)站設(shè)計(jì)用戶(hù)體驗(yàn)、建站公司、自適應(yīng)網(wǎng)站網(wǎng)站收錄

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

手機(jī)網(wǎng)站建設(shè)