NN,DN process for upgrading Hadoop's HDFs, log output as JSON grid

Source: Internet
Author: User

Original link: http://blog.itpub.net/30089851/viewspace-2136429/

1. Log in to the NN machine, go to the Namenode Configuration folder of the latest serial number, view the log4j configuration of the current NN
[Email protected] ~]# cd/var/run/cloudera-scm-agent/process/
[Email protected] process]# LS-LRT
.......
.......
.......
Drwxr-x--x 3 HDFs HDFs 380 Mar 20:40 372-hdfs-failovercontroller
Drwxr-x--x 3 HDFs HDFs 20:40 370-hdfs-namenode
Drwxr-x--x 3 HDFs HDFs 20:40 422-hdfs-failovercontroller
Drwxr-x--x 3 HDFs HDFs 480 Mar 20:40 420-hdfs-namenode
Drwxr-x--x 3 Yarn Hadoop 520 Mar 20:40 383-yarn-resourcemanager
Drwxr-x--x 3 mapred Hadoop 20:40 379-yarn-jobhistory
Drwxr-x--x 3 mapred Hadoop 380 Mar 20:40 425-yarn-jobhistory
Drwxr-x--x 3 yarn Hadoop April 20:40 428-yarn-resourcemanager
Drwxr-x--x 3 root root 15:53 359-cluster-host-inspector
[Email protected] process]# CD 420-hdfs-namenode
[email protected] 420-hdfs-namenode]# cat log4j.properties
Log.threshold=info
Main.logger=rfa
Hadoop.root.logger=${log.threshold},${main.logger}
Log4j.appender.eventcounter=org.apache.hadoop.log.metrics.eventcounter
Log4j.rootlogger=${hadoop.root.logger},eventcounter,eventcatcher
Log.dir=/var/log/hadoop-hdfs
Log.file=hadoop-cmf-hdfs-namenode-sht-sgmhadoopnn-01.log.out
max.log.file.size=200mb
max.log.file.backup.index=10
Log4j.appender.rfa=org.apache.log4j.rollingfileappender
Log4j.appender.rfa.file=${log.dir}/${log.file}
Log4j.appender.rfa.layout=org.apache.log4j.patternlayout
log4j.appender.rfa.layout.conversionpattern=%d{iso8601}%p%c:%m%n
Log4j.appender.rfa.maxfilesize=${max.log.file.size}
Log4j.appender.rfa.maxbackupindex=${max.log.file.backup.index}
Log4j.appender.console=org.apache.log4j.consoleappender
Log4j.appender.console.target=system.err
Log4j.appender.console.layout=org.apache.log4j.patternlayout
Log4j.appender.console.layout.conversionpattern=%d{yy/mm/dd HH:mm:ss}%p%c{2}:%m%n
........
........


2. Careful analysis, log4j.appender.RFA.layout.ConversionPattern This parameter should be the log that controls the NN process

3. Open CDH, enter the configuration interface of HDFs, search "log" keyword,

3.1 Find "NameNode Logging Advanced Configuration Snippet (Safety Valve)", configuring
Log4j.appender.RFA.layout.ConversionPattern = {"Time": "%d{yyyy-mm-dd hh:mm:ss,sss}", "LogType": "%p", "Loginfo": "%c: %m "}%n


3.2 found "DataNode Logging Advanced Configuration Snippet (Safety Valve)", also configured
Log4j.appender.RFA.layout.ConversionPattern = {"Time": "%d{yyyy-mm-dd hh:mm:ss,sss}", "LogType": "%p", "Loginfo": "%c: %m "}%n

3.3 Click Save
3.4 Click Stale Configuration:restart needed

3.5 Restart Stale Services

3.6 Review Changes, select Re-deploy Client Configuration, Restart now

4. Check if the log output of the NN,DN process is in JSON format
4.1 Check if new parameters are in effect
[Email protected] 420-hdfs-namenode]# CD. /
[Email protected] process]# LS-LRT
.......
.......
.......
Drwxr-x--x 3 HDFs HDFs 380 Mar 20:32 422-hdfs-failovercontroller
Drwxr-x--x 3 HDFs HDFs 20:32 439-hdfs-failovercontroller
Drwxr-x--x 3 HDFs HDFs 480 Mar 20:32 437-hdfs-namenode
Drwxr-x--x 3 mapred Hadoop 20:32 425-yarn-jobhistory
Drwxr-x--x 3 Yarn Hadoop 520 Mar 20:32 428-yarn-resourcemanager
Drwxr-x--x 3 mapred Hadoop 380 Mar 20:32 442-yarn-jobhistory
Drwxr-x--x 3 yarn Hadoop 20:32 445-yarn-resourcemanager
[Email protected] process]# CD 437-hdfs-namenode
[email protected] 437-hdfs-namenode]# cat log4j.properties |grep Log4j.appender.RFA.layout.ConversionPattern
log4j.appender.rfa.layout.conversionpattern={"Time": "%d{yyyy-mm-dd hh:mm:ss,sss}", "LogType": "%p", "Loginfo": "%c: %m "}%n
[Email protected] 437-hdfs-namenode]#


4.2 Check Log
to

[Email protected] 437-hdfs-namenode]# tail-f/var/log/hadoop-hdfs/ Hadoop-cmf-hdfs-namenode-sht-sgmhadoopnn-01.log.out
{"Time": "2017-03-31 20:40:38,588", "LogType": "INFO", "Loginfo": "Org.apache.hadoop.hdfs.server.namenode.FSImage: Reading org[email protected]5c588660 expecting start Txid #142520 "}
{"Time": "2017-03-31 20:40:38,588", "LogType": "INFO", "Loginfo": "Org.apache.hadoop.hdfs.server.namenode.FSImage: Start Loading edits file http://sht-sgmhadoopdn-02:8480/getjournal?jid=nameservice1&segmenttxid=142520& Storageinfo=-60%3a1863012361%3a0%3acluster8, http://sht-sgmhadoopdn-01:8480/getjournal?jid=nameservice1& Segmenttxid=142520&storageinfo=-60%3a1863012361%3a0%3acluster8 "}
{"Time": "2017-03-31 20:40:38,588", "LogType": "INFO", "Loginfo": " Org.apache.hadoop.hdfs.server.namenode.editloginputstream:fast-forwarding Stream ' http://sht-sgmhadoopdn-02:8480 /getjournal?jid=nameservice1&segmenttxid=142520&storageinfo=-60%3a1863012361%3a0%3acluster8, HTTP// sht-sgmhadoopdn-01:8480/getjournal?jid=nameservice1&segmenttxid=142520&storageinfo=-60%3a1863012361% 3a0%3acluster8 ' to Transaction ID 142520}
{"Time": "2017-03-31 20:40:38,588", "LogType": "INFO", "Loginfo": " Org.apache.hadoop.hdfs.server.namenode.editloginputstream:fast-forwarding Stream ' http://sht-sgmhadoopdn-02:8480 /getjournal?jid=nameservice1&segmenttxid=142520&storageinfo=-60%3a1863012361%3a0%3acluster8 ' to Transaction ID 142520 "}


5. Insufficient, when the occurrence of exception, will be the entire information only the first behavior JSON format, the residual behavior of ordinary output, then the entire message is not the full JSON

Workaround:
5.1 Retrofit Log4j-xxxx.jar-cost too much
5.2 At the flume-ng end of the exec source transformation, we take the second kind of
5.3 Google search log4j json, I found a lot of people like me, there are ready-made GitHub projects and so on

NN,DN process for upgrading Hadoop's HDFs, log output as JSON (GO)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.