Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install and configure Zabbix and LNMP

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Monitor operation #! / bin/bash# install zabbix and LNMP#lnmp () {# turn off firewall & core security function systemctl stop firewalld.servicesystemctl disable firewalld.service & > / dev/nullsetenforce 0sed-I "7cSELINUX=disabled" / etc/sysconfig/selinux#yum install nginxwget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm# create nginx installation source (centos can be replaced according to different systems Later versions are the same) echo "[nginx] name=nginx repobaseurl= http://nginx.org/packages/centos/7/\$basearch/gpgcheck=0enabled=1" > / etc/yum.repos.d/nginx.repoyum install nginx-y # launch nginxsystemctl start nginxsystemctl enable nginx# install mysql 5.7and launch yum install-y mariadb-server mariadb expectsystemctl enable mariadb.servicesystemctl start mariadb.service# to set database initial password / usr/bin/expect / dev/nullif [$?-ne 0] Then yum install-y php72w php72w-devel php72w-fpm php72w-gd php72w-mbstring php72w-mysqlelse breakfidone# modifies the fpm module to support nginxsed-I-e "8cuser = nginx"-e "10cgroup = nginx" / etc/php-fpm.d/www.conf# changes the nginx configuration file so that it can recognize the php dynamic file sed-I "10s/index.html/index.html index.php/" / etc/nginx/conf.d/default.confsed-I-e "30rem 36s / # / "- e" 31s/html/\ / usr\ / share\ / nginx\ / html/ "- e" 34s/\ / scripts/\ $document_root/ "/ etc/nginx/conf.d/default.conf# configuration PHPsed-I-e" 359s/On/Off/ "- e" 202s/Off/On/ "/ etc/php.ini# restart Service systemctl start php-fpmsystemctl enable php-fpmsystemctl restart nginx} # check whether the LNMP architecture has been installed Bi systemctl restart nginx & > / dev/nullservice mysqld restart & > / dev/nullsystemctl restart mariadb & > / dev/nullnetstat-atnp | egrep'(nginx | 3306)'& > / dev/nullif [$?-ne 0] Then lnmpfi# configures PHP to accommodate zabbixsed-I-e "368s/30/300/"-e "378s/60/300/"-e "656s/8/16/"-e "799aalways_populate_raw_post_data =-1"-e "877cdate.timezone = Asia/Shanghai" / etc/php.inisystemctl restart php-fpm# to establish zabbix database and manage user mysql-uroot-p123123-e "CREATE DATABASE zabbix character set utf8 collate utf8_bin "mysql-uroot-p123123-e" GRANT all privileges ON *. * TO 'zabbix'@'%' IDENTIFIED BY' 123123; "mysql-uroot-p123123-e" flush privileges; "# solves the local login problem mysql-uroot-p123123-e" drop user'@ localhost; "mysql-uroot-p123123-e" drop user'@ localhost.localdomain " "mysql-uroot-p123123-e" flush privileges "# installs zabbixrpm-I https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpmfor ((kumb1 ne k > 0 ne +)); do rpm-Q zabbix-agent & > / dev/null if [$?-ne 0] Then yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent-y else break fidone# generates database file zcat / usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql-uzabbix-p123123 zabbix# modifies zabbix server configuration file sed-I-e "91s/# / /"-e "125cDBPassword=123123" / etc/zabbix/zabbix_server.conf# working directory rights cp-r / usr/share/ Zabbix/ / usr/share/nginx/html/chown-R zabbix:zabbix / etc/zabbix/chown-R zabbix:zabbix / usr/share/nginx/chown-R zabbix:zabbix / usr/lib/zabbix/chmod-R 755 / etc/zabbix/web/chmod-R 777 / var/lib/php/session/# start zabbixsystemctl start zabbix-server.servicesystemctl enable zabbix-server.servicesystemctl start zabbix-agent.servicesystemctl enable zabbix-agent.service# all services restart systemctl restart php-fpm nginx mariadb zabbix-server zabbix- Agent# checks whether the service starts test= `netstat-atnp | egrep'(nginx | 3306 | 10051 | 10050)'| grep-v "TIME_WAIT" | wc-l`if [$test-ge 5] Then echo "zabbix server settings complete" fidizhi= `ifconfig ens33 | awk 'NR==2 {print $2}' `echo "Please use the browser to login to ${dizhi} / zabbix/ to install the default login user name is: Admin default login password is: zabbix" login to the monitoring platform

Configuring the agent side is the controlled server. If the server also needs to be monitored by itself, you also need to install abbix-agent# to turn off the firewall and set the boot self-shutdown systemctl stop firewalld.service systemctl disable firewalld.service # install YumSource rpm-ivh http://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/zabbix-release-3.5-1.el7.noarch.rpm# install zabbix-agentyum install-y zabbix-agent# modify the configuration file grep-n'^'[aMeiz ] / etc/zabbix/zabbix_agentd.conf13:PidFile=/var/run/zabbix/zabbix_agentd.pid32:LogFile=/var/log/zabbix/zabbix_agentd.log43:LogFileSize=098:Server=127.0.0.1139:ServerActive=127.0.0.1150:Hostname=Zabbix server268:Include=/etc/zabbix/zabbix_agentd.d/*.confvim / etc/zabbix/zabbix_agentd.confServer=192.168.142.123 # 98 line Point to the monitoring server IPServerActive=192.168.142.123 # 139line, point to the monitoring server IPHostname=czt # 150line, you can define your own hostname # start the service systemctl enable zabbix-agent.servicesystemctl start zabbix-agent.service# to view the service listening port netstat-anpt | grep zabbix adds the controlled host on the WEB platform so that the monitoring end can identify it.

Access http://192.168.142.123/zabbix/ configuration-hosts-create hosts:

Under configuration, click create Host.

Fill in the appropriate content in the host configuration interface, and then click the template

Select the template links for HTTP and SSH in the template, click add in the prompt, and then click add.

Newly added monitoring item

Thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report