- 在hive的使用中,我們都知道可以通過修改hive-log4j2.properties.template中的屬性來讓hive打印日志到指定的地方,如打印到/var/log/hive/hive.log中,則可以配置如下的指定
property.hive.log.level = INFO
property.hive.root.logger = DRFA
property.hive.log.dir = /var/log/hive
property.hive.log.file = hive.log
property.hive.perflogger.log.level = INFO
- 但是在實(shí)際中,我們不僅要設(shè)置hive日志的打印路徑,還想再進(jìn)一步的設(shè)置hms和hs2的日志路徑,首先先從模板中拷貝對應(yīng)進(jìn)程的日志properties文件
cd /xxx/hive/hive-3.1.3/conf
cp hive-log4j2.properties.template hive-hms-log4j2.properties
cp hive-log4j2.properties.template hive-hs2-log4j2.properties
- 修改配置文件中日志的指定路徑,接下思路就是如何讓hms和hs2進(jìn)程在啟動(dòng)時(shí)分別加載各自的log4j配置文件,可以通過修改hive腳本來實(shí)現(xiàn)
vim /xxx/hive/hive-3.1.3/bin/hive
#刪除掉通用配置:
export HADOOP_CLIENT_OPTS="$HADOOP_CLIENT_OPTS -Dlog4j.configurationFile=hive-log4j2.properties "
#新增如下判斷添加:
if [ $SERVICE == "metastore" ]
then
export HADOOP_CLIENT_OPTS="$HADOOP_CLIENT_OPTS -Dlog4j.configurationFile=hive-hms-log4j2.properties "
else
export HADOOP_CLIENT_OPTS="$HADOOP_CLIENT_OPTS -Dlog4j.configurationFile=hive-hs2-log4j2.properties "
fi
- 下面的hive命令啟動(dòng)hms和hs2,則會(huì)打印到正確的日志目錄
/xxx/hive/hive-3.1.3/bin/hive --service metastore >> /var/log/hive/metastore.out 2>&1 &
/xxx/hive/hive-3.1.3/bin/hive --service hiveserver2 >> /var/log/hive/hiveserver2.out 2>&1 &
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。