2024-07-08
한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina
タスクの内容は、Flume のインストールと設定、ストリーミング データのテストと収集です。
Flume はリアルタイム データ収集のツールとしてよく使用され、収集されたデータは HDFS または Kafka のようなメッセージ キューに保存できます。
具体的なインストール手順は次のとおりです。
1. Flume 圧縮パッケージを解凍します。
2. Flume の環境変数を設定する
3. Flume 構成ファイルを変更します。Flume 構成ファイルは、Flume インストールディレクトリの conf に保存されます。
4. リモートログインを通じて Flume によって収集されたデータを取得する
5. Flume によって収集されたデータを HDFS に保存します
/opt/software/ ディレクトリでインストール パッケージを見つけ、インストール パッケージを解凍して、インストール パッケージを /opt/app ディレクトリにコピーします。
master1 で実行します。
[root@master1 ~]# cd /opt/software/
[root@master1 software]# tar -xzf apache-flume-1.9.0-bin.tar.gz -C /opt/app/
/etc/profile ファイルを編集して Flume のホーム パスを宣言し、bin パスを path に追加します。
export FLUME_HOME=/opt/app/apache-flume-1.9.0-bin
export PATH=$PATH:$FLUME_HOME/bin
設定ファイル /etc/profile をロードし、有効になることを確認します。
[root@master1 ~]# source /etc/profile
[root@master1 ~]# echo $FLUME_HOME
$FLUME_HOME/conf の下に flume-env.sh.template をコピーして名前を flume-env.sh に変更し、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
構成ファイルの最後に次の内容を追加します。
JAVA_HOME=/opt/app/jdk1.8.0_181
JAVA_OPTS="-Xms100m -Xmx200m -Dcom.sun.management.jmxremote"
flume-conf 設定ファイルを変更する
$FLUME_HOME/conf ディレクトリー内の flume-conf.properties.template ファイルを変更し、コピーして名前を 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
flume-conf 構成ファイルの内容を次のように変更します。
# 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
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
別のターミナルを開き、次のコマンドを入力します。
[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 '^]'.
ターミナルに次のように入力します。
Hello