设为首页 收藏本站
查看: 821|回复: 0

[经验分享] Data ETL tools for hadoop ecosystem Morphlines

[复制链接]
发表于 2016-12-11 07:51:27 | 显示全部楼层 |阅读模式
  when i use
  there is a error

java.lang.NoClassDefFoundError: org/kitesdk/morphline/api/MorphlineCompilationException
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
at org.apache.flume.sink.solr.morphline.MorphlineSink.start(MorphlineSink.java:93)
at org.apache.flume.sink.DefaultSinkProcessor.start(DefaultSinkProcessor.java:46)
at org.apache.flume.SinkRunner.start(SinkRunner.java:79)
at org.apache.flume.lifecycle.LifecycleSupervisor$MonitorRunnable.run(LifecycleSupervisor.java:251)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:304)

  solution:

* clone flume from git
* cd flume
* edit flume-ng-sinks/flume-ng-morphline-solr-sink/pom.xml, in there do the following:
** make cdk-morphlines-all required by commenting out this blurb: <optional>true</optional>
** add the following mvn blurb to the <build> element in order to copy the dependency jars into the target/lib dir:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<includeScope>runtime</includeScope> <!-- excludes test jars; see http://jira.codehaus.org/browse/MDEP-128 -->
<excludeScope>provided</excludeScope>
</configuration>
</execution>
</executions>
</plugin>
* mvn -Dhadoop.profile=2 clean package -pl flume-ng-sinks/flume-ng-morphline-solr-sink
* find flume-ng-sinks/flume-ng-morphline-solr-sink/target -name '*.jar'
* copy the jars printed out by the above find command into the flume lib dir

  see : https://groups.google.com/a/cloudera.org/forum/#!msg/cdk-dev/7T4pTebdWN4/sBHGkoS70LkJ
  ---------
  solr server's version is 4.10.1
  error
  
DSC0000.png
 
  solution:
  find solr's lib

ls /home/tomcat/solr/WEB-INF/lib/
antlr-runtime-3.5.jar                hadoop-hdfs-2.2.0.jar                  lexicon                               lucene-suggest-4.10.1.jar
asm-4.1.jar                          hppc-0.5.2.jar                         log4j-1.2.16.jar                      mahout-collections-1.0.jar
asm-commons-4.1.jar                  httpclient-4.3.1.jar                   lucene-analyzers-common-4.10.1.jar    mahout-math-0.6.jar
attributes-binder-1.2.2.jar          httpcore-4.3.jar                       lucene-analyzers-kuromoji-4.10.1.jar  noggit-0.5.jar
carrot2-core-3.10.0-SNAPSHOT.jar     httpmime-4.3.1.jar                     lucene-analyzers-phonetic-4.10.1.jar  org.restlet-2.1.1.jar
commons-cli-1.2.jar                  inok-solr-dataimportscheduler-1.1.jar  lucene-analyzers-smartcn-4.10.1.jar   org.restlet.ext.servlet-2.1.1.jar
commons-codec-1.9.jar                jackson-core-asl-1.9.13.jar            lucene-codecs-4.10.1.jar              protobuf-java-2.5.0.jar
commons-configuration-1.6.jar        jackson-mapper-asl-1.9.13.jar          lucene-core-4.10.1.jar                simple-xml-2.7.jar
commons-fileupload-1.2.1.jar         jcl-over-slf4j-1.6.6.jar               lucene-expressions-4.10.1.jar         slf4j-api-1.6.6.jar
commons-io-2.3.jar                   jcseg-analyzer-1.9.5.jar               lucene-grouping-4.10.1.jar            slf4j-log4j12-1.6.6.jar
commons-lang-2.6.jar                 jcseg-core-1.9.5.jar                   lucene-highlighter-4.10.1.jar         solr-core-4.10.1.jar
concurrentlinkedhashmap-lru-1.2.jar  jcseg-core-1.9.5.jar.old               lucene-join-4.10.1.jar                solr-solrj-4.10.1.jar
dom4j-1.6.1.jar                      jcseg.properties                       lucene-memory-4.10.1.jar              spatial4j-0.4.1.jar
guava-14.0.1.jar                     jcseg-solr-1.9.5.jar                   lucene-misc-4.10.1.jar                wstx-asl-3.2.7.jar
hadoop-annotations-2.2.0.jar         jcseg-solr-1.9.5.jar.old               lucene-queries-4.10.1.jar             zookeeper-3.4.6.jar
hadoop-auth-2.2.0.jar                joda-time-2.2.jar                      lucene-queryparser-4.10.1.jar
hadoop-common-2.2.0.jar              jul-to-slf4j-1.6.6.jar                 lucene-spatial-4.10.1.jar

  #cp  /home/tomcat/solr/WEB-INF/lib/lucene-*-4.10.1.jar   /root/aflume/lib/
  #cp /home/tomcat/solr/WEB-INF/lib/solr-*-4.10.1.jar    /root/aflume/lib/
  #cp /home/tomcat/solr/WEB-INF/lib/http*-4.3.1.jar   /root/aflume/lib/
  delete old related jars in /root/aflume/lib/  such as lucene-*-4.3.0.jar  solr-*-4.3.0.jar   http*-4.2.1.jar
  -------
  when run
  #flume-ng agent -c ./conf/ -f conf/flume.conf -Dflume.root.logger=DEBUG,console -n a1
  flume/conf/flume.conf

