如何在CentOS 7上安装和配置Graylog
Graylog是一个开源日志管理系统。
基于德克萨斯州的成立,Graylog以前称为火炬,该火炬在2009年开始作为德国汉堡的开源项目。
Graylog Comerally捕获,存储,并实现与IT基础架构和应用程序中的任何组件的机器数据的实时搜索和日志分析。
该软件使用基于弹性的三级三级架构和可扩展存储。
Graylog创建了一个利基,作为Splunk的快速,价格实惠和可行的替代品。
在CentOS 7上安装Graylog
1.预设
触摸终端并输入以下命令以设置主机名。 hostnamectl set-hostname graylog
更新系统。 yum update -y
安装epel存储库。 yum install epel-release
安装所需的包。 yum install pwgen vim
2.设置Java.
安装Java。 yum install java-1.8.0-openjdk-headless.x86_64
检查Java版本。 java -version
3.安装MongoDB.
创建存储库文件。 vim /etc/yum.repos.d/mongodb-org.repo
添加以下内容。
[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
列出repo。 yum repolist
安装mongodb。 yum install mongodb-org
启用系统启动的Mongo服务。 systemctl enable mongod.service
开始服务。 systemctl start mongod.service
检查Mongo Port。 netstat -tunlp | grep 27017
4.安装Elasticsearch.
安装GPG键。 rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
创建存储库。 vim /etc/yum.repos.d/elasticsearch.repo
将以下内容添加到文件中。
[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
列出存储库。 yum repolist
安装Elasticsearch的开源版本。 yum install elasticsearch-oss
修改Elasticsearch配置文件。
将群集名称设置为灰度,并向文件添加"action.auto_create_index:false"。 vim /etc/elasticsearch/elasticsearch.yml
保存并退出文件。
启用系统启动的弹性搜索。 systemctl enable elasticsearch.service
检查服务的状态。 systemctl status elasticsearch.service
开始服务。 systemctl start elasticsearch.service
检查日志。 tail -f /var/log/elasticsearch/graylog.log
检查弹性搜索健康。 curl -XGET 'http://localhost:9200/_cluster/health?pretty=true'
5.安装Graylog
安装存储库。 rpm -Uvh https://packages.graylog2.org/repo/packages/graylog-3.2-repository_latest.rpm
列出存储库。 yum repolist
安装Graylog-Server。 yum install graylog-server
6.配置Graylog.
我们现在应该将"password_secret"和"root_password_sha2"添加到server.conf文件。
生成password_secret。 pwgen -N 1 -s 96
生成root_password_sha2. echo -n theitroad@dan123 | sha256sum
将生成的值添加到文件。 vim /etc/graylog/server/server.conf
更改绑定地址。 vim /etc/graylog/server/server.conf
取消注释以下行。 http_bind_address = 127.0.0.1:9000
启用系统启动服务。 systemctl enable graylog-server.service
开始服务。 systemctl start graylog-server.service
监控服务器日志。 tail -f /var/log/graylog-server/server.log
检查服务器端口。 netstat -tunlp | grep 9000
7.使用SSL配置Nginx反向代理
I.安装和配置nginx
yum install nginx -y
启用nginx在启动时。systemctl enable nginx
检查状态。 systemctl status nginx
开始服务。 systemctl start nginx
II。设置DNS记录
然后转到DNS管理器并为服务器添加记录。 A Domain Name Server IP
III。使用CESTBOT安装和配置SSL
安装certbot。 yum install certbot python2-certbot-nginx
有很少的方法可以使用CERTBOT来获取和配置SSL,但这是最简单的方法。
运行以下命令以获取证书并将其应用于nginx。 certbot --nginx
当它询问时提供所需信息。
例如,我们需要提供电子邮件,域名等。
当它要求将所有流量重定向到HTTPS时,请输入相关数字。
IV。修改nginx配置 vim /etc/nginx/nginx.conf
将以下内容添加到位置块。
location / { proxy_set_header Host $http_host; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Server $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Graylog-Server-URL https://$server_name/; proxy_pass http://127.0.0.1:9000; }
检查nginx for syntax错误。 nginx -t
重新启动nginx。 systemctl restart nginx
8.设置selinux政策 setsebool -P httpd_can_network_connect 1
9.使用域名浏览 https://graylog.theitroad.com/
然后我们将获得登录界面。
使用Server.conf中的用户名"admin"和root密码登录。
登录后,我们应该看到如下所示的接口。
现在我们需要将输入和将日志文件设置为服务器。