基于Hadoo的日志收集框架---Chukwa的安装部署

来源:互联网 发布:金山软件管家 编辑:程序博客网 时间:2024/04/27 15:45

chukwa是解决在集群环境中收集各节点增量日志的一种基于hadoop的实现方案,其主要有如下四个组成部分。
1. Agents 运行在每个客户端上,负责发送数据。
2. Collectors 接收Agents发送的数据并写入稳定存储。
3. MapReduce jobs 分析和归档数据。
4. HICC 数据中心,用于显示数据的web界面。
它的系统架构如下图

以单机部署为例,前提已经安装hadoop(0.20.2),HADOOP_HOME=/usr/local/cloud/hadoop

1. 下载chukwa(0.4.0)
2. 解压到/usr/local/cloud/chukwa/,CHUKWA_HOME=/usr/local/cloud/chukwa
3. 修改$CHUKWA_HOME/conf/agents,部署在本机的话为localhost
4. 修改$CHUKWA_HOME/conf/collectors, 部署在本机的话为localhost
5. 修改$CHUKWA_HOME/conf/chukwa-env.sh,设置如下项

Shell代码  收藏代码
  1. export JAVA_HOME=/usr/java/jdk1.6.0_26  
  2. export HADOOP_HOME="/usr/local/cloud/hadoop"  
  3. export HADOOP_CONF_DIR="/usr/local/cloud/hadoop/conf"  
  4. export HADOOP_JAR=${HADOOP_HOME}/hadoop-core-0.20.2.jar  
  5. export chukwaRecordsRepository="/chukwa/repos/"  
  6. export CHUKWA_PID_DIR=/usr/local/cloud/tmp/chukwa/pids  
  7. export CHUKWA_LOG_DIR=/usr/local/cloud/tmp/chukwa/logs  
  8. export CHUKWA_DATA_DIR=/usr/local/cloud/tmp/chukwa/data  

6. 修改$CHUKWA_HOME/conf/chukwa-agent-conf.xml

Xml代码  收藏代码
  1.   <property>  
  2.     <name>chukwaAgent.tags</name>  
  3.     <value>cluster="chukwa"</value>  
  4.     <description>The cluster's name for this agent</description>  
  5.   </property>  
  6.     
  7.   <property>  
  8.     <name>chukwaAgent.control.port</name>  
  9.     <value>9093</value>  
  10.     <description>The socket port number the agent's control interface can be contacted at.</description>  
  11.   </property>  
  12.   
  13.   <property>  
  14.     <name>chukwaAgent.hostname</name>  
  15.     <value>localhost</value>  
  16.     <description>The hostname of the agent on this node. Usually localhost, this is used by the chukwa instrumentation agent-control interface library</description>  
  17.   </property>  
  18.   
  19.   <property>  
  20.     <name>chukwaAgent.checkpoint.name</name>  
  21.     <value>chukwa_agent_checkpoint</value>  
  22.     <description>the prefix to to prepend to the agent's checkpoint file(s)</description>  
  23.   </property>  
  24.     
  25.   <property>  
  26.     <name>chukwaAgent.checkpoint.dir</name>  
  27.     <value>${CHUKWA_LOG_DIR}/</value>  
  28.     <description>the location to put the agent's checkpoint file(s)</description>  
  29.   </property>  
  30.   
  31.   <property>  
  32.     <name>chukwaAgent.checkpoint.interval</name>  
  33.     <value>5000</value>  
  34.     <description>the frequency interval for the agent to do checkpoints, in milliseconds</description>  
  35.   </property>  
  36.   
  37.   <property>  
  38.     <name>chukwaAgent.sender.fastRetries</name>  
  39.     <value>4</value>  
  40.     <description>the number of post attempts to make to a single collector, before marking it failed</description>  
  41.   </property>  
  42.   
  43.   <property>  
  44.     <name>chukwaAgent.collector.retries</name>  
  45.     <value>144000</value>  
  46.     <description>the number of attempts to find a working collector</description>  
  47.   </property>  
  48.   
  49.   <property>  
  50.     <name>chukwaAgent.collector.retryInterval</name>  
  51.     <value>20000</value>  
  52.     <description>the number of milliseconds to wait between searches for a collector</description>  
  53.   </property>  

7. 修改$CHUKWA_HOME/conf/chukwa-collector-conf.xml

Xml代码  收藏代码
  1. <property>  
  2.    <name>writer.hdfs.filesystem</name>  
  3.    <value>hdfs://master:9000/</value>  
  4.    <description>HDFS to dump to</description>  
  5.  </property>  
  6.   
  7.  <property>  
  8.    <name>chukwaCollector.outputDir</name>  
  9.    <value>/chukwa/logs/</value>  
  10.    <description>Chukwa data sink directory</description>  
  11.  </property>  
  12.   
  13.  <property>  
  14.    <name>chukwaCollector.rotateInterval</name>  
  15.    <value>300000</value>  
  16.    <description>Chukwa rotate interval (ms)</description>  
  17.  </property>  
  18.   
  19.  <property>  
  20.    <name>chukwaCollector.http.port</name>  
  21.    <value>8080</value>  
  22.    <description>The HTTP port number the collector will listen on</description>  
  23.  </property>  

8. 修改$CHUKWA_HOME/conf/initial_adaptors,添加要监测的日志文件,比如

Shell代码  收藏代码
  1. add filetailer.CharFileTailingAdaptorUTF8 TestLog1 0 /home/matrix/Program/project/log/testlog1 0  

9. 启动collectors

Shell代码  收藏代码
  1. $CHUKWA_HOME/bin/start-collectors.sh  

10. 启动agents

Shell代码  收藏代码
  1. $CHUKWA_HOME/bin/start-agents.sh  

11. 启动data-processors

Shell代码  收藏代码
  1. $CHUKWA_HOME/bin/start-data-processors.sh 



转至:http://savagegarden.iteye.com/blog/1426853