忍者ブログ
×

[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。

splunkのようなログ解析ツールにgraylogというのがあるらしい。

それを動かすには2つの方法があり、1つは仮想アプライアンスで
出来合いのものを動かす方法。
もう一つは、rpm等を使ってサーバにインストールする方法だそうだ。

仮想アプライアンスは後で試すとして、とりあえず、CentOS7にインストールしてみる。

インストールする際には、JDKとElasticsearch、MongoDBのインストールが必要らしい。

1.JDKのインストール
まず、jdk-8u101-linux-x64.rpmのダウンロード

# wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u101-b13/jdk-8u101-linux-x64.rpm

ダウンロードしたらインストールする
# rpm -ihv jdk-8u101-linux-x64.rpm

2.elasticsearchのインストール
次にElasticsearchをインストールする。

まず、リポジトリを追加
# rpm --import https://packages.elastic.co/GPG-KEY-elasticsearch
# cat << EOF > /etc/yum.repos.d/elasticsearch.repo
[elasticsearch-2.x]
name=Elasticsearch repository for 2.x packages
baseurl=https://packages.elastic.co/elasticsearch/2.x/centos
gpgcheck=1
gpgkey=https://packages.elastic.co/GPG-KEY-elasticsearch
enabled=1
EOF

用意ができたらインストール
# yum install elasticsearch

# systemctl daemon-reload
# systemctl enable elasticsearch

確認してみる。
# systemctl list-unit-files | grep elastic
elasticsearch.service                         enabled

elasticsearchの設定変更

# cp /etc/elasticsearch/elasticsearch.yml{,.bk}
# cat <<EOF >> /etc/elasticsearch/elasticsearch.yml
cluster.name: graylog
script.inline: false
script.indexed: false
script.file: false
EOF

elasticsearch再起動
# service elasticsearch restart

ちゃんと起動しているかどうか確認
# curl -X GET http://localhost:9200
{
  "name" : "Fallen One",
  "cluster_name" : "graylog",
  "cluster_uuid" : "XWGjyKT6QaOSixynaJLG_A",
  "version" : {
    "number" : "2.4.4",
    "build_hash" : "fcbb46dfd45562a9cf00c604b30849a6dec6b017",
    "build_timestamp" : "2017-01-03T11:33:16Z",
    "build_snapshot" : false,
    "lucene_version" : "5.5.2"
  },
  "tagline" : "You Know, for Search"
}

# curl -XGET 'http://localhost:9200/_cluster/health?pretty=true'
{
  "cluster_name" : "graylog",
  "status" : "green",
  "timed_out" : false,
  "number_of_nodes" : 1,
  "number_of_data_nodes" : 1,
  "active_primary_shards" : 0,
  "active_shards" : 0,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 0,
  "delayed_unassigned_shards" : 0,
  "number_of_pending_tasks" : 0,
  "number_of_in_flight_fetch" : 0,
  "task_max_waiting_in_queue_millis" : 0,
  "active_shards_percent_as_number" : 100.0
}
#

3.MongoDBのインストール

# cat <<"EOF" > /etc/yum.repos.d/mongodb-org-3.2.repo
[mongodb-org-3.2]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.2/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.2.asc
EOF
# yum install mongodb-org

サービス起動
# systemctl start mongod
# systemctl enable mongod

4.graylogのインストール

リポジトリの取得
# wget https://packages.graylog2.org/repo/packages/graylog-2.0-repository_latest.rpm

リポジトリをインストール
# rpm -ivh graylog-2.0-repository_latest.rpm

# yum install graylog-server

# yum -y install epel-release
# yum -y install pwgen
# sed -e "/^password_secret/c password_secret = $(pwgen -N 1 -s 96)" \
    -e "/^root_password_sha2 /c root_password_sha2 = $(echo -n P@ssw0rd | sha256sum | awk '{print $1}')" \
    -e "/^#root_email/c root_email = root@localhost" \
    -e "/^root_timezone/c root_timezone = Japan" \
    -e "/^elasticsearch_discovery_zen_ping_unicast_hosts/c elasticsearch_discovery_zen_ping_unicast_hosts = $(hostname -I | xargs -n 1 | xargs -I{} echo {}:9300 | tr '\n' ',' | sed 's/,$//g')" \
    -e "/^elasticsearch_max_docs_per_index/c elasticsearch_max_docs_per_index = 20000000" \
    -e "/^elasticsearch_shards/c elasticsearch_shards = 1" \
    -e "/^elasticsearch_replicas/c elasticsearch_replicas = 0" \
    -e "/^rest_listen_uri/c rest_listen_uri = http://192.168.1.10:12900/" \
    -e "/#web_listen_uri/c web_listen_uri = http://192.168.1.10:9000/" \
    -i.bk /etc/graylog/server/server.conf

設定できたらサービスの再起動

# systemctl daemon-reload
# systemctl restart graylog-server
# systemctl enable graylog-server
# systemctl enable elasticsearch

firewallの穴あけをする
# firewall-cmd --permanent --zone=public --add-port=9000/tcp
# firewall-cmd --permanent --zone=public --add-port=12900/tcp
# firewall-cmd --permanent --zone=public --add-port=1514/tcp
# firewall-cmd --reload

ブラウザで、
http://192.168.1.10:9000 にアクセスする。
ID/パスワードは admin と P@ssw0rd ← 上で設定したパスワードにする

PR
この記事にコメントする
お名前
タイトル
文字色
メールアドレス
URL
コメント
パスワード   Vodafone絵文字 i-mode絵文字 Ezweb絵文字
カレンダー
03 2024/04 05
S M T W T F S
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
ブログ内検索
HOME  rsyslogサーバを作る

material:web*citron  template:ゆずろぐ

忍者ブログ [PR]