- 在 CentOS / RHEL 7 Linux 作業系統上,安裝 Graylog 服務!
- Graylog 為收集系統記錄檔於一部主機上的服務!該服務亦可進行監控與分析的工作!
- Graylog 安裝的主機名稱定為:Systemlog1 !
-
在 Systemlog1主機上,做好升級與事前相關必要軟體安裝工作!
# yum upgrade # yum install epel-release # yum install java-1.8.0-openjdk-headless.x86_64 # yum install pwgen
-
在 Systemlog1 主機上,安裝 MongoDB 套件:
# vim 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 -y mongodb-org # systemctl daemon-reload # systemctl enable mongod.service # systemctl start mongod.service # systemctl status mongod.service -l
-
在 Systemlog1 主機上,安裝 ElasticSearchDB 套件:
# rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch # vim /etc/yum.repos.d/elasticsearch.repo [elasticsearch-5.x] name=Elasticsearch repository for 5.x packages baseurl=https://artifacts.elastic.co/packages/5.x/yum gpgcheck=1 gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch enabled=1 autorefresh=1 type=rpm-md # yum install elasticsearch # vim /etc/elasticsearch/elasticsearch.yml (只修改需要改的部份) cluster.name: graylog # systemctl enable elasticsearch.service # systemctl restart elasticsearch.service # systemctl status elasticsearch.service -l
-
在 Systemlog1 主機上,下載安裝 Graylog 套件:
# rpm -Uvh https://packages.graylog2.org/repo/packages/graylog-2.4-repository_latest.rpm # yum install graylog-server # pwgen -N 1 -s 96 (產生密碼給 password_secret 使用) # echo -n yourpassword | shasum -a 256 (產生密碼給 root_password_sha2 使用) # vim /etc/graylog/server/server.conf (只修改需要修改的部份...) password_secret = (pwgen 產生的密碼) root_username = admin root_password_sha2 = (shawum 產生的密碼) root_timezone = Asia/Taipei rest_listen_uri = http://127.0.0.1:9000/api/ web_listen_uri = http://127.0.0.1:9000/ # systemctl enable graylog-server.service # systemctl start graylog-server.service # yum install policycoreutils-python # systemctl status graylog-server.service -l (啟動應該會失敗!)
-
在 Systemlog1 主機上,修改 SELinux 設定:
# setsebool -P httpd_can_network_connect 1 # semanage port -a -t http_port_t -p tcp 9000 # semanage port -a -t http_port_t -p tcp 9200 # semanage port -a -t mongod_port_t -p tcp 27017 # less /var/log/messages (找到 sealert 部份) # sealert -l XXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX # ausearch -c 'ftdc' --raw | audit2allow -M my-ftdc # ausearch -c 'ftdc' --raw | audit2allow -M my-ftdc # systemctl restart graylog-server.service # systemctl status graylog-server.service -l
-
在 Systemlog1 主機上,修改 Firewall 設定:
# firewall-cmd --add-port=9000/tcp # firewall-cmd --add-port=8514/tcp # firewall-cmd --add-port=514/tcp # firewall-cmd --list-all
- 在 Systemlog1 主機上,使用 firefox ,連線 http://127.0.0.1:9000 即可登入!
Client 設定流程:
-
在 Clients 主機上,修改 rsyslog 設定檔:
# vim /etc/rsyslog.conf (只修改需要的項目:) #### GLOBAL DIRECTIVES #### *.* @@Systemlog1:8514;RSYSLOG_SyslogProtocol23Format # systemctl restart rsyslog
參考文獻:
- 官方安裝文件:http://docs.graylog.org/en/2.4/pages/installation/os/centos.html