Skip to content

Instantly share code, notes, and snippets.

@ngsw
Created August 26, 2012 15:39
Show Gist options
  • Select an option

  • Save ngsw/3481196 to your computer and use it in GitHub Desktop.

Select an option

Save ngsw/3481196 to your computer and use it in GitHub Desktop.
flunetd mongoDB test
## http://d.hatena.ne.jp/mikeda/20120826/1345972294
## http://d.hatena.ne.jp/wyukawa/20120207/1328625443
## http://www.mongodb.org/pages/viewpage.action?pageId=18907495
## http://taka512.hatenablog.com/entry/20110220/1298195574
cat >> /etc/yum.repos.d/td.repo <<'EOF'
[tdrepo]
name=treasuredata
baseurl=http://packages.treasure-data.com/redhat/$basearch
gpgcheck=0
enable=0
EOF
yum -y install --enablerepo=tdrepo td-agent
/usr/lib64/fluent/ruby/bin/fluent-gem install fluentd
cp /etc/td-agent/td-agent.conf{,_orig}
cat > /etc/td-agent/td-agent.conf <<'EOF'
<source>
type tcp
</source>
<match debug.**>
type file
path /var/log/fluent/debug
</match>
EOF
mkdir /var/log/fluent
chown td-agent:td-agent /var/log/fluent
/etc/init.d/td-agent start
echo '{"debug":"test"}'| /usr/lib64/fluent/ruby/bin/fluent-cat debug.test
echo '{"debug":"info"}'| /usr/lib64/fluent/ruby/bin/fluent-cat debug.info
cat >> /etc/td-agent/td-agent.conf <<'EOF'
<source>
type tail
format apache
path /var/log/nginx/access.log
tag nginx.access
</source>
<match nginx.access>
type file
path /var/log/fluent/nginx_access_log
</match>
EOF
/etc/init.d/td-agent restart
wget http://localhost/ -O - > /dev/null
cat /var/log/fluent/nginx_access_log
cat >> /etc/yum.repos.d/10gen.repo <<'EOF'
[10gen]
name=10gen Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64
gpgcheck=0
enable=0
EOF
yum -y install --enablerepo=10gen mongo-10gen-server
/etc/init.d/mongod start
mongo
> show dbs;
> exit
/usr/lib64/fluent/ruby/bin/fluent-gem install fluent-plugin-mongo
cat >> /etc/td-agent/td-agent.conf <<'EOF'
<source>
type tail
format apache
path /var/log/httpd/access_log
tag mongo.apache
</source>
<match mongo.**>
# plugin type
type mongo
# mongodb db + collection
database apache
collection access
# mongodb host + port
host localhost
port 27017
# interval
flush_interval 10s
</match>
EOF
/etc/init.d/td-agent restart
wget http://localhost/ -O - > /dev/null
mongo
> show dbs;
> use nginx;
> show collections;
> db.access.find();
> db.access.count();
> exit
ab -n 100 -c 10 http://192.168.1.102/
mongo
> show dbs;
> use nginx;
> show collections;
> db.access.find();
> db.access.count();
> exit
### /usr/lib64/fluent/ruby/bin/fluent-gem
### /etc/td-agent/td-agent.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment