graylog搭建
版本:
elasticsearch-6.6.2,mongodb-4.0,graylog-3.0.0,openjdk1.8.0_181
单节点部署,最少3G内存,关闭selinux,防火墙
安装jdk环境,最好使用1.8版本
curl -o /etc/yum.repos.d/CentOs-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum install epel-release
yum install pwgen
#3.安装mongodb
#可以去官网下载包安装,这里使用的是yum安装
#官网地址:蒙哥数据库社区下载|蒙哥数据库 (mongodb.com)
各包的作用,按需求下载
mongodb-org-server-4.0.0-0.el7.x86_64.rpm 安装 mongoDB 的服务端程序
mongodb-org-shell-4.0.0-0.el7.x86_64.rpm 用命令行连接 mongoDB,则需要安装 shell 程序包
mongodb-org-tools-mongodb-org-tools-4.2.9-1.el7.x86_64.rpm 附加工具,例如数据导入导出,则需要安装 tool 程序包
mongodb-org-mongos-4.2.9-1.el7.x86_64.rpm 如果要部署集群,则还需要安装 mongos 程序包
#新建mongodb的repo文件
vim /etc/yum.repos.d/mongodb-org-4.0.reop
[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 -y install mongodb-org
systemctl daemon-reload
systemctl enable mongod.service
systemctl start mongod.service
#安装ES
rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
#新建ES的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 -y install elasticsearch-oss
vim /etc/elasticsearch/elasticsearch.yml
#在最后添加两行
cluster.name: graylog
action.auto_create_index: false
chkconfig --add elasticsearch
systemctl daemon-reload
systemctl enable elasticsearch.service
systemctl start elasticsearch.service
#安装graylog
#yum安装比较慢,可以上官网下载rpm包安装
#下载地址:灰度日志包存储库 (graylog2.org)
#各包的作用,下载server包就行了,按需求下载
graylog-server
graylog-enterprise-plugins 企业插件、可选
graylog-integrations-plugins 集成插件、可选
graylog-enterprise-integrations-plugins 企业集成插件
rpm -Uvh https://packages.graylog2.org/repo/packages/graylog-3.0-repository_latest.rpm
yum install graylog-server
#安装完成后生成 password_secret密文和root_password_sha2密文
#生成password_secret命令:
pwgen -N 1 -s 96
#生成password_secret命令:
echo -n "Enter Password: " && head -1 </dev/stdin | tr -d '\n' | sha256sum | cut -d" " -f1
#需要输入密码这个密码就是一会web网页的登录密码
#修改配置文件
vim /etc/graylog/server/server.conf
password_secret = 6YmEnz3RxyLtQefmvY4H6203diSxSEaYRbaWKAU5JxL7WEHGgDGs
root_password_sha2 = 75345fbaafa92061dbbbe8a2227c84c5c54377ab3878
#还需要修改访问地址
http_bind_address = 0.0.0.0:9000
chkconfig --add graylog-server
systemctl daemon-reload
systemctl enable graylog-server.service
systemctl start graylog-server.service
搭建完成。
登录web页面: http://192.168.11.11:9000
账号: admin
密码: jjy (刚刚服务器生成密文时的密码)
###graylog配置不同项目接收日志
项目服务器下载安装Sidecar
rpm -Uvh https://packages.graylog2.org/repo/packages/graylog-sidecar-repository-1-2.noarch.rpm
yum -y install graylog-sidecar
vim /etc/graylog/sidecar/sidecar.yml
#graylog日志服务地址,gratlog服务器9000端口需对项目服务器开放
server_url: "http://192.168.11.11:9000/api/"
#之前生成的token
server_api_token: "ab331b5************************"
#配置节点名称
node_name: "node12"
#取消注释
update_interval: 10
send_status: true
#启动
graylog-sidecar -service install
systemctl start graylog-sidecar
systemctl status graylog-sidecar
需要创建一个beats的input,因为要用filebeat进行日志采集
在graylog服务器安装filebeat
curl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.13.2-x86_64.rpm
rpm -vi filebeat-7.13.2-x86_64.rpm
update保存后back然后进行绑定