Skip to content

Instantly share code, notes, and snippets.

@ruo91
Created October 13, 2013 14:30
Show Gist options
  • Save ruo91/6962973 to your computer and use it in GitHub Desktop.
Save ruo91/6962973 to your computer and use it in GitHub Desktop.
mongodb test import
일단 이건 테스트
logs 데이터베이스에 nginx json 로그를 import
[root@dev mongodb]# mongoimport --host localhost --db logs --collection logs < /usr/local/nginx/logs/mirror-json-access.log
connected to: localhost
Sun Oct 13 23:25:01.874 check 9 4688
Sun Oct 13 23:25:01.891 imported 4688 objects
쿼리 해서 값이 잘 들어갔는지 확인
[root@dev mongodb]# mongo
MongoDB shell version: 2.4.6
connecting to: test
> use logs
switched to db logs
> db.logs.find()
{ "_id" : ObjectId("525aad3dcfec889eefa98339"), "@timestamp" : "2013-10-13T22:54:14+09:00", "@fields" : { "country" : "US", "host" : "74.63.198.226", "status" : "200", "request" : "GET /elrepo/elrepo/el5/x86_64/repodata/repomd.xml HTTP/1.1", "size" : "2535", "user-agent" : "urlgrabber/3.1.0 yum/3.2.22", "referrer" : "-" } }
{ "_id" : ObjectId("525aad3dcfec889eefa9833a"), "@timestamp" : "2013-10-13T22:54:14+09:00", "@fields" : { "country" : "US", "host" : "66.208.210.29", "status" : "200", "request" : "GET /repoforge/redhat/el5/en/x86_64/rpmforge/repodata/repomd.xml HTTP/1.1", "size" : "1953", "user-agent" : "urlgrabber/3.1.0 yum/3.2.22", "referrer" : "-" } }
{ "_id" : ObjectId("525aad3dcfec889eefa9833b"), "@timestamp" : "2013-10-13T22:54:14+09:00", "@fields" : { "country" : "CY", "host" : "164.215.18.143", "status" : "200", "request" : "GET /tex-archive/systems/win32/miktex/tm/packages/tikzmark.tar.lzma HTTP/1.1", "size" : "420088", "user-agent" : "MPM/2.9.4240", "referrer" : "-" } }
{ "_id" : ObjectId("525aad3dcfec889eefa9833c"), "@timestamp" : "2013-10-13T22:54:14+09:00", "@fields" : { "country" : "US", "host" : "209.54.52.232", "status" : "200", "request" : "GET /repoforge/redhat/el5/en/i386/rpmforge/repodata/repomd.xml HTTP/1.1", "size" : "1953", "user-agent" : "urlgrabber/3.1.0 yum/3.2.22", "referrer" : "-" } }
{ "_id" : ObjectId("525aad3dcfec889eefa9833d"), "@timestamp" : "2013-10-13T22:54:15+09:00", "@fields" : { "country" : "US", "host" : "74.63.198.226", "status" : "200", "request" : "GET /repoforge/redhat/el5/en/x86_64/rpmforge/repodata/repomd.xml HTTP/1.1", "size" : "1953", "user-agent" : "urlgrabber/3.1.0 yum/3.2.22", "referrer" : "-" } }
{ "_id" : ObjectId("525aad3dcfec889eefa9833e"), "@timestamp" : "2013-10-13T22:54:15+09:00", "@fields" : { "country" : "TH", "host" : "112.121.138.194", "status" : "200", "request" : "GET /repoforge/redhat/el6/en/x86_64/rpmforge/repodata/repomd.xml HTTP/1.1", "size" : "1953", "user-agent" : "urlgrabber/3.9.1 yum/3.2.29", "referrer" : "-" } }
{ "_id" : ObjectId("525aad3dcfec889eefa9833f"), "@timestamp" : "2013-10-13T22:54:16+09:00", "@fields" : { "country" : "US", "host" : "66.249.66.32", "status" : "200", "request" : "GET /tex-archive/biblio/bibtex/contrib/achemso/ HTTP/1.1", "size" : "2226", "user-agent" : "Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25 (compatible; Googlebot-Mobile/2.1; +http://www.google.com/bot.html)", "referrer" : "-" } }
{ "_id" : ObjectId("525aad3dcfec889eefa98340"), "@timestamp" : "2013-10-13T22:54:17+09:00", "@fields" : { "country" : "US", "host" : "174.121.162.130", "status" : "200", "request" : "GET /repoforge/redhat/el5/en/x86_64/rpmforge/repodata/repomd.xml HTTP/1.1", "size" : "1953", "user-agent" : "urlgrabber/3.1.0 yum/3.2.22", "referrer" : "-" } }
{ "_id" : ObjectId("525aad3dcfec889eefa98341"), "@timestamp" : "2013-10-13T22:54:17+09:00", "@fields" : { "country" : "SG", "host" : "107.6.115.170", "status" : "200", "request" : "GET /elrepo/elrepo/el5/x86_64/repodata/repomd.xml HTTP/1.1", "size" : "2535", "user-agent" : "urlgrabber/3.1.0 yum/3.2.22", "referrer" : "-" } }
{ "_id" : ObjectId("525aad3dcfec889eefa98342"), "@timestamp" : "2013-10-13T22:54:17+09:00", "@fields" : { "country" : "US", "host" : "174.77.158.50", "status" : "200", "request" : "GET /elrepo/elrepo/el5/x86_64/repodata/repomd.xml HTTP/1.1", "size" : "2535", "user-agent" : "urlgrabber/3.1.0 yum/3.2.22", "referrer" : "-" } }
{ "_id" : ObjectId("525aad3dcfec889eefa98343"), "@timestamp" : "2013-10-13T22:54:17+09:00", "@fields" : { "country" : "US", "host" : "206.251.242.116", "status" : "200", "request" : "GET /elrepo/elrepo/el5/i386/repodata/repomd.xml HTTP/1.1", "size" : "2538", "user-agent" : "urlgrabber/3.1.0 yum/3.2.22", "referrer" : "-" } }
{ "_id" : ObjectId("525aad3dcfec889eefa98344"), "@timestamp" : "2013-10-13T22:54:17+09:00", "@fields" : { "country" : "SG", "host" : "107.6.115.170", "status" : "200", "request" : "GET /repoforge/redhat/el5/en/x86_64/rpmforge/repodata/repomd.xml HTTP/1.1", "size" : "1953", "user-agent" : "urlgrabber/3.1.0 yum/3.2.22", "referrer" : "-" } }
{ "_id" : ObjectId("525aad3dcfec889eefa98345"), "@timestamp" : "2013-10-13T22:54:22+09:00", "@fields" : { "country" : "US", "host" : "216.116.66.5", "status" : "200", "request" : "GET /elrepo/elrepo/el6/x86_64/repodata/53824b5405a78bbd67958f5f31072b8eb00e32bcb6196a9b96c0d8917a732989-filelists.sqlite.bz2 HTTP/1.1", "size" : "114150", "user-agent" : "urlgrabber/3.9.1 yum/3.2.29", "referrer" : "-" } }
{ "_id" : ObjectId("525aad3dcfec889eefa98346"), "@timestamp" : "2013-10-13T22:54:22+09:00", "@fields" : { "country" : "HK", "host" : "113.253.239.15", "status" : "200", "request" : "GET /repoforge/redhat/el5/en/x86_64/rpmforge/repodata/repomd.xml HTTP/1.1", "size" : "1953", "user-agent" : "urlgrabber/3.1.0 yum/3.2.22", "referrer" : "-" } }
{ "_id" : ObjectId("525aad3dcfec889eefa98347"), "@timestamp" : "2013-10-13T22:54:23+09:00", "@fields" : { "country" : "CY", "host" : "164.215.18.143", "status" : "200", "request" : "GET /tex-archive/systems/win32/miktex/tm/packages/gentium-tug.tar.lzma HTTP/1.1", "size" : "5245928", "user-agent" : "MPM/2.9.4240", "referrer" : "-" } }
{ "_id" : ObjectId("525aad3dcfec889eefa98348"), "@timestamp" : "2013-10-13T22:54:23+09:00", "@fields" : { "country" : "GB", "host" : "217.168.20.15", "status" : "200", "request" : "GET /repoforge/redhat/el5/en/x86_64/rpmforge/repodata/repomd.xml HTTP/1.1", "size" : "1953", "user-agent" : "urlgrabber/3.1.0 yum/3.2.22", "referrer" : "-" } }
{ "_id" : ObjectId("525aad3dcfec889eefa98349"), "@timestamp" : "2013-10-13T22:54:24+09:00", "@fields" : { "country" : "BE", "host" : "178.116.3.168", "status" : "200", "request" : "GET /tex-archive/systems/win32/miktex/tm/packages/hyperref.tar.lzma HTTP/1.1", "size" : "3848099", "user-agent" : "MPM/2.9.4240", "referrer" : "-" } }
{ "_id" : ObjectId("525aad3dcfec889eefa9834a"), "@timestamp" : "2013-10-13T22:54:24+09:00", "@fields" : { "country" : "IE", "host" : "54.247.188.179", "status" : "200", "request" : "HEAD / HTTP/1.1", "size" : "0", "user-agent" : "NewRelicPinger/1.0 (338489)", "referrer" : "-" } }
{ "_id" : ObjectId("525aad3dcfec889eefa9834b"), "@timestamp" : "2013-10-13T22:54:25+09:00", "@fields" : { "country" : "CY", "host" : "164.215.18.143", "status" : "200", "request" : "GET /tex-archive/systems/win32/miktex/tm/packages/xevlna.tar.lzma HTTP/1.1", "size" : "57472", "user-agent" : "MPM/2.9.4240", "referrer" : "-" } }
{ "_id" : ObjectId("525aad3dcfec889eefa9834c"), "@timestamp" : "2013-10-13T22:54:25+09:00", "@fields" : { "country" : "IT", "host" : "78.134.2.255", "status" : "200", "request" : "GET /repoforge/redhat/el5/en/i386/rpmforge/repodata/repomd.xml HTTP/1.1", "size" : "1953", "user-agent" : "urlgrabber/3.1.0 yum/3.2.22", "referrer" : "-" } }
Type "it" for more
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment