[root@monitor_53 ~]$ systemctl stop firewalld [root@monitor_53 ~]$ systemctl disable firewalld
[root@monitor_53 ~]$ setenforce 0 [root@monitor_53 ~]$ sed -i "s#enforcing#disabled#g" /etc/sysconfig/selinux
[root@monitor_53 ~]$ wget -O CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo [root@monitor_53 ~]$ wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo [root@monitor_53 ~]$ yum clean all [root@monitor_53 ~]$ yum makecache [root@monitor_53 ~]$ yum update -y
[root@monitor_53 ~]$ yum install -y php-mysql php-gd php-bcmath php-common php-xml php-mbstring php-cli pcre glibc gcc livevent zlib libcurl-devel curl-devel OpenIPMI-devel libssh2 fping net-snmp-devel perl-DBI openssl-devel iksemel libxml2
[root@monitor_53 ~]$ yum install -y httpd php mariadb mariadb-server ntp
[root@monitor_53 ~]$ ntpdate -u asia.pool.ntp.org [root@monitor_53 ~]$ systemctl enable ntpd [root@monitor_53 ~]$ echo '* /30 * * * * /usr/sbin/ntpdate -u asia.pool.ntp.org > /dev/null 2>&1' >>/var/spool/cron/root
[root@monitor_53 ~]$ mkdir -p /home/mysql/{data,logs} [root@monitor_53 ~]$ touch /home/mysql/logs/slow_query_log.log [root@monitor_53 ~]$ touch /home/mysql/logs/error.log [root@monitor_53 ~]$ chown -R mysql:mysql /home/mysql [root@monitor_53 ~]$ cp /etc/my.cnf /etc/my.cnf.bak [root@monitor_53 ~]$ cat /etc/my.cnf [mysqld] user = mysql port = 3306 datadir = /var/lib/mysql socket = /var/lib/mysql/mysql.sock pid-file = /var/run/mariadb/mariadb.pid log-error = /home/mysql/logs/error.log slow_query_log = on slow_query_log_file = /home/mysql/logs/slow_query_log.log long_query_time = 0.1 log_queries_not_using_indexes =1 long_query_time=2 character_set_server=utf8 [client] port = 3306 socket = /var/lib/mysql/mysql.sock [mysqldump] quick max_allowed_packet = 32M
[root@monitor_53 ~]$ systemctl enable mariadb [root@monitor_53 ~]$ systemctl start mariadb [root@monitor_53 ~]$ mysql_secure_installation #初始化,配置完成root密码后,一路按Y即可 [root@monitor_53 ~]$ mysql_secure_installation Enter current password for root (enter for none): 回车 Set root password? [Y/n] 回车 New password: 123456 Re-enter new password: 123456 Remove anonymous users? [Y/n] 回车 Disallow root login remotely? [Y/n] 回车 Remove test database and access to it? [Y/n] 回车 Reload privilege tables now? [Y/n] 回车 Thanks for using MariaDB!
[root@monitor_53 ~]$ systemctl start httpd [root@monitor_53 ~]$ systemctl enable httpd [root@monitor_53 ~]$ netstat -ntap | egrep '(80|3306)'
[root@monitor_53 ~]$ rpm -Uvh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm [root@monitor_53 ~]$ yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent
[root@monitor_53 ~]$ mysql -uroot -p123456 mysql> create database zabbix character set utf8 collate utf8_bin; mysql> grant all privileges on zabbix.* to 'zabbix'@'10.0.0.53' identified by 'zabbix'; mysql> flush privileges; mysql> quit;
[root@monitor_53 ~]$ zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -h 10.0.0.53 -uzabbix -p zabbix
[root@monitor_53 ~]$ cp /etc/zabbix/zabbix_server.conf /etc/zabbix/zabbix_server.conf.bak [root@monitor_53 ~]$ cat /etc/zabbix/zabbix_server.conf LogFile=/var/log/zabbix/zabbix_server.log LogFileSize=0 DebugLevel=3 PidFile=/var/run/zabbix/zabbix_server.pid SocketDir=/var/run/zabbix DBHost=10.0.0.53 DBName=zabbix DBUser=zabbix DBPassword=zabbix DBSocket=/var/lib/mysql/mysql.sock SNMPTrapperFile=/var/log/snmptrap/snmptrap.log Timeout=4 AlertScriptsPath=/usr/lib/zabbix/alertscripts ExternalScripts=/usr/lib/zabbix/externalscripts LogSlowQueries=3000
[root@monitor_53 ~]$ cp /etc/httpd/conf.d/zabbix.conf /etc/httpd/conf.d/zabbix.conf.bak [root@monitor_53 ~]$ vim /etc/httpd/conf.d/zabbix.conf php_value date.timezone Europe/Riga
[root@monitor_53 ~]$ cp /etc/zabbix/zabbix_agentd.conf /etc/zabbix/zabbix_agentd.conf.bak [root@monitor_53 ~]$ cat /etc/zabbix/zabbix_agentd.conf PidFile=/var/run/zabbix/zabbix_agentd.pid LogFile=/var/log/zabbix/zabbix_agentd.log LogFileSize=0 ListenPort=10050 Server=10.0.0.53 ServerActive=10.0.0.53 Hostname=10.0.0.53 Include=/etc/zabbix/zabbix_agentd.d/*.conf HostMetadataItem=system.uname StartAgents=1 RefreshActiveChecks=120 BufferSize=200 Timeout=10
[root@monitor_53 ~]$ systemctl restart zabbix-server zabbix-agent httpd [root@monitor_53 ~]$ systemctl enable zabbix-server zabbix-agent httpd
[root@monitor_53 ~]$ netstat -tnlp | egrep '(80|3306|10050|10051)'
浏览器连接到新安装的Zabbix前端: http://10.0.0.53/zabbix
Database type MySQL Database server 10.0.0.53 Database port 3306 Database name zabbix Database user zabbix Database password zabbix Zabbix server 10.0.0.53 Zabbix server port 10051 Zabbix server name 运维监控