当前位置:网站首页>一键安装脚本实现快速部署GrayLog Server 4.2.10单机版

一键安装脚本实现快速部署GrayLog Server 4.2.10单机版

2022-07-05 15:34:00 yuanfan2012

一键安装脚本实现快速部署GrayLog Server 4.2.10单机版

由于局点(分支机构)较多,为了快速部署GrayLog单机版

所以简单整理了一下GrayLog的安装步骤脚本,来实现一键安装GrayLog Server 4.2.10单机版

只需上传GraylogServer4.2.10_install.tar.gz和GrayLogServer_install.sh安装脚本并执行一键安装脚本即可完成GrayLog Server 4.2.10单机版的安装

(图片可点击放大查看)

其中安装包和脚本的下载链接如下

链接:https://share.weiyun.com/MySqbCkG 密码:295bcq

说明:

1、GraylogServer4.2.10_install.tar.gz中为GrayLogServer安装时所需的JDK+pwgen+MongoDB+elasticsearch+graylog-server的RPM包 使用createrepo方式打包制作成本地yum源来实现离线yum安装

(图片可点击放大查看)

2、建议的资源配置如下

操作系统:CentOS7.9

CPU 8核

内存建议8GB内存以上

磁盘大小:建议单独一块数据盘,并挂载到/data目录

3、其中ES和MongoDB未做加密认证,因为只监听在本地127.0.0.1不对外暴露,若需要安全加固,请自行配置

GrayLogServer_install.sh脚本

脚本内容如下

#!/bin/bash
#关闭SELINUX
sed -i 's/enforcing/disabled/g' /etc/selinux/config
setenforce 0
#解压安装包
tar -zxvf GraylogServer4.2.10_install.tar.gz -C /opt/
mkdir /opt/yum_repo_backup 
mv /etc/yum.repos.d/CentOS*.repo /opt/yum_repo_backup
cp /opt/graylog_local.repo /etc/yum.repos.d/
echo "priority=1" >> /etc/yum.repos.d/graylog_local.repo 
#安装JDK+pwgen
yum install -y java-1.8.0-openjdk-headless.x86_64
yum install -y pwgen
cp /opt/yum_repo_backup/CentOS*.repo /etc/yum.repos.d/
#安装mongodb-server服务
yum install -y mongodb-org

#启动mongodb-server服务
systemctl daemon-reload
systemctl enable mongod.service
systemctl start mongod.service
systemctl --type=service --state=active | grep mongod
firewall-cmd --add-port=27017/tcp --permanent --zone=public 
firewall-cmd --reload 

#安装elasticsearch
yum install elasticsearch -y
#单独创建目录用于存放elasticsearch数据
mkdir -p /data/elasticsearch/data
mkdir -p /data/elasticsearch/logs
chown -R elasticsearch:elasticsearch /data/elasticsearch
cp /etc/elasticsearch/elasticsearch.yml /etc/elasticsearch/elasticsearch.yml_default
#修改elasticsearch相关配置文件
sed -i "[email protected]#cluster.name: [email protected]: [email protected]" /etc/elasticsearch/elasticsearch.yml
sed -i "s#path.data: /var/lib/elasticsearch#path.data: /data/elasticsearch/data#g" /etc/elasticsearch/elasticsearch.yml
sed -i "s#path.logs: /var/log/elasticsearch#path.logs: /data/elasticsearch/logs#g" /etc/elasticsearch/elasticsearch.yml
#修改JVM内存大小
sed -i "s/-Xms1g/-Xms4g/g" /etc/elasticsearch/jvm.options
sed -i "s/-Xmx1g/-Xmx4g/g" /etc/elasticsearch/jvm.options
#启动elasticsearch服务
systemctl daemon-reload
systemctl enable elasticsearch.service
systemctl restart elasticsearch.service
firewall-cmd --add-port=9200/tcp --permanent --zone=public 
firewall-cmd --reload 
curl -s -XGET 'http://127.0.0.1:9200/_cluster/health?pretty=true'
curl -s -XGET 'http://127.0.0.1:9200/_cat/nodes?v'
#安装graylog-server服务
yum install graylog-server -y
cp /etc/graylog/server/server.conf /etc/graylog/server/server.conf_default
#修改graylog-server相关配置文件
sed -i "s/password_secret =/password_secret = 0pAHJtPdZZUb5yHAvFbBezbWAlQwh9CbRX1rshJEVxM0kV7t0SpIgY5q9tLpVEwWLElhG3EtbvQ03mTm9i0HuvWKwlWgWiIJ/g" /etc/graylog/server/server.conf
sed -i "s/root_password_sha2 =/root_password_sha2 = 79a560ed561e6fc57b3d02a59335b7710fada90625e4c661fbb7b780fb92ceaa/g" /etc/graylog/server/server.conf
sed -i "[email protected]#root_timezone = [email protected]_timezone = Asia/[email protected]" /etc/graylog/server/server.conf
sed -i "[email protected]#http_bind_address = 127.0.0.1:[email protected]_bind_address = 0.0.0.0:[email protected]" /etc/graylog/server/server.conf
sed -i "s/allow_highlighting = false/allow_highlighting = true/g" /etc/graylog/server/server.conf
#修改graylog-server启动时JVM内存大小
sed -i "s/-Xms1g -Xmx1g/-Xms2g -Xmx2g/g" /etc/sysconfig/graylog-server
firewall-cmd --add-port=9000/tcp --permanent --zone=public 
firewall-cmd --reload
#启动graylog-server服务
systemctl restart graylog-server
systemctl enable graylog-server

安装过程截图如下

目前只在CentOS7.9环境下进行部署测试,其他版本未测试

[[email protected] ~]# ll
total 642960
-rw-------. 1 root root      1648 Jul  3  2021 anaconda-ks.cfg
-rw-r--r--. 1 root root 658378578 Jun 18 11:56 GraylogServer4.2.10_install.tar.gz
-rw-r--r--. 1 root root      3065 Jun 18 13:07 GrayLogServer_install.sh
[[email protected] ~]# chmod 755 GrayLogServer_install.sh 
[[email protected] ~]# ./GrayLogServer_install.sh 

(图片可点击放大查看)

(图片可点击放大查看)

(图片可点击放大查看)

三、登录GrayLog Web界面

账号密码为

admin/[email protected]

(图片可点击放大查看)

(图片可点击放大查看)

(图片可点击放大查看)

Tips

若需要修改admin登录密码请使用如下命令

echo -n "Enter Password: " && head -1 </dev/stdin | tr -d '\n' | sha256sum | cut -d" " -f1
并修改/etc/graylog/server/server.conf 中root_password_sha2值
重启Graylog服务生效
原网站

版权声明
本文为[yuanfan2012]所创,转载请带上原文链接,感谢
https://cloud.tencent.com/developer/article/2041004