# Define a memory channel called ch1 on agent1
a1.channels.ch1.type = memory
# Define an Avro source called avro-source1 on agent1 and tell it
# to bind to 0.0.0.0:41414. Connect it to channel ch1.
a1.sources.mysqlbinlog.channels = ch1
a1.sources.mysqlbinlog.type = com.inoknok.mysqlbinlog.source.InokMysqlBinlogSource
a1.sources.mysqlbinlog.user=zhaohj
a1.sources.mysqlbinlog.password=zhaohj111
a1.sources.mysqlbinlog.host=192.168.0.135
a1.sources.mysqlbinlog.port=3306
a1.sources.mysqlbinlog.serverId=2
a1.sources.mysqlbinlog.autoReconnect=false

# Define a logger sink that simply logs all events it receives
# and connect it to the other end of the same channel.
a1.sinks.k1.channel = ch1
a1.sinks.k1.type = org.apache.flume.sink.solr.morphline.MorphlineSolrSink
a1.sinks.k1.morphlineFile = /root/aflume/conf/morphline.conf
# Finally, now that we've defined all of our components, tell
# agent1 which ones we want to activate.
a1.channels = ch1
a1.sources = mysqlbinlog
a1.sinks = k1

  flume/conf/morphile.conf

morphlines : [
{
id : morphline1
importCommands : ["org.kitesdk.**", "com.cloudera.**", "org.apache.solr.**"]
commands : [
{
readClob {
charset : UTF-8
}
}
{
split {
inputField : message
outputFields : ["", "", "",user_id, username, age]
separator : "\u0001"
isRegex : false
addEmptyStrings : false
trim : true
}
}
{
sanitizeUnknownSolrFields {
solrLocator : {
solrUrl : "192.168.10.204:8983"
solrHomeDir : "/home/tomcat/solrHome/test.inok_user"
#collection : "@${tablename}"
#zkHost: "192.168.10.204:8983"
}
}
}
{
logDebug {
format : "xxxxxxxxx   xxxxxx My output record: {}"
args : ["@{}"]
}
}

# load the record into a Solr server or MapReduce Reducer
{
loadSolr {
solrLocator : {
solrUrl : "192.168.10.204:8983"
solrHomeDir : "/home/tomcat/solrHome/test.inok_user"
#collection : "@${tablename}"       # Name of solr collection
#zkHost : "192.168.10.204:8983" # ZooKeeper ensemble
}
}
}
]
}
]

  error:
  
