Ubuntu LNMP系统搭建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

             Ubuntu LNMP系统搭建Zabbix监控
             Ubuntu LNMP系统搭建Zabbix监控
           
                  大概需要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:访问数据库时有可能会出错,下面是解决方案。

root@SH152118:~# 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")

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

[client]

#password       = your_password

port            = 3306

#socket         = /tmp/mysql.sock

root@SH152118:~# /etc/init.d/mysql restart

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

--------------------------------------------------------------------------------------------------------------
4:  建立zabbix的库表,并导入数据
     root@SH152118:~# 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 zabbix@localhost 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 前端Ubuntu LNMP系统搭建Zabbix监控

访问: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   重新启动服务;

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

Ubuntu LNMP系统搭建Zabbix监控

如有问题可联系WX:ai759731807

上一篇:sqlplus命令手冊


下一篇:第一章 HTML+CSS(中)