如何更改cloudera-scm-server默认日志路径?

由于CM安装的所有的组件,路径默认是/var/lib或者是/var/log,如果系统盘太小的话,会一直有警告,看起来太烦了.

有两种方式解决:

1.直接选择抑制改告警

2. 在CM web ui所有能配置的/var/log 基本上我都修改了,甚至连 /tmp堆转储也都改了.

手动清理历史日志/var/log/.

上面是需要重启服务生效的.基本上能解决大部分的问题.

唯一不能通过web ui 配置log路径的那就是cm-server,下面就来尝试着修改下吧.

----------------------------------------------------------------------------------------------------------------------------------

以下操作需要有一定运维经验

1. 查看相关的环境

# whereis cloudera-scm-server
cloudera-scm-server: /etc/cloudera-scm-server

2. 查看路径下 的文件

ll /etc/cloudera-scm-server/
total 36
-rw------- 1 cloudera-scm cloudera-scm  436 May 24 10:52 db.properties
-rw------- 1 cloudera-scm cloudera-scm  757 Mar 15 01:45 db.properties.~1~
-rw------- 1 cloudera-scm cloudera-scm  432 Apr 28 00:14 db.properties.~2~
-rw------- 1 cloudera-scm cloudera-scm  432 Apr 28 00:14 db.properties.~3~
-rw------- 1 cloudera-scm cloudera-scm  432 Apr 28 00:15 db.properties.~4~
-rw------- 1 cloudera-scm cloudera-scm  432 Apr 28 00:16 db.properties.~5~
-rw------- 1 cloudera-scm cloudera-scm  432 Apr 28 00:16 db.properties.~6~
-rw------- 1 cloudera-scm cloudera-scm  432 Apr 28 00:18 db.properties.~7~
-rw-r--r-- 1 cloudera-scm cloudera-scm 3059 May 29 10:12 log4j.properties

发现log4j.properties,是不是很开心.

尝试修改 其中的 cmf.log.dir=/alidata1/log/cloudera-scm-server

mkdir  /alidata1/log/cloudera-scm-server
chown cloudera-scm:cloudera-scm   /alidata1/log/cloudera-scm-server

3.重启cloudera-scm-server 