DSC0001.png
 
  Solution:

        solrUrl : "http://192.168.10.204:8983/test.inok_user"
solrHomeDir : "/home/tomcat/solrHome/test.inok_user"
  ----------
  Morphline - Choose collection for loadSolr at run time
  https://groups.google.com/a/cloudera.org/forum/#!topic/search-user/z9A_Xe5FviM
  http://kitesdk.org/docs/current/morphlines/morphlines-reference-guide.html#Implementing_your_own_Custom_Command
  Use case: I want to dynaic set solrLocator at run time, but faild. The replacement way is to use tryRule command, but the solrLocator must be setted hardcode.

morphlines : [
{
id : morphline1
importCommands : ["org.kitesdk.**", "com.cloudera.**", "org.apache.solr.**"]
commands : [
{
readClob {
charset : UTF-8
}
}

{
tryRules {
catchExceptions : false
throwExceptionIfAllRulesFailed : true
rules : [
{
//test.inok_user
commands : [
{contains {tablename : [test.inok_user]} }
{logDebug { format : "YYYYYYYYY 1111 My output record: {}, talbename={}",args : ["@{}","@{tablename}"]} }
{split {inputField : message, outputFields : [updatetime,"","",user_id, username, age],separator : "\u0001",
isRegex : false,addEmptyStrings : false, trim : true} }
{convertTimestamp {
field : updatetime
inputFormats : ["unixTimeInMillis"]
inputTimezone : UTC
outputFormat : "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
outputTimezone : PRC
}
}
{sanitizeUnknownSolrFields {
solrLocator : {
solrUrl :"http://192.168.10.204:8983/test.inok_user/"
solrHomeDir : "/home/tomcat/solrHome/test.inok_user"
}
}}
{logDebug { format : "xxxxxxxxx 1111 My output record: {}, talbename={}",args : ["@{}","@{tablename}"]}  }
# load the record into a Solr server or MapReduce Reducer
{loadSolr { solrLocator : {
solrUrl : "http://192.168.10.204:8983/test.inok_user"
solrHomeDir : "/home/tomcat/solrHome/test.inok_user"
batchSize : 1
}  }  }
]
}//end rule1
#test.inoktest
{
//test.inoktest
commands : [
{contains {tablename : [test.inoktest]} }
{logDebug {format : "YYYYYYYYY 2222 My output record: {}, talbename={}",args : ["@{}","@{tablename}"] } }
{split {inputField : message, outputFields : [updatetime,"","",id, content],separator : "\u0001",
isRegex : false,addEmptyStrings : false, trim : true} }
{convertTimestamp {
field : updatetime
inputFormats : ["unixTimeInMillis"]
inputTimezone : UTC
outputFormat : "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
outputTimezone : PRC
}
}
{sanitizeUnknownSolrFields {solrLocator : {
solrUrl :"http://192.168.10.204:8983/test.inoktest/"
solrHomeDir : "/home/tomcat/solrHome/test.inoktest"
}
}}
{logDebug { format : "xxxxxxxxx 2222 My output record: {}, talbename={}",args : ["@{}","@{tablename}"]} }
# load the record into a Solr server or MapReduce Reducer
{loadSolr { solrLocator : {
solrUrl : "http://192.168.10.204:8983/test.inoktest"
solrHomeDir : "/home/tomcat/solrHome/test.inoktest"
batchSize : 1
}
} }
]
}//end rule2
]
}//end rules
}
]
}
]

  --------------------
  when I configure avro source in agent a while an avro sink in agent b in different hosts.
  flume.conf in host a

