Dr.elephant是一款對hadoop、Hive和Spark任務進行性能監控和調優的工具,它由LinkedIn的團隊於2016年開源。
一、環境搭建
整體環境:dr.elephant 2.0.13, hadoop 2.6.5, spark 2.2.3
1.jdk8安裝
2.play framework安裝
1)play framework下載解壓
下載Play,在頁面的最下部找到安裝包鏈接進行下載。
$wget https://downloads.typesafe.com/play/2.2.6/play-2.2.6.zip
$unzip play-2.2.6.zip
2)play framework環境變量配置
$vim ~.bash_profile:
export JAVA_HOME=/opt/java
export PLAY_HOME=/opt/play-2.2.6
export PATH=$PATH:$PLAY_HOME:$JAVA_HOME/bin
3)playf ramework測試
創建一個新應用/項目
play new helloworld
3.dr.elephant編譯
1)從github.com上下載dr-elephant-2.0.13
$wget https://github.com/linkedin/dr-elephant/archive/v2.0.13.zip
$unzip v2.0.13.zip
2)修改配置文件compile.conf
$cd ~/dr-elephant-2.0.13
$vim compile.conf
hadoop_version=2.6.5
spark_version=2.2.3
play_opts="-Dsbt.repository.config=app-conf/resolver.conf"
3)編譯生成安裝包
$cd ~/dr-elephant-2.0.13
#以下編譯不成功,可以反覆編譯,或者換一個版本,直到編譯成功。
$./compile.sh ./compile.conf
$ls dist
dr-elephant-2.0.13.zip
編譯完成後,會有SUCCESS的提示。這時可以看到在源碼文件夾中,多了一個目錄dist,進入這個目錄可以看到,裏面有一個zip包dr-elephant-2.0.13.zip,解壓縮這個zip包,生成dr-elephant-2.0.13的代碼,可用於部署使用。
4.dr.elephant部署
1)dr.elephant部署
$cd ~/dr-elephant-2.0.13/dist
$mv dr-elephant-2.0.13.zip /opt/
$cd /opt/;unzip dr-elephant-2.0.13.zip
2)修復SQL文件的BUG
$cd /opt/dr-elephant-2.0.13
$vim conf/evolutions/default/1.sql
Replace lines 49-51, from
create index yarn_app_result_i4 on yarn_app_result (flow_exec_id);
create index yarn_app_result_i5 on yarn_app_result (job_def_id);
create index yarn_app_result_i6 on yarn_app_result (flow_def_id);
to
create index yarn_app_result_i4 on yarn_app_result (flow_exec_id(191));
create index yarn_app_result_i5 on yarn_app_result (job_def_id(191));
create index yarn_app_result_i6 on yarn_app_result (flow_def_id(191));
可以解決以下拋錯:
[error] c.j.b.ConnectionHandle - Database access problem. Killing off this connection and all remaining connections in the connection pool. SQL State = HY000
mysql的字符集必須設置爲UTF8
3)更改配置文件
設置mysql信息:vim app-conf/elephant.conf
調整採集線程數和時間間隔:vim app-conf/GeneralConf.xml
<configuration>
<property>
<name>drelephant.analysis.thread.count</name>
<value>15</value>
<description>Number of threads to analyze the completed jobs</description>
</property>
<property>
<name>drelephant.analysis.fetch.interval</name>
<value>60000</value>
<description>Interval between fetches in milliseconds</description>
</property>
<property>
<name>drelephant.analysis.retry.interval</name>
<value>60000</value>
<description>Interval between retries in milliseconds</description>
</property>
<property>
<name>drelephant.application.search.match.partial</name>
<value>true</value>
<description>If this property is "false", search will only make exact matches</description>
</property>
</configuration>
修改drelephant.analysis.thread.count,默認是3,建議修改到15,3的話從jobhistoryserver讀取的速度太慢,高於15的話又讀取的太快,會對jobhistoryserver造成很大壓力。下面兩個一個是讀取的時間週期,一個是重試讀取的間隔時間週期。
4)啓動進程
$cd /opt/dr-elephant-2.0.13
$sh -x bin/start.sh app-conf/
5)web瀏覽器訪問
http://$ip:8080