2024-07-08
한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina
Konten tugasnya adalah menginstal dan mengonfigurasi Flume, serta menguji dan mengumpulkan data streaming.
Flume sering digunakan sebagai alat pengumpulan data waktu nyata. Data yang dikumpulkan dapat disimpan dalam HDFS atau antrian pesan seperti Kafka.
Langkah-langkah instalasi spesifiknya adalah sebagai berikut:
1. Buka zip paket terkompresi Flume
2. Konfigurasikan variabel lingkungan Flume
3. Ubah file konfigurasi Flume. File konfigurasi Flume disimpan di conf di direktori instalasi Flume.
4. Dapatkan data yang dikumpulkan oleh Flume melalui login jarak jauh
5. Simpan data yang dikumpulkan oleh Flume ke dalam HDFS
Anda dapat menemukan paket instalasi di direktori /opt/software/, unzip paket instalasi dan salin paket instalasi ke direktori /opt/app
Jalankan di master1:
[root@master1 ~]# cd /opt/software/
[root@master1 software]# tar -xzf apache-flume-1.9.0-bin.tar.gz -C /opt/app/
Edit file /etc/profile dan nyatakan jalur beranda Flume dan tambahkan jalur bin ke jalur:
export FLUME_HOME=/opt/app/apache-flume-1.9.0-bin
export PATH=$PATH:$FLUME_HOME/bin
Muat file konfigurasi /etc/profile dan konfirmasikan bahwa file tersebut berlaku
[root@master1 ~]# source /etc/profile
[root@master1 ~]# echo $FLUME_HOME
Salin dan ganti nama flume-env.sh.template menjadi flume-env.sh di bawah $FLUME_HOME/conf, dan ubah file konfigurasi conf/flume-env.sh
[root@master1 ~]# cd $FLUME_HOME/conf
[root@master1 conf]# cp flume-env.sh.template flume-env.sh
[root@master1 conf]# vi flume-env.sh
Tambahkan konten berikut di akhir file konfigurasi:
JAVA_HOME=/opt/app/jdk1.8.0_181
JAVA_OPTS="-Xms100m -Xmx200m -Dcom.sun.management.jmxremote"
Ubah file konfigurasi flume-conf
Ubah file flume-conf.properties.template di direktori $FLUME_HOME/conf, salin dan ganti namanya menjadi flume-conf.properties
[root@master1 ~]# cd $FLUME_HOME/conf
[root@master1 conf]# cp flume-conf.properties.template flume-conf.properties
[root@master1 conf]# vi flume-conf.properties
Ubah konten file konfigurasi flume-conf sebagai berikut:
# The configuration file needs to define the sources, the channels and the sinks.
# Sources, channels and sinks are defined per agent, in this case called 'a1'
a1.sources = r1
a1.sinks = k1
a1.channels = c1
# For each one of the sources, the type is defined
a1.sources.r1.type = netcat
a1.sources.r1.bind = localhost
a1.sources.r1.port = 44444
#The channel can be defined as follows.
a1.sources.r1.channels = c1
# Each sink's type must be defined
a1.sinks.k1.type = logger
#Specify the channel the sink should use
a1.sinks.k1.channel = c1
# Each channel's type is defined.
a1.channels.c1.type = memory
# Other config values specific to each type of channel(sink or source)
# can be defined as well
# In this case, it specifies the capacity of the memory channel
a1.channels.c1.capacity = 1000
a1.channels.c1.transactionCapacity = 100
Jalankan di direktori instalasi Flume
[root@master1 conf]# cd $FLUME_HOME
[root@master1 apache-flume-1.9.0-bin]# flume-ng agent -c ./conf/ -f ./conf/flume-conf.properties -n a1 -Dflume.root.logger=INFO,console
Buka terminal lain dan masukkan perintah berikut:
[root@master1 ~]# telnet localhost 44444
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Masukkan yang berikut ini di terminal:
Hello