Tüm Ürünler
Search
Belge Merkezi

Object Storage Service:Flume ile JindoSDK Kullanarak OSS-HDFS Hizmetine Veri Yazma

Son Güncelleme:Oct 01, 2026

Apache Flume; dağıtık, güvenilir ve yüksek kullanılabilirliğe (HA) sahip bir sistemdir. Çok sayıda farklı veri kaynağından gelen büyük miktarda günlük verisini merkezi bir veri deposuna etkili bir şekilde toplar, birleştirir ve taşır. Flume, işlemsel yazmaları garanti altına almak için flush() çağrılarını kullanır. OSS-HDFS hizmetine veri yazmak için JindoSDK kullandığınızda, veriler flush işleminden hemen sonra görünür hale gelir; bu durum veri kaybını önler.

Ön Koşullar

Yordam

  1. ECS örneğine bağlanın. Daha fazla bilgi için bkz. ECS örneğine bağlanma.

  2. JindoSDK'yı yapılandırın.

    1. En son JindoSDK JAR paketini indirin. İndirme bağlantısı için bkz. GitHub.

    2. İndirilen kurulum paketini açın.

      Aşağıdaki örnek, jindosdk-x.x.x-linux.tar.gz dosyasının nasıl açılacağını göstermektedir. Farklı bir JindoSDK sürümü kullanıyorsanız paket adını gerçek adla değiştirin.

      tar -zxvf jindosdk-x.x.x-linux.tar.gz -C /usr/lib
    3. JINDOSDK_HOME ortam değişkenini yapılandırın.

      export JINDOSDK_HOME=/usr/lib/jindosdk-x.x.x-linux
      export PATH=$JINDOSDK_HOME/bin:$PATH
    4. HADOOP_CLASSPATH ortam değişkenini yapılandırın.

      export HADOOP_CLASSPATH=$HADOOP_CLASSPATH:${FLUME_HOME}/lib/*
      Önemli

      Gerekli dosyaları her düğümde Flume kök dizinindeki lib klasörüne dağıtın ve ortam değişkenlerini ayarlayın.

    5. FLUME_CLASSPATH ortam değişkenini yapılandırın.

      cp ${FLUME_HOME}/conf/flume-env.sh.template ${FLUME_HOME}/conf/flume-env.sh
      echo "FLUME_CLASSPATH=/usr/lib/jindosdk-x.x.x-linux/lib/*" >>  ${FLUME_HOME}/conf/flume-env.sh
  3. Sink'i yapılandırın.

    Aşağıdaki kod, sink yapılandırmasına bir örnek sunar:

    # Configure the OSS sink. Set your_bucket to a bucket for which the OSS-HDFS service is enabled.
    xxx.sinks.oss_sink.hdfs.path = oss://${your_bucket}/flume_dir/%Y-%m-%d/%H
    
    # The maximum number of events in a Flume transaction. Flush at least 32 MB of data at a time to prevent small flushes from affecting overall performance and generating many staging files.
    # The unit of batchSize is the number of events, which is the number of log entries. To set this parameter, first estimate the average event size. For example, if the average event size is 200 bytes and you expect to flush 32 MB of data at a time, set batchSize to approximately 160,000 (32 MB / 200 bytes).
    xxx.sinks.oss_sink.hdfs.batchSize = 100000
    
    ...
    # Specifies whether to partition Hadoop Distributed File System (HDFS) files by time and round down the timestamp. The default value is true.
    xxx.sinks.oss_sink.hdfs.round = true
    # This parameter is used with xxx.sinks.oss_sink.hdfs.roundUnit when xxx.sinks.oss_sink.hdfs.round is set to true. For example, if xxx.sinks.oss_sink.hdfs.roundUnit is set to minute and this parameter is set to 60, data within a 60-minute period is written to a single file. This means a new file is generated every 60 minutes.
    xxx.sinks.oss_sink.hdfs.roundValue = 15
    # The time unit for time-based partitioning. Default value: minute. Valid values: second, minute, and hour.
    xxx.sinks.oss_sink.hdfs.roundUnit = minute
    # The fixed prefix for new files that Flume creates in the HDFS folder.
    xxx.sinks.oss_sink.hdfs.filePrefix = your_topic
    # The file size in bytes that triggers a file roll. A new file is created when the current file reaches this size. A value of 0 indicates that files are not split by size.
    xxx.sinks.oss_sink.rollSize = 3600
    # The number of threads that each sink instance opens for HDFS I/O operations, such as open and write.
    xxx.sinks.oss_sink.threadsPoolSize = 30
    ...

    Sink yapılandırma parametreleri hakkında daha fazla bilgi için bkz. Apache Flume.

SSS

Hata: "org.apache.flume.conf.ConfigurationException: Component has no type. Cannot configure.user_sink"

Bu sorunu çözmek için Hadoop core-site.xml dosyasına aşağıdaki yapılandırmayı ekleyin.

<!-- Configure the JindoOSS implementation class -->
fs.AbstractFileSystem.oss.impl com.aliyun.jindodata.oss.OSS 
fs.oss.impl com.aliyun.jindodata.oss.OssFileSystem
<!-- Configure the AccessKey and Endpoint -->
fs.oss.credentials.provider com.aliyun.jindodata.auth.SimpleAliyunCredentialsProvider 
fs.oss.accessKeyId LTAI******** 
fs.oss.accessKeySecret KZo1********
fs.oss.endpoint {regionId}.oss-dls.aliyuncs.com