| 76 | |
| 77 | == MongoDBでログを管理 |
| 78 | |
| 79 | MongoDBでログを管理すると、クエリーなどで検索できるので使いやすくなる。 |
| 80 | |
| 81 | MongoDBをインストールする。 |
| 82 | |
| 83 | {{{ |
| 84 | # yum install epel-release |
| 85 | # yum install mongodb mongodb-server |
| 86 | # systemctl start mongod.service |
| 87 | }}} |
| 88 | |
| 89 | ログ用のデータベース作成 |
| 90 | |
| 91 | {{{ |
| 92 | # mongo openstack-log |
| 93 | MongoDB shell version: 2.6.11 |
| 94 | connecting to: openstack-log |
| 95 | > use openstack-log |
| 96 | switched to db openstack-log |
| 97 | }}} |
| 98 | |
| 99 | Fluentdの設定 |
| 100 | |
| 101 | {{{ |
| 102 | <match nova-api.log> |
| 103 | type mongo |
| 104 | database openstack-log |
| 105 | collection log |
| 106 | host localhost |
| 107 | port 27017 |
| 108 | flush_interval 10s |
| 109 | </match> |
| 110 | }}} |
| 111 | |
| 112 | ログの確認 |
| 113 | |
| 114 | {{{ |
| 115 | # mongo openstack-log |
| 116 | MongoDB shell version: 2.6.11 |
| 117 | connecting to: openstack-log |
| 118 | > show collections; |
| 119 | log |
| 120 | system.indexes |
| 121 | > db.log.find(); |
| 122 | { "_id" : ObjectId("563de070e138230994000001"), "date" : "2016-05-21 13:01:55.215 6322", "level" : "INFO", "class" : "nova-api.osapi_compute.wsgi.server", "tag" : "-", "message" : "(6322) accepted ('192.168.66.128', 42247)", "time" : ISODate("2015-11-07T07:34:56Z") } |
| 123 | .... |
| 124 | }}} |