Ubuntu系统搭建Zabbix监控

Posted 唐僧还在拜佛求经路。

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Ubuntu系统搭建Zabbix监控相关的知识,希望对你有一定的参考价值。

操作系统类型:Ubuntu

系统环境版本:4.4.0-122-generic

IP地址:192.168.152.118

第一步:选择适当的操作系统类型与各项的版本要求,我这边直接使用LNMP脚本平台搭建;

           https://lnmp.org/download.html下下载lnmp1.5-full.tar.gz脚本安装包

          1:上面连接中是一个LNMP平台的脚本程序包,下载对应服务器和相应的目录中进行解压;

                SH152118:/tmp/Package$ sudo tar xvf lnmp1.5-full.tar.gz

               SH152118:/tmp/Package$ cd lnmp1.5-full/

               SH152118:/tmp/Package/lnmp1.5-full$sudo  bash install.sh          

             技术分享图片
             技术分享图片
           
                  大概需要40-50分钟的安装时间才可以安装结束,安装成功之后可以使用相关命令查看对应服务端口已经开启;
  
            2:获取3.4zabbix安装包       
                安装zabbix Server
                    #使用dpkg安装3.4deb包
                         dpkg -i zabbix-release_3.4-1+xenial_all.deb
                    #更新apt
                           apt update
                    #安装Zabbix web程序
                          apt install zabbix-server-mysql zabbix-frontend-php zabbix-agent
--------------------------------------------------------------------------------------------------------------
3:访问数据库时有可能会出错,下面是解决方案。

[email protected]:~# mysql -uroot -p

Enter password:

ERROR 2002 (HY000): Can‘t connect to local MySQL server through socket ‘/tmp/mysql.sock‘ (2 "No such file or directory")

[email protected]:~# vim /etc/my.cnf            //注释掉client字段中的socket         = /tmp/mysql.sock在进行服务重启;

[client]

#password       = your_password

port            = 3306

#socket         = /tmp/mysql.sock

[email protected]:~# /etc/init.d/mysql restart

[ ok ] Restarting mysql (via systemctl): mysql.service.

 

--------------------------------------------------------------------------------------------------------------
4:  建立zabbix的库表,并导入数据
     [email protected]:~# mysql -uroot -p      Enter password: ubuntu      Welcome to the MariaDB monitor.  Commands end with ; or g.      Your MariaDB connection id is 33      Server version: 10.0.34-MariaDB-0ubuntu0.16.04.1 Ubuntu 16.04

     Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

     Type ‘help;‘ or ‘h‘ for help. Type ‘c‘ to clear the current input statement.

     MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;      Query OK, 1 row affected (0.00 sec)

     MariaDB [(none)]> grant all privileges on zabbix.* to [email protected] identified by ‘password‘;      Query OK, 0 rows affected (0.00 sec)

     MariaDB [(none)]>      MariaDB [(none)]> flush privileges;      Query OK, 0 rows affected (0.00 sec)

     MariaDB [(none)]>exit

----------------------------------------------------------------------------------------------------------------------------

5:初始化导入表结构

zcat /usr/share/doc/zabbix-server-mysql/create.sql.gz | mysql -uzabbix -p zabbix

Enter password: password

------------------------------------------------------------------------------------------------------------------------------

6:修改zabbix_server.conf文件

      配置参考如下,主要是修改密码和一个注释的主机
                  DBHost=localhost
                  DBName=zabbix
                  DBUser=zabbix
                  DBPassword=password

---------------------------------------------------------------------------------------------------------------------------

7:拷贝相关配置文件到对应nginx默认目录下,一键脚本默认路径为 /home/wwwroot/default/

# cp -r /usr/share/zabbix/ /home/wwwroot/default/

# cd /home/wwwroot/default/zabbix/conf/

#rm -rf zabbx.conf.php

#cp zabbix.conf.php.example ./zabbix.conf.php

#vim ./zabbix.conf.php

 $DB[‘TYPE‘]                             = ‘MYSQL‘;

 $DB[‘SERVER‘]                   = ‘127.0.0.1‘;

 $DB[‘PORT‘]                             = ‘3306‘;

 $DB[‘DATABASE‘]                 = ‘zabbix‘;

 $DB[‘USER‘]                             = ‘zabbix‘;

 $DB[‘PASSWORD‘]                 = ‘password‘;

# chown www.www /home/wwwroot/default/*  -R

#vim /etc/zabbix/zabbix_server.conf              修改配置文件

          DBSocket=/tmp/mysqld.sock               

#ln -s /run/mysqld/mysqld.sock /tmp/

#/etc/init.d/php-fpm restart

----------------------------------------------------------------------------------------------------------------------------

8:安装 zabbix web 前端技术分享图片

访问:http://IP/zabbix/zabbix.php

修改配置文件:

     max_input_time = 60 修改为:max_input_time = 300 

     ;always_populate_raw_post_data = -1 修改为:always_populate_raw_post_data = -1

     SH152118:~# /etc/init.d/php-fpm restart   重新启动服务;

----------------------------------------------------------------------------------------------

技术分享图片

如有问题可联系WX:ai759731807

以上是关于Ubuntu系统搭建Zabbix监控的主要内容,如果未能解决你的问题,请参考以下文章

zabbix通过自定义脚本监控docker服务docker nginx容器,图文详细

Ubuntu下Zabbix服务器监控工具部署

Ubuntu1804安装监控软件之zabbix

Ubuntu1804安装监控软件之zabbix

Zabbix企业应用之服务器硬件信息监控

ubuntu下zabbix服务器监控工具部署