Graylog 部署(Centos + MongoDB + Graylog 3.2 + Elasticsearch )

CentOS6 或7或更高都可以

1.安裝 MongoDB

手動建立 mongodb repo 源,如果沒有安裝 vim,則先執行

yum install vim

在線安裝mongodb

vim /etc/yum.repos.d/mongodb-org-3.6.repo

配置如下

[mongodb-org-3.6] 
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.6/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.6.asc

執行安裝

yum install mongodb-org

查看mongo安裝位置 :

whereis mongod

離線安裝mongodb

https://www.mongodb.com/try/download/community
選擇合適的版本
在這裏插入圖片描述
此處離線用的是3.2.1
https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.2.10.tgz

然後執行解壓,重命名

查看修改配置文件 :

 vim /etc/mongod.conf

修改數據存儲路徑
將文件中dbPath修改爲自己指定的路徑

dbPath: /data1/ViewLog/database/mongodb/mongo

端口修改,也可以默認不改

net:
  port: 27317

啓動MongoDB

sudo /usr/bin/mongod -config /etc/mongod.conf

在這裏插入圖片描述
訪問 MongoDB 服務器

/usr/bin/mongod 

在這裏插入圖片描述
停止 MongoDB 服務器

sudo /usr/bin/mongod -shutdown -config /etc/mongod.conf

命令:

mongo 

查看數據庫:

show dbs

在這裏插入圖片描述

2.安裝Elasticsearch

下載elasticsearch
https://www.elastic.co/cn/downloads/elasticsearch 添加鏈接描述
Graylog目前對7支持還有問題,建議下6的
歷史版本下載地址

https://www.elastic.co/cn/downloads/past-releases#elasticsearch

我選擇6.8.5

上傳至服務器並解壓到指定目錄

tar -zxvf elasticsearch-6.8.5.tar.gz -C ../module/

重命名

mv elasticsearch-6.8.5/ elasticsearch/
cd elasticsearch/

添加數據目錄

mkdir data

修改配置文件

vim config/elasticsearch.yml
#修改集羣名
cluster.name: grayloges
#修改節點名
node.name: node-log1
#修改數據的存儲目錄
path.data: /data1/ViewLog/module/elasticsearch/data
#修改日誌的存儲目錄
path.logs: /data1/ViewLog/module/elasticsearch/logs
#設置綁定的ip,和redis一個道理,設置爲0.0.0.0以後就可以讓任何計算機節點訪問到你了
network.host: 0.0.0.0
# Set a custom port for HTTP:
#不修改就是默認端口
#http.port: 9200

設置資源參數

vi /etc/security/limits.conf

修改如下

* soft nofile 65536
* hard nofile 131072
* soft nproc 65536
* hard nproc 131072

設置用戶資源參數

vim /etc/security/limits.d/90-nproc.conf

將“ soft nproc 1024”改爲“* soft nproc 4096”*

*   soft    nproc   4096

配置完成後進入bin目錄執行啓動腳本elasticsearch

 cd bin/

前臺啓動

./elasticsearch

後臺啓動

   ./elasticsearch  -d

報錯1

java.lang.RuntimeException: can not run elasticsearch as root
        at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:111)
        at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:178)
        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:393)
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:170)
        at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:161)
        at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86)
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:127)
        at org.elasticsearch.cli.Command.main(Command.java:90)
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:126)
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92)

解決辦法:
創建一個獨立的用戶,比如elk來啓動elasticsearch,不用root用戶啓動、

報錯2

java.lang.UnsupportedOperationException: seccomp unavailable: CONFIG_SECCOMP not compiled into kernel, CONFIG_SECCOMP and CONFIG_SECCOMP_FILTER are needed

錯誤描述:

ElasticSearch集羣啓動錯誤,錯誤的原因是:因爲Centos6不支持SecComp,而ES默認bootstrap.system_call_filter爲true進行檢測,所以導致檢測失敗,失敗後直接導致ES不能啓動解決:修改elasticsearch.yml

問題解決:

在所有節點的elasticsearch.yml配置文件中加入:

bootstrap.memory_lock: false
bootstrap.system_call_filter: false

後臺啓動

./elasticsearch  -d

web查看

ip:9200

在這裏插入圖片描述

3.安裝Graylog

下載Graylog

https://www.graylog.org/downloads
解壓到指定文件夾並重命名

修改配置文件
修改安裝目錄下的graylog.conf.example

vim graylog.conf.example 
#時區
root_timezone = Asia/Shanghai
#pssworde_secret可以通過命令:pwgen -N 1 -s 96 來隨機生成,下面就是我隨機生成的
password_secret =UQUOMnZvVGCUsEc5u8tYCCnBjMvtiAQfYOmTcXhGdie8R5OZ7Xxx6WycyWdsqA7IWIF4TjCCQEY0xnvhmvMSb4OqG3LvdQUg
# 生成後,請記住你的 YourPassword
#echo -n "Enter Password: " && head -1 </dev/stdin | tr -d '\n' | sha256sum | cut -d" " -f1
root_password_sha2 =1b5c432b094de3ff79b9296d09347841f38b9cdbea019399c7ed54abba92e975
# elasticsearch 相關配置
elasticsearch_hosts = http://127.0.0.1:9200
elasticsearch_shards =1  
elasticsearch_replicas = 0
# mongodb 連接配置,這裏直接本機起的mongodb,沒有設置驗證
mongodb_uri = mongodb://localhost/graylog
# 網絡訪問相關,重要,graylog3比2.x版本簡潔了很多網絡配置,只需配置http_bind_address即可。
http_bind_address = 0.0.0.0:9000

修改配置文件
因爲graylog安裝bin目錄下,默認啓動配置文件
在這裏插入圖片描述
配置文件路徑 /etc/graylog/server/server.conf
所以需要將graylog.conf.example 複製到/etc/graylog/server/目錄下,並改名爲server.conf
執行命令

 mkdir -p /etc/graylog/server/

啓動Graylog

進入graylog目錄下

 ./graylogctl start

查看Graylog運行日誌
在graylog安裝目錄下執行

 tail -200f log/graylog-server.log 

使用ip:9000 進行訪問
在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章