Advertisement
Guest User

Untitled

a guest
Jun 20th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. // Pull orders data from order sqoop table to \user\cloudera\problem7\prework
  2.  
  3. sqoop import \
  4. --table orders \
  5. --connect "jdbc:mysql://quickstart.cloudera:3306/retail_db" \
  6. --username retail_dba \
  7. --password cloudera \
  8. -m 1 \
  9. --target-dir /user/cloudera/problem7/prework \
  10. --as-avrodatafile
  11.  
  12. // Get the file from HDFS to local
  13.  
  14. mkdir flume-avro;
  15. cd flume-avro;
  16. hadoop fs -get /user/cloudera/problem7/prework/* .
  17. gedit f.config
  18.  
  19. // Create a flume-config file in problem7 folder named f.config
  20.  
  21. #Agent Name = step1
  22.  
  23. # Name the source, channel and sink
  24. step1.sources = avro-source
  25. step1.channels = jdbc-channel
  26. step1.sinks = file-sink
  27.  
  28. # Source configuration
  29. step1.sources.avro-source.type = avro
  30. step1.sources.avro-source.port = 11112
  31. step1.sources.avro-source.bind = localhost
  32.  
  33.  
  34. # Describe the sink
  35. step1.sinks.file-sink.type = hdfs
  36. step1.sinks.file-sink.hdfs.path = /user/cloudera/problem7/sink
  37. step1.sinks.file-sink.hdfs.fileType = DataStream
  38. step1.sinks.file-sink.hdfs.fileSuffix = .avro
  39. step1.sinks.file-sink.serializer = avro_event
  40. step1.sinks.file-sink.serializer.compressionCodec=snappy
  41.  
  42. # Describe the type of channel -- Use memory channel if jdbc channel does not work
  43. step1.channels.jdbc-channel.type = jdbc
  44.  
  45. # Bind the source and sink to the channel
  46. step1.sources.avro-source.channels = jdbc-channel
  47. step1.sinks.file-sink.channel = jdbc-channel
  48.  
  49. // Run the flume agent
  50.  
  51. flume-ng agent --name step1 --conf . --conf-file f.config
  52.  
  53. // Run the flume Avro client
  54.  
  55. flume-ng avro-client -H localhost -p 11112 -F <<Provide your avro file path here>>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement