2024-07-08
한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina
Der Aufgabeninhalt besteht darin, Flume zu installieren und zu konfigurieren sowie Streaming-Daten zu testen und zu sammeln.
Flume wird häufig als Tool zur Echtzeit-Datenerfassung verwendet. Die gesammelten Daten können in HDFS oder einer Nachrichtenwarteschlange wie Kafka gespeichert werden.
Die spezifischen Installationsschritte sind wie folgt:
1. Entpacken Sie das komprimierte Flume-Paket
2. Konfigurieren Sie die Umgebungsvariablen von Flume
3. Ändern Sie die Flume-Konfigurationsdatei. Die Flume-Konfigurationsdatei wird in conf im Flume-Installationsverzeichnis gespeichert.
4. Erhalten Sie die von Flume gesammelten Daten durch Remote-Anmeldung
5. Speichern Sie die von Flume gesammelten Daten in HDFS
Sie finden das Installationspaket im Verzeichnis /opt/software/, entpacken Sie das Installationspaket und kopieren Sie das Installationspaket in das Verzeichnis /opt/app
Auf Master1 ausführen:
[root@master1 ~]# cd /opt/software/
[root@master1 software]# tar -xzf apache-flume-1.9.0-bin.tar.gz -C /opt/app/
Bearbeiten Sie die Datei /etc/profile, deklarieren Sie den Home-Pfad von Flume und fügen Sie den Bin-Pfad zum Pfad hinzu:
export FLUME_HOME=/opt/app/apache-flume-1.9.0-bin
export PATH=$PATH:$FLUME_HOME/bin
Laden Sie die Konfigurationsdatei /etc/profile und bestätigen Sie, dass sie wirksam wird
[root@master1 ~]# source /etc/profile
[root@master1 ~]# echo $FLUME_HOME
Kopieren Sie flume-env.sh.template, benennen Sie es in flume-env.sh unter $FLUME_HOME/conf um und ändern Sie die Konfigurationsdatei 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
Hängen Sie den folgenden Inhalt am Ende der Konfigurationsdatei an:
JAVA_HOME=/opt/app/jdk1.8.0_181
JAVA_OPTS="-Xms100m -Xmx200m -Dcom.sun.management.jmxremote"
Ändern Sie die Flume-Conf-Konfigurationsdatei
Ändern Sie die Datei flume-conf.properties.template im Verzeichnis $FLUME_HOME/conf, kopieren Sie sie und benennen Sie sie in flume-conf.properties um
[root@master1 ~]# cd $FLUME_HOME/conf
[root@master1 conf]# cp flume-conf.properties.template flume-conf.properties
[root@master1 conf]# vi flume-conf.properties
Ändern Sie den Inhalt der flume-conf-Konfigurationsdatei wie folgt:
# 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
Im Flume-Installationsverzeichnis ausführen
[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
Öffnen Sie ein anderes Terminal und geben Sie den folgenden Befehl ein:
[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 '^]'.
Geben Sie im Terminal Folgendes ein:
Hello