Fluentd插件使用方法

这里主要介绍从MongoDB同步数据到ODPS。ruby环境的搭建以及fluent_plugin_mongo_odps插件的安装。
1.准备工作
1.1安装环境要求
Ruby 2.1以上
Gem 2.4.5以上
1.2 ruby的安装首先查看你的Linux系统是否安装了ruby可以用下面两个命令查询
rpm -qa | grep ruby 

yum list | grep ruby
1.3 安装一些依赖环境
执行下面的命令:
yum install gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison iconv-devel wget tar

1.4 安装ruby步骤
(1) cd ~/
(2)wget https://ruby.taobao.org/mirrirs/ruby/ruby-2.2.3.tar.gz
(3) tar –zxvf ruby-2.2.3.rar.gz
(4) cd ruby-2.2.3
(5) ./configure
(6) make
(7) make install
1.5 修改gem库源
由于国内gem库源被墙了,访问有问题,所以将gem库换成淘宝的gem镜像源
(1) 查看当前的源地址
输入:gem sources 默认:https://rubygems.org/
(2) 删除默认的源地址
输入:gem sources –r https://rubygems.org/
注:默认的url地址后必须有”/”,否则删不掉。

(3) 添加淘宝的镜像库
输入:gem sources -a https://ruby.taobao.org/
注:国内使用淘 宝的源比较稳定,且安装或更新网速都比较快
(4) 更新源的缓存
输入:gem sources –u
更新源的缓存后即完成了Ruby的gem源修改。
最后输入 gem sources –l

2.安装Fluent-plugin-aliyun-odps
通过gem直接下载插件
输入:gem install fluent-plugin-aliyun-odps
查找默认安装路径
输入:whereis ruby
(/usr/local/lib/ruby/gems/2.2.0/gems)
screenshot

3.安装ruby driver
执行下面的命令:(A Ruby driver for MongoDB)
gem install mango

  1. 安装fluent-plugin-mongo 插件:
  2. install fluent-plugin-mongo
  3. fluent_mongo_odps.conf配置文件

type mongo_tail
host 172.16.1.157
port 27017
database test
collection mongo_small

adapter mongo
tag app.mongo

#user root
#password root

# waiting time when there is no next document. default is 1s.
wait_time 5

# Convert 'time'(BSON's time) to fluent time(Unix time).
time_key time

#disable_collection_check true


type aliyun_odps
aliyun_access_id OERGMhXn6H2mBkhk
aliyun_access_key qnuSKMKoMcY5Va97GGFtL0nvlAoLZx
aliyun_odps_endpoint http://service.odps.aliyun.com/api
aliyun_odps_hub_endpoint http://dh.odps.aliyun.com
buffer_chunk_limit 2m
buffer_queue_limit 128
flush_interval 5s
project dtstack_dev

  1. 在fluent的bin目录下启动fluent插件:
  2. –c fluent_mysql_odps.conf

执行命令,出现 Successfully import …. 表示同步数据成功
screenshot

问题1:
2016-05-27 11:12:47 +0800 [error]: unexpected error error_class=Fluent::ConfigError error=#
screenshot

解决方法:
这个问题就是导入的数据源mongo_tail只支持capped collection的数据,新建一个capped collection问题就解决了。

猜你喜欢

转载自www.cnblogs.com/dtstack/p/10271135.html