文章目录
1.环境说明
环境说明 | IP | 需要的环境 |
---|---|---|
服务器 | 192.168.69.134 | lamp架构zabbix server和zabbix agent |
客户端 | 192.168.69.128 | zabbix agent |
部署zabbix需要lamp部署详细步骤参照上一篇文章
启动相关服务并确认
[root@localhost ~]#apachectl start
[root@localhost ~]# service php-fpm start
Starting php-fpm done
[root@localhost ~]# service mysqld start
Starting MySQL SUCCESS!
[root@localhost ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 127.0.0.1:9000 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 80 :::3306 :::*
LISTEN 0 128 :::80 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
2.关闭防火墙和setLinux服务
[root@localhost ~]#sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config
[root@localhost ~]#setenforce 0
[root@localhost ~]#systemctl stop firewalld
3.在服务器上部署zabbix(192.168.69.134)
[root@localhost ~]# yum -y install net-snmp-devel libevent-devel
[root@localhost ~]# cd /usr/src/
[root@localhostsrc]#wget https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.4.12/zabbix-3.4.12.tar.gz
[root@localhost src]# tar xf zabbix-3.4.12.tar.gz
[root@localhost src]# groupadd -r zabbix
[root@localhost src]# useradd -r -g zabbix -M -s /sbin/nologin zabbix
[root@localhost ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix123!';
Query OK, 0 rows affected, 2 warnings (0.05 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.05 sec)
mysql> quit
[root@localhost ~]# cd /usr/src/zabbix-3.4.12/database/mysql/
[root@localhost mysql]# ls
data.sql images.sql schema.sql
[root@localhost mysql]# mysql -uzabbix -pzabbix123! zabbix < schema.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@localhost mysql]# mysql -uzabbix -pzabbix123! zabbix < images.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@localhost mysql]# mysql -uzabbix -pzabbix123! zabbix < data.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@localhost ~]# cd /usr/src/zabbix-3.4.12
[root@localhost zabbix-3.4.12]# ./configure --enable-server \
--enable-agent \
--with-mysql \
--with-net-snmp \
--with-libcurl \
--with-libxml2
[root@localhost zabbix-3.4.12]# make &&make install
[root@localhost zabbix-3.4.12]# ls /usr/local/etc/
zabbix_agentd.conf zabbix_agentd.conf.d zabbix_server.conf zabbix_server.conf.d
[root@localhost ~]# vim /usr/local/etc/zabbix_server.conf
DBPassword=zabbix123! \\设置密码
[root@localhost zabbix-3.4.12]# zabbix_server
[root@localhost zabbix-3.4.12]# zabbix_agentd
[root@localhost zabbix-3.4.12]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:10050 *:*
LISTEN 0 128 *:10051 *:*
LISTEN 0 128 127.0.0.1:9000 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 80 :::3306 :::*
LISTEN 0 128 :::80 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 ::: *
[root@localhost ~]# sed -ri 's/(post_max_size =).*/\1 16M/g' /etc/php.ini
[root@localhost ~]# sed -ri 's/(max_execution_time =).*/\1 300/g' /etc/php.ini
[root@localhost ~]# sed -ri 's/(max_input_time =).*/\1 300/g' /etc/php.ini
[root@localhost ~]# sed -i '/;date.timezone/a date.timezone = Asia/Shanghai' /etc/php.ini
[root@localhost ~]# service php-fpm restart
[root@localhost tmp]# cd /usr/src/zabbix-3.4.12
[root@localhost zabbix-3.4.12]# ls
aclocal.m4 bin ChangeLog conf config.log config.sub configure.ac database frontends INSTALL m4 Makefile.am man missing README src
AUTHORS build compile config.guess config.status configure COPYING depcomp include install-sh Makefile Makefile.in misc NEWS sass upgrades
[root@localhost zabbix-3.4.12]# mkdir /usr/local/apache/htdocs/zabbix
[root@localhost zabbix-3.4.12]# cp -a frontends/php/* /usr/local/apache/htdocs/zabbix/
[root@localhost zabbix-3.4.12]# chown -R apache.apache /usr/local/