systemctl stop cloudera-scm-server.service
mv /var/log/cloudera-scm-server/* /alidata1/log/cloudera-scm-server/
systemctl start cloudera-scm-server.service

发现日志还是在/val/log/cloudera-scm-server路径下,what?那个log4j文件没生效.

[[email protected] ~]# systemctl status cloudera-scm-server.service 
● cloudera-scm-server.service - Cloudera CM Server Service
   Loaded: loaded (/usr/lib/systemd/system/cloudera-scm-server.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2019-05-29 10:33:23 CST; 8min ago
 Main PID: 9868 (java)
   CGroup: /system.slice/cloudera-scm-server.service
           └─9868 /usr/java/jdk1.8.0_181-cloudera/bin/java -cp .:/usr/share/java/mysql-connector-java.jar:/usr/share/java/oracle-connector-java.jar:/usr/share/java/postgresql-connector-java.jar:lib/* -server...

May 29 10:33:23 hzd-t-vbdl-02 systemd[1]: Started Cloudera CM Server Service.
May 29 10:33:23 hzd-t-vbdl-02 systemd[1]: Starting Cloudera CM Server Service...
May 29 10:33:23 hzd-t-vbdl-02 cm-server[9868]: JAVA_HOME=/usr/java/jdk1.8.0_181-cloudera
May 29 10:33:23 hzd-t-vbdl-02 cm-server[9868]: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
May 29 10:33:24 hzd-t-vbdl-02 cm-server[9868]: ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console. Set system property 'org.a...ation logging.
Hint: Some lines were ellipsized, use -l to show in full.
[[email protected] ~]#

什么情况日志不够清晰 ?再来一遍

[[email protected] ~]# systemctl status cloudera-scm-server.service  -l
● cloudera-scm-server.service - Cloudera CM Server Service
   Loaded: loaded (/usr/lib/systemd/system/cloudera-scm-server.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2019-05-29 10:33:23 CST; 8min ago
 Main PID: 9868 (java)
   CGroup: /system.slice/cloudera-scm-server.service
           └─9868 /usr/java/jdk1.8.0_181-cloudera/bin/java -cp .:/usr/share/java/mysql-connector-java.jar:/usr/share/java/oracle-connector-java.jar:/usr/share/java/postgresql-connector-java.jar:lib/* -server -Dlog4j.configuration=file:/etc/cloudera-scm-server/log4j.properties -Dfile.encoding=UTF-8 -Dcmf.root.logger=INFO,LOGFILE -Dcmf.log.dir=/var/log/cloudera-scm-server -Dcmf.log.file=cloudera-scm-server.log -Dcmf.jetty.threshhold=WARN -Dcmf.schema.dir=/opt/cloudera/cm/schema -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true -Dpython.home=/opt/cloudera/cm/python -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+HeapDumpOnOutOfMemoryError -Xmx2G -XX:MaxPermSize=256m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp -XX:OnOutOfMemoryError=kill -9 %p com.cloudera.server.cmf.Main

May 29 10:33:23 hzd-t-vbdl-02 systemd[1]: Started Cloudera CM Server Service.
May 29 10:33:23 hzd-t-vbdl-02 systemd[1]: Starting Cloudera CM Server Service...
May 29 10:33:23 hzd-t-vbdl-02 cm-server[9868]: JAVA_HOME=/usr/java/jdk1.8.0_181-cloudera
May 29 10:33:23 hzd-t-vbdl-02 cm-server[9868]: Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
May 29 10:33:24 hzd-t-vbdl-02 cm-server[9868]: ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console. Set system property 'org.apache.logging.log4j.simplelog.StatusLogger.level' to TRACE to show Log4j2 internal initialization logging.

发现了吗?这个cmf.log.dir 是事先写死的,(⊙o⊙)…!

是时候表演真正的技术了!

查看启动程序入口:/usr/lib/systemd/system/cloudera-scm-server.service

[[email protected] ~]# more  /usr/lib/systemd/system/cloudera-scm-server.service 
[Unit]
Description=Cloudera CM Server Service
After=network-online.target
Wants=network-online.target

[Install]
WantedBy=multi-user.target

[Service]
User=cloudera-scm
Group=cloudera-scm
Type=simple
Environment=CLOUDERA_ROOT=/opt/cloudera
Environment=CMF_DEFAULTS=/etc/default/cloudera-scm-server ExecStart=/opt/cloudera/cm/bin/cm-server Restart=on-failure
StartLimitInterval=2min
StartLimitBurst=5

重点查看上面两个配置,一个是环境的配置,一个是启动的配置.

[[email protected] ~]# more  /opt/cloudera/cm/bin/cm-server | grep log 
export CMF_LOG4J_CONFIG="file:$CMF_CONF_DIR/log4j.properties"
# export CMF_LOG_DIR="${CMF_VAR:-/var}/log/$prog"
export CMF_LOG_DIR="${CMF_VAR:-/var}/log/$prog"
export CMF_LOGFILE="$prog.log"
CMF_OPTS="$CMF_OPTS -Dlog4j.configuration=${CMF_LOG4J_CONFIG}"
CMF_OPTS="$CMF_OPTS -Dcmf.root.logger=${CMF_ROOT_LOGGER:-INFO,CONSOLE}"
CMF_OPTS="$CMF_OPTS -Dcmf.log.dir=${CMF_LOG_DIR:-.}"
CMF_OPTS="$CMF_OPTS -Dcmf.log.file=${CMF_LOGFILE:-cmf-server.log}"

发现log了吧,^_^.修改如下图

 

 

在来确认一下吧. 

sh -xv  /opt/cloudera/cm/bin/cm-server

 

 

基本上到此结束了,修改上面的/var --> /mnt/data/cdh/cloudera-scm-server-log

然后重启cm server.

posted @ 2022-06-28 10:31  民宿  阅读(516)  评论(0编辑  收藏  举报