jlthlx 发表于 2019-1-19 12:32:15

centos使用宝塔linux面板搭建zabbix过程记录

发表声明:本文章参照了https://lala.im/2733.html中的步骤和加入自己的安装步骤图而成,不喜勿喷。
1、使用镜像名称为CentOS-7-x86_64-DVD-1804.iso的镜像最小化安装Centos(安装过程中选择),安装后查看使用ip add命令查看本机ip。

http://s1.运维网.com/images/20180802/1533169711918215.png
http://s1.运维网.com/images/20180802/1533169728107912.png
2、使用security crt登陆Centos。
http://s1.运维网.com/images/20180802/1533169741879287.png
3、使用yum update命令更新系统。
http://s1.运维网.com/images/20180802/1533169762288552.png
4、使用yum install -y wget && wget -O install.sh http://download.bt.cn/install/install.sh && sh install.sh安装宝塔Linux面板。安装完成后使用截图中圈住的账户和密码(此账户密码是安装的时候随机生成的,安装完成后可以直接看到或者过后使用bt default命令进行查看并登陆web面板进行自定义修改,如果忘记了可以使用cd /www/server/panel && python tools.pyc panel新密码进行修改,关于宝塔面板的更多内容请参考其官网资料)。
http://s1.运维网.com/images/20180802/1533169773238874.png
http://s1.运维网.com/images/20180802/1533169785349183.png
5、使用http://IP:8888(此ip是前面查看到的本机ip)登陆宝塔Linux 面板,进行lamp环境的搭建。
http://s1.运维网.com/images/20180802/1533169795960291.png
6、自定义修改宝塔linux面板的默认账户名和密码。
http://s1.运维网.com/images/20180802/1533169815933711.png
7、分别使用groupadd zabbix、useradd zabbix -g zabbix -s /sbin/nologin两个命令新建zabbix用户组和zabbix用户。
http://s1.运维网.com/images/20180802/1533169830104803.png
8、使用yum -y install epel-release命令安装epel源。
http://s1.运维网.com/images/20180802/1533169839774866.png
9、使用yum -y install net-snmp-devel fping命令安装编译Zabbix需要的各种依赖和组件。
http://s1.运维网.com/images/20180802/1533169849105543.png
10、在root目录内下载Zabbix-3.4.11源码(在你的本地电脑也提前下载一份,待会导入数据库时会用到)。下载命令为wget https://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.4.11/zabbix-3.4.11.tar.gz。
http://s1.运维网.com/images/20180802/1533169864771277.png
11、使用tar -zxvf Zabbix-3.4.11.tar.gz命令对下载到的源码进行解压,并使用cd Zabbix-3.4.11/命令切换到解压出来zabbix-3.4.11文件夹。
http://s1.运维网.com/images/20180802/1533169874484359.png
12、使用./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2命令对zabbix进行编译,然后使用make install命令进行安装。
http://s1.运维网.com/images/20180802/1533169883382477.png
http://s1.运维网.com/images/20180802/1533169903387212.png
13、在宝塔linux面板修改数据库root密码并对其进行同步。
http://s1.运维网.com/images/20180802/1533169924750224.png
http://s1.运维网.com/images/20180802/1533169935477597.png

14、在宝塔linux面板中打开phpmyadmin,创建zabbix数据库,使用utf8_general_ci进行排序。
http://s1.运维网.com/images/20180802/1533169976603090.png
15、在创建好的zabbix中导入zabbix需要的三个数据库表,导入顺序如图所示。
http://s1.运维网.com/images/20180802/1533169988113140.png

导入后回到宝塔linux面板,点击从服务器获取数据库,发现zabbix数据库后对其进行同步,切记切记。
http://s1.运维网.com/images/20180802/1533170035147478.png
16、回到security crt使用vi /usr/local/etc/zabbix_server.conf对zabbix服务器端进行如下图的修改。
http://s1.运维网.com/images/20180802/1533170047575971.png
17、使用vi /usr/local/etc/zabbix_agentd.conf对zabbix客户端进行修改,加入安装zabbix那台机子的ip。
http://s1.运维网.com/images/20180802/1533170057591272.png
18、使用systemctl stop firewalld.service、systemctl disable firewalld.service关闭centos防火墙。
http://s1.运维网.com/images/20180802/1533170069944086.png
19、使用zabbix_server、zabbix_agentd启动zabbix服务端、客户端。
http://s1.运维网.com/images/20180802/1533170084504947.png
20、回到宝塔linux面板创建站点,并将创建的站点设置为默认站点,并找到安装的php版本,将其max_input_time值修改为300。
http://s1.运维网.com/images/20180802/1533170128163162.png
http://s1.运维网.com/images/20180802/1533170140103752.png
http://s1.运维网.com/images/20180802/1533170155747776.png
21、在crt使用cp -r /root/zabbix-3.4.11/frontends/php/* /www/wwwroot/zabbix.local/(这里的zabbix.local/就是上一步创建的站点目录)。
http://s1.运维网.com/images/20180802/1533170167402128.png
22、打开浏览器,输入安装zabbix的那台机子的ip/setup进行web前端的安装,对截图中圈住部分的内容进行填写然后一直下一步完成安装。
http://s1.运维网.com/images/20180802/1533170236774952.png
http://s1.运维网.com/images/20180802/1533170244832605.png
http://s1.运维网.com/images/20180802/1533170269522525.png
http://s1.运维网.com/images/20180802/1533170290241241.png
http://s1.运维网.com/images/20180802/1533170301798832.png
23、下载下图中箭头指向位置的文件,并将其上传到站点目录中的conf文件夹内。
http://s1.运维网.com/images/20180802/1533170316707893.png
http://s1.运维网.com/images/20180802/1533170346622289.png
上传完成后,点击上一步中最后一图中的finish,出现下面的内容即可完成zabbix web前端的安装。
http://s1.运维网.com/images/20180802/1533170368675909.png
24、上一步完成后再点击finish就会弹出登陆界面,输入默认的账户名:Admin,密码:zabbix即可登陆,登陆后,如无意外会出现下面第二张图中圈住部分的错误。
http://s1.运维网.com/images/20180802/1533170381278634.png
http://s1.运维网.com/images/20180802/1533170402431320.png
25、回到crt使用cat /tmp/zabbix_server.log查看产生错误的原因。
http://s1.运维网.com/images/20180802/1533170417133875.png
http://s1.运维网.com/images/20180802/1533170438451419.png
26、使用find /-name mysql.sock命令查找mysql.sock所在的路径是在/tmp/文件夹内,,跟上一步看到的/var/lib/mysql/mysql.sock这个路径不符,为此我们对mysql.sock采用软链接的方式去处理。
http://s1.运维网.com/images/20180802/1533170451405846.png
处理命令如下:
mkdir /var/lib/mysql
ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock
http://s1.运维网.com/images/20180802/1533170483983639.png
上述命令完成后使用/etc/rc.d/init.d/mysqld restart对mysql进行重启。
http://s1.运维网.com/images/20180802/1533170497319984.png
27、刷新zabbix web界面,发现错误消失,一切恢复正常。
http://s1.运维网.com/images/20180802/1533170509341827.png



页: [1]
查看完整版本: centos使用宝塔linux面板搭建zabbix过程记录