TypechoJoeTheme

王子博客

用户名
密码
用户名
邮箱

grayLog部署安装

王子博主
2022-09-09
/
1 评论
/
599 阅读
/
480 个字
/
百度已收录
09/09
本文最后更新于2022年09月11日,已超过591天没有更新。如果文章内容或图片资源失效,请留言反馈,我会及时处理,谢谢!

前言

Graylog 的架构主要有两种,一种是最小化 Graylog,用于较小的非关键或测试环境,各组成组件之间不冗余,设置简单快捷;另一种是针对更大生产环境下的 Graylog,各组成组件之间组成集群架构,在 Graylog 节点前部署负载均衡,适用于生产环境。
最小化 Graylog 所有的组件都部署在一台服务器之上,其架构如下:

生产环境下 Graylog 架构如下:

一、准备环境

此次部署既要满足测试功能,又要能够对生产环境下的架构有清楚认识,决定先部署一台单节点的最小化 graylog,然后再扩展加入集群。
各组件版本选型分别是:elasticsearch-6.6.2、mongodb-4.0、graylog-3.0.0、openjdk1.8.0_181 等。

二、单节点部署

首先部署单节点最小化 graylog,部署步骤如下:

1.配置可通外网网络或搭建内部最新 yum 源(此处不做详细介绍)
2.关闭 selinux、iptable、firewalld 等防火墙

setenforce 0
#将SELINUX=enable修改成SELINUX=disabled,保存退出
vim /etc/selinux/config
systemctl stop firewalld
systemctl disable firewalld

3.系统优化

vim /etc/security/limits.conf
#加入以下内容
* soft nofile 655360
* hard nofile 655360
* soft nproc 655360
* hard nproc 655360
* soft memlock unlimited
* hard memlock unlimited
  
vim /etc/sysctl.conf
#加入以下内容
vm.max_map_count = 655360
  
source /etc/sysctl.conf

4.安装 jdk 以及 pwgen(用来生成密码校验码)

yum install java-1.8.0-openjdk-headless.x86_64
yum install epel-release
yum install pwgen

5.安装 mongodb

#新建mongodb的repo文件
vim /etc/yum.repos.d/mongodb-org-4.0.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
  
yum install mongodb-org
systemctl daemon-reload
systemctl enable mongod.service
systemctl start mongod.service

6.安装 Elasticsearch

rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch

# 新建Elasticsearch的repo文件
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 install elasticsearch-oss
vim /etc/elasticsearch/elasticsearch.yml
修改elasticsearch配置文件,加入以下内容 
cluster.name: graylog
action.auto_create_index: false
  
chkconfig --add elasticsearch
systemctl daemon-reload
systemctl enable elasticsearch.service
systemctl start elasticsearch.service

7.安装 graylog

rpm -Uvh https://packages.graylog2.org/repo/packages/graylog-3.0-repository_latest.rpm
yum install graylog-server

#生成password_secret秘钥:
pwgen -N 1 -s 512

#每人的秘钥都不相同,仅供参考
tLdAuIOWjpytOINtHUKjNhI3V6NUjE8XeiktcaUOOO1SXl4JrFwflBvsrCzoqTqdeAjYpioj5stGv70wE13Nmkyu9qtOi6gI3qJ0P3Ebpsh4MmtJbbB1iSDd5Q9Agq7DxsZUlvghLq5r2Sn6jdzvOIHeRVLQgOme9jmStDRGSZvSZE3JMDUuAcEGfANNbGadDT5jnekplGPEcGY3vCkzv3jmW0Ap4PJxIDffiRPmImyJorWlMZbHZPMufay58huFraiwi0dlS4MBfozxfbGgxvpW2H0UflpGKbjt63ZUOumMICD8NyGvo7omBRusIfRpy5xFGcGGhRtMiv6qsXhu0UlqjE2fjZul1XwYBLg8nnqQaIebA2USZoN6cmCAYri47MNXginKGAwW75XOXqma1rHQvvqfa2e9HlhMzl7J2KAzX4DQlL9Z41rhqpmXON1KGty5qxqaA9VGtMlSJNK0NySfKQzmUSOdSrUxObcWcCq1cI2NOGK5YoOh8amhhfvq


#生成root_password_sha2秘钥(graylog网站登录密码):
echo -n"Enter Password: " && head -1 </dev/stdin | tr -d '\n' | sha256sum | cut -d" " -f1
#执行这个会要你设置密码,然后就输出一串

#每人的秘钥都不相同,仅供参考
e86f78a8a3caf0b60d8e74e5942aa6d86dc150cd3c03338aef25b7d2d7e3acc7

vim /etc/graylog/server/server.conf
# 修改graylog配置文件,将password_secret和root_password_sha2的值填上,保存退出。如:
  password_secret = ESVfAErGXhpih8FLTncNP3tDAoz4V6Oz25PWdca8r4aqLJJNt8Yl5MRv5EGyJnjBDvUFSBgCaL8Ymm8D3s3Oub0j8Un5Zuvy
  root_password_sha2 = fee074307074d18c93ebeb597aed4dfcc87d856864afb2d4216183ccc65687c2
# 修改http_bind_address的值,以方便访问
http_bind_address = 0.0.0.0:9000
# 主机地址为服务器ip:
# 根据自己服务器IP配置,以下为参考
http_publish_uri = http://172.16.1.40:9000/
  
chkconfig --add graylog-server
systemctl daemon-reload
systemctl enable graylog-server.service
systemctl start graylog-server.service

8.测试 graylog
打开浏览器访问 graylog 服务器地址,如:http://localhost:9000

添加 input 测试收集是否正常,system→inputs→select input→Raw/Plaintext TCP→Launch new input,选择 Node,添加 Title,点击 Save 即可。

然后到节点上输入命令:

echo "Hello, Just Test!" | nc localhost 5555

点击 Show received messages,即可查看到日志信息。

graylog
朗读
赞(0)
版权属于:

王子博客

本文链接:

http://120.78.163.174/index.php/archives/176/(转载时请注明本文出处及文章链接)

评论 (1)
  1. xicexikvyru124 闲逛
    Windows 10 · Google Chrome

    BTC may be the latest or last chance to get rich in this era. It will reach $200000 next year or the next year.

    BTC has increased 20 times in the last year, and other coins have increased 800 times!!!

    Think about only $2 a few years ago. Come to the world's largest and safest virtual currency exchange Binance to Get free rewards. Don't miss the most important opportunity in life!!!

    https://hi.switchy.io/91xl

    2023-11-20 回复