GrayLog5.0一键安装脚本
(图片点击放大查看)
1、CentOS7.9基础环境准备
cat /etc/redhat-release lsblk
建议数据盘/data目录作为ES的存储目录
2、上传脚本和安装包,一键安装
rz ll chmod 755 GrayLogServer5.0_install.sh ./GrayLogServer5.0_install.sh systemctl status graylog-server.service netstat -anp | grep 9000
(图片点击放大查看)
(图片点击放大查看)
3、安装完成后,直接登陆GrayLog5.0
admin/Graylog@2022
(图片点击放大查看)
(图片点击放大查看)
(图片点击放大查看)
(图片点击放大查看)
GrayLogServer5.0_install.sh脚本如下
#!/bin/bash #关闭SELINUX sed -i 's/enforcing/disabled/g' /etc/selinux/config setenforce 0 #解压安装包 mkdir -p /opt/GrayLog_install tar -zxvf ./GrayLog_MongoDB_Elasticsearch_RPM.tar.gz -C /opt/GrayLog_install cat > /etc/yum.repos.d/mongodb-org.repo << \EOF [mongodb-org-5.0] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/5.0/x86_64/ gpgcheck=0 enabled=1 EOF cd /opt/GrayLog_install #安装mongodb-server服务 rpm -Uvh cyrus-sasl*.rpm rpm -Uvh mongodb*.rpm #启动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 rpm -ivh /opt/GrayLog_install/elasticsearch-7.10.2-x86_64.rpm #单独创建目录用于存放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 "s@#cluster.name: my-application@cluster.name: graylog@g" /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 #echo "action.auto_create_index: false" >> /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服务 rpm -ivh /opt/GrayLog_install/graylog-server-5.0.0-14.x86_64.rpm 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 "s@#root_timezone = UTC@root_timezone = Asia/Shanghai@g" /etc/graylog/server/server.conf sed -i "s@#http_bind_address = 127.0.0.1:9000@http_bind_address = 0.0.0.0:9000@g" /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
可以联系本文作者yuanfan2012获取安装包与脚本
说明
本文参考如下文档完成
https://go2docs.graylog.org/5-0/downloading_and_installing_graylog/red_hat_installation.htm