# Define a memory channel called ch1 on agent1
a1.channels.ch1.type = memory
# Define an Avro source called avro-source1 on agent1 and tell it
# to bind to 0.0.0.0:41414. Connect it to channel ch1.
a1.sources.mysqlbinlog.channels = ch1
a1.sources.mysqlbinlog.type = com.inoknok.mysqlbinlog.source.InokMysqlBinlogSource
a1.sources.mysqlbinlog.user=zhaohj
a1.sources.mysqlbinlog.password=zhaohj111
a1.sources.mysqlbinlog.host=192.168.0.135
a1.sources.mysqlbinlog.port=3306
a1.sources.mysqlbinlog.serverId=2
a1.sources.mysqlbinlog.autoReconnect=false

#sink to solr
a1.sinks.k1.channel = ch1
a1.sinks.k1.type = org.apache.flume.sink.solr.morphline.MorphlineSolrSink
a1.sinks.k1.morphlineFile = /root/aflume/conf/morphline.conf

#sink to avro
a1.sinks.k3.type = avro
a1.sinks.k3.channel = ch1
a1.sinks.k3.hostname = 192.168.0.135
a1.sinks.k3.port = 4545

# Finally, now that we've defined all of our components, tell
# agent1 which ones we want to activate.
a1.channels = ch1
a1.sources = mysqlbinlog
a1.sinks =  k3

  flume.conf in host b

# Define a memory channel called ch1 on agent1
a1.channels.ch1.type = memory
#source avro
a1.sources.s1.channels = ch1
a1.sources.s1.type = avro
a1.sources.s1.bind = 0.0.0.0
a1.sources.s1.port = 4545
#sink to hdfs
a1.sinks.k1.channel = ch1
a1.sinks.k1.type = hdfs
a1.sinks.k1.hdfs.path = /user/flume/mysqlbinlog/%{tablename}
a1.sinks.k1.hdfs.filePrefix = %{tablename}-
a1.sinks.k1.hdfs.round = false
a1.sinks.k1.hdfs.rollInterval = 0
a1.sinks.k1.hdfs.rollCount = 0
a1.sinks.k1.hdfs.rollSize = 0
a1.sinks.k1.hdfs.batchSize = 100
a1.sinks.k1.hdfs.fileType = DataStream
a1.sinks.k1.hdfs.roundValue = 10
a1.sinks.k1.hdfs.roundUnit = minute
a1.sinks.k1.hdfs.useLocalTimeStamp = true

# Finally, now that we've defined all of our components, tell
# agent1 which ones we want to activate.
a1.channels = ch1
a1.sources = s1
a1.sinks = k1
  There is a error
  
DSC0002.png
 
  --------------------
  1. install    flume in the same machine with solr
  2. add zookeeper-3.4.6.jar to flume/lib dir
  3. put plugin in plugins.d dir

plugins.d/
└── mysqlbinlog
├── lib
│   └── mysqlbinlog-sources.jar
└── libext
└── open-replicator-1.0.7.jar
  4. set mysql to master/salve replication set and start up master and slave mysql daemons
  5. start up solr
  6. test by use command

flume-ng agent -c ./conf/ -f conf/flume.conf -Dflume.root.logger=DEBUG,console -n a1
  References
  http://flume.apache.org/FlumeUserGuide.html#morphlinesolrsink
  http://cloudera.github.io/cdk/docs/current/cdk-morphlines/index.html
  http://cloudera.github.io/cdk/docs/current/cdk-morphlines/morphlinesReferenceGuide.html
  http://www.cloudera.com/content/cloudera/en/documentation/core/latest/topics/search_flume_morphline_solr_sink_config_options.html
  http://www.slideshare.net/cloudera/using-morphlines-for-onthefly-etl
  http://kitesdk.org/docs/current/morphlines/morphlines-reference-guide.html#Implementing_your_own_Custom_Command
  http://kitesdk.org/docs/current/morphlines/morphlines-reference-guide.html

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-312498-1-1.html 上篇帖子: Hadoop中一些采样器的实现 下篇帖子: hadoop处理手机流量小例子
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表