1.环境说明
环境说明 | IP | 需要的环境 |
---|---|---|
服务器 | 192.168.69.134 | lamp架构zabbix server和zabbix agent |
客户端 | 192.168.69.128 | zabbix agent |
部署zabbix需要lamp部署详细步骤参照上一篇文章
2.关闭防火墙和setLinux服务
[[email protected] ~]#sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config [[email protected] ~]#systemctl stop firewalld
3.在服务器上部署zabbix(192.168.69.134)
[[email protected] ~]# yum -y install net-snmp-devel libevent-devel [[email protected] ~]# cd /usr/src/ [[email protected]]#wget https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.4.12/zabbix-3.4.12.tar.gz [[email protected] src]# tar xf zabbix-3.4.12.tar.gz [[email protected] src]# groupadd -r zabbix [[email protected] src]# useradd -r -g zabbix -M -s /sbin/nologin zabbix [[email protected] ~]# 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 [email protected] 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 [[email protected] ~]# cd /usr/src/zabbix-3.4.12/database/mysql/ [[email protected] mysql]# ls data.sql images.sql schema.sql [[email protected] mysql]# mysql -uzabbix -pzabbix123! zabbix < schema.sql mysql: [Warning] Using a password on the command line interface can be insecure. [[email protected] mysql]# mysql -uzabbix -pzabbix123! zabbix < images.sql mysql: [Warning] Using a password on the command line interface can be insecure. [[email protected] mysql]# mysql -uzabbix -pzabbix123! zabbix < data.sql mysql: [Warning] Using a password on the command line interface can be insecure. [[email protected] ~]# cd /usr/src/zabbix-3.4.12 [[email protected] zabbix-3.4.12]# ./configure --enable-server \ --enable-agent \ --with-mysql \ --with-net-snmp \ --with-libcurl \ --with-libxml2 [[email protected] zabbix-3.4.12]# make install [[email protected] zabbix-3.4.12]# ls /usr/local/etc/ zabbix_agentd.conf zabbix_agentd.conf.d zabbix_server.conf zabbix_server.conf.d [[email protected] ~]# vim /usr/local/etc/zabbix_server.conf DBPassword=zabbix123! \\设置密码 [[email protected] zabbix-3.4.12]# zabbix_server [[email protected] zabbix-3.4.12]# zabbix_agentd [[email protected] 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 ::: * [[email protected] ~]# sed -ri 's/(post_max_size =).*/\1 16M/g' /etc/php.ini [[email protected]lhost ~]# sed -ri 's/(max_execution_time =).*/\1 300/g' /etc/php.ini [[email protected] ~]# sed -ri 's/(max_input_time =).*/\1 300/g' /etc/php.ini [[email protected] ~]# sed -i '/;date.timezone/a date.timezone = Asia/Shanghai' /etc/php.ini [[email protected] ~]# service php-fpm restart [[email protected] tmp]# cd /usr/src/zabbix-3.4.12 [[email protected] 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 [[email protected] zabbix-3.4.12]# mkdir /usr/local/apache/htdocs/zabbix [[email protected] zabbix-3.4.12]# cp -a frontends/php/* /usr/local/apache/htdocs/zabbix/ [[email protected] zabbix-3.4.12]# chown -R apache.apache /usr/local/apache/htdocs [[email protected] ~]# vim /etc/httpd24/httpd.conf <VirtualHost *:80> DocumentRoot "/usr/local/apache/htdocs/zabbix" ServerName zabbix.wangqing.com ProxyRequests Off ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/usr/local/apache/htdocs/zabbix/$1 <Directory "/usr/local/apache/htdocs/zabbix"> Options none AllowOverride none Require all granted </Directory> </VirtualHost> [[email protected] zabbix-3.4.12]# chmod 777 /usr/local/apache/htdocs/zabbix/conf [[email protected] zabbix-3.4.12]# ll -d /usr/local/apache/htdocs/zabbix/conf drwxrwxrwx. 2 apache apache 81 7月 30 19:41 /usr/local/apache/htdocs/zabbix/conf [[email protected] zabbix-3.4.12]# apachectl -t Syntax OK [[email protected] zabbix-3.4.12]# apachectl stop [[email protected] zabbix-3.4.12]# apachectl start [[email protected] 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 ::: *
在我的电脑
修改C:\Windows\System32\drivers\etc\hosts
192.168.69.134 zabbix.qinyong.com \\在结尾添加此行域名ip [[email protected] ~]# chmod 755 /usr/local/apache/htdocs/zabbix/conf [[email protected] ~]# ll -d /usr/local/apache/htdocs/zabbix/conf drwxr-xr-x 2 apache apache 104 Aug 17 13:05 /usr/local/apache/htdocs/zabbix/conf
4.登陆zabbix
默认的用户名和密码是:
用户名 | 密码 |
---|---|
Admin | zabbix |
5.给客户端安装zabbix(192.168.69.128|)
[[email protected] ~]# yum -y install net-snmp-devel libevent-devel [[email protected] ~]# wget https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.4.12/zabbix-3.4.12.tar.gz [[email protected] ~]# tar xf zabbix-3.4.12.tar.gz [[email protected] ~]# groupadd -r zabbix [[email protected] ~]# useradd -r -g zabbix -M -s /sbin/nologin zabbix [[email protected] ~]# cd zabbix-3.4.12 [[email protected] zabbix-3.4.12]# ./configure --enable-agent [[email protected] zabbix-3.4.12]# make install [[email protected] zabbix-3.4.12]# vim /usr/local/etc/zabbix_agentd.conf Server=127.0.0.1修改为Server=192.168.69.134 ServerActive=127.0.0.1修改为ServerActive=192.168.69.134 Hostname=Zabbix server修改为Hostname=192.168.69.128 [[email protected] zabbix-3.4.12]# zabbix_agentd [[email protected] zabbix-3.4.12]# ss -antl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 *:10050 *:* LISTEN 0 128 *:22 *:* LISTEN 0 100 127.0.0.1:25 *:* LISTEN 0 128 :::22 :::* LISTEN 0 100 ::1:25 :::*
6.然后对zabbix进行设置
6.1进入zabbix管理界面建立主机组
选择配置→主机群组→创建主机群组
6.2把管理的主机加入相应的主机组进行管理
配置→主机→创建主机
添加群组还有主机名称和IP地址,并且把最后已启用的√打上最后选择添加就完成
6.3配置监控项
主机→模板→选择→Template OS Linux→添加→更新
出现了监控的项目
6.4配置告警信息
配置→主机→触发器
查看设备运行状态