刚开始接触Linux(centos7),安装Graylog3.0花费很长时间,最后还是按照官网的步骤安装成功了,具体步骤如下:
CentOS installation
This guide describes the fastest way to install Graylog on CentOS 7. All links and packages are present at the time of writing but might need to be updated later on.
Warning
This setup should not be done on publicly exposed servers. This guide does not cover security settings!
Prerequisites
Taking a minimal server setup as base will need this additional packages:
$ sudo yum install java-1.8.0-openjdk-headless.x86_64
If you want to use pwgen
later on you need to Setup EPEL on your system with sudo yum install epel-release
and install the package with sudo yum install pwgen
.
MongoDB
Installing MongoDB on CentOS should follow the tutorial for RHEL and CentOS from the MongoDB documentation. First add the repository file /etc/yum.repos.d/mongodb-org.repo
with the following contents:
[mongodb-org-4.0] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.0/x86_64/ gpgcheck=1 enabled=1 gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc
After that, install the latest release of MongoDB with sudo yum install mongodb-org
.
Additionally, run these last steps to start MongoDB during the operating system’s boot and start it right away:
$ sudo systemctl daemon-reload
$ sudo systemctl enable mongod.service
$ sudo systemctl start mongod.service
Elasticsearch
Graylog can be used with Elasticsearch 6.x, please follow the installation instructions from the Elasticsearch installation guide.
First install the Elastic GPG key with rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch then add the repository file /etc/yum.repos.d/elasticsearch.repo with the following contents:
[elasticsearch-6.x] name=Elasticsearch repository for 6.x packages baseurl=https://artifacts.elastic.co/packages/oss-6.x/yum gpgcheck=1 gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch enabled=1 autorefresh=1 type=rpm-md
followed by the installation of the latest release with sudo yum install elasticsearch-oss
.
Make sure to modify the Elasticsearch configuration file (/etc/elasticsearch/elasticsearch.yml
) and set the cluster name to graylog
additionally you need to uncomment (remove the # as first character) the line, and add action.auto_create_index: false
to the configuration file:
cluster.name: graylog action.auto_create_index: false
After you have modified the configuration, you can start Elasticsearch:
$ sudo systemctl daemon-reload
$ sudo systemctl enable elasticsearch.service
$ sudo systemctl restart elasticsearch.service
Graylog
Now install the Graylog repository configuration and Graylog itself with the following commands:
$ sudo rpm -Uvh https://packages.graylog2.org/repo/packages/graylog-3.1-repository_latest.rpm $ sudo yum install graylog-server
Hint
If you want the Integrations Plugins or the Enterprise Plugins installed, you need to install them now. The following install all official provided packages by Graylog at the same time: sudo yum install graylog-server graylog-enterprise-plugins graylog-integrations-plugins graylog-enterprise-integrations-plugins
Follow the instructions in your /etc/graylog/server/server.conf and add password_secret and root_password_sha2 . These settings are mandatory and without them, Graylog will not start!
You need to use the following command to create your root_password_sha2
:
echo -n "Enter Password: " && head -1 </dev/stdin | tr -d '\n' | sha256sum | cut -d" " -f1
To be able to connect to Graylog you should set http_bind_address
to the public host name or a public IP address of the machine you can connect to. More information about these settings can be found in Configuring the web interface.
Note
If you’re operating a single-node setup and would like to use HTTPS for the Graylog web interface and the Graylog REST API, it’s possible to use NGINX or Apache as a reverse proxy.
The last step is to enable Graylog during the operating system’s startup:
$ sudo systemctl daemon-reload $ sudo systemctl enable graylog-server.service $ sudo systemctl start graylog-server.service
The next step is to ingest messages into your Graylog and extract the messages with extractors or use the Pipelines to work with the messages.
备注:
1. password_secret
不能太简单, 开始设置成1,Graylog没有启动起来, 后来配置成用pwgen
生成的随机密码,重启 Graylog成功了,命令如下:
#用pwgen生成密码 pwgen -N 1 -s 96 #重启Graylog服务 sudo systemctl restart mongod.service
2、默认登录名和密码:
#用户名
admin
#密码,在生成 root_password_sha2 时输入的密码