当前位置:网站首页>zabbix的安装避坑指南
zabbix的安装避坑指南
2022-06-25 03:34:00 【51CTO】
(1)zabbix的服务端的安装:
①zabbix部署流程规划:
1、centos7不支持yum安装服务端,客户端可以yum安装
2、部署ngx+php环境并测试
3、部署数据库 mariadb 10.5以及上
4、编译安装zabbix-server服务器以及后端配置
5、部署前端代码进行访问
6、web访问
②部署nginx+php:
1、yum -y isntall nginx
[[email protected] conf.d]# cat zabbix.conf
server {
listen 80;
server_name localhost;
access_log /var/log/nginx/she-access.log main;
error_log /var/log/nginx/she-error.log notice;
root /app/code/zbx;
#静态
location / {
index index.php;
}
#动态
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index_php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
[[email protected] conf.d]#
2、[[email protected] zabbix-6.0.5]# yum install -y php72w-cli php72w-fpm php72w-gd php72w-mbstring php72w-bcmath php72w-xml php72w-ldap php72w-mysqlnd -y
3、修改php的配置:
[[email protected] conf.d]# grep 'nginx' /etc/php-fpm.d/www.conf
user = nginx
group = nginx
[[email protected] conf.d]#
4、启动:
[[email protected] tmp]# systemctl enable php-fpm.service
[[email protected] tmp]# systemctl enable nginx
[[email protected] tmp]# systemctl start php-fpm.service
[[email protected] tmp]# systemctl start nginx
5、测试php:
[[email protected] code]# cat zbx/info.php
<?php
phpinfo();
?>
[[email protected] code]#
6、查看是否出现页面,看php是否配合nginx:
http://120.48.55.178/info.php
③部署数据库:
1、zabbix 6.0不支持mariadb5.5要安装mariddb10.0以上
2、配置mariadb yum源:
[[email protected] ~]# cat /etc/yum.repos.d/mariddb.repo
# MariaDB 10.5 CentOS repository list - created 2022-06-24 08:48 UTC
# https://mariadb.org/download/
[mariadb]
name = MariaDB
baseurl = https://tw1.mirror.blendbyte.net/mariadb/yum/10.5/centos7-amd64
gpgkey=https://tw1.mirror.blendbyte.net/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck=0
[[email protected] ~]# yum install -y MariaDB-server MariaDB-client
3、检查是否安装:
[[email protected] code]# rpm -qa |grep -i mariadb
MariaDB-common-10.5.16-1.el7.centos.x86_64
MariaDB-server-10.5.16-1.el7.centos.x86_64
MariaDB-compat-10.5.16-1.el7.centos.x86_64
MariaDB-client-10.5.16-1.el7.centos.x86_64
[[email protected] code]#
4、启动:
[[email protected] code]# systemctl enable mariadb
[[email protected] code]# systemctl start mariadb
5、数据库初始化:{仅一次}
[[email protected] code]# mysql_secure_installation
You already have your root account protected, so you can safely answer 'n'. <新数据库没密码输n>
Switch to unix_socket authentication [Y/n] n <输n>
... skipping.
You already have your root account protected, so you can safely answer 'n'.
Change the root password? [Y/n] y <修改一个数据库root的密码>
Remove anonymous users? [Y/n] y <y>
... Success!
Disallow root login remotely? [Y/n] y <y>
... Success!
e moving into a production environment.
Remove test database and access to it? [Y/n] y <y>
Reload privilege tables now? [Y/n] y <y>
... Success!
[[email protected] code]#
6、创建库:
[[email protected] code]# mysql -uroot -p
MariaDB [(none)]> create database zabbix charset utf8 collate utf8_bin;
Query OK, 1 row affected (0.000 sec)
MariaDB [(none)]> grant all on zabbix.* to 'zabbix'@'localhost' identified by 'zabbix';
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]>
7、向数据库中导入数据:{注意导入顺序-不能错千万}
1.下载源码包:https://cdn.zabbix.com/zabbix/sources/stable/6.0/zabbix-6.0.5.tar.gz
2.导入:
[[email protected] database]# cd /tmp/zabbix-6.0.5/database/mysql/
[[email protected] mysql]# ls -lh
total 33M
-rw-r--r-- 110001000 31M May 3014:23 data.sql
-rw-r--r-- 110001000282 May 3014:22 double.sql
-rw-r--r-- 1100010001.5K May 3014:22 history_pk_prepare.sql
-rw-r--r-- 1100010001.9M May 216:26 images.sql
-rw-r--r-- 110001000508 May 3014:22 Makefile.am
-rw-r--r-- 110001000 16K May 3014:22 Makefile.in
-rw-r--r-- 110001000 161K May 3014:23 schema.sql
[[email protected] mysql]#
[[email protected] mysql]# pwd
/tmp/zabbix-6.0.5/database/mysql
[[email protected] mysql]# mysql -uroot -p'mima' zabbix < schema.sql
[[email protected] mysql]# mysql -uroot -p'mima' zabbix < images.sql
[[email protected] mysql]# mysql -uroot -p'mima' zabbix < data.sql
[[email protected] mysql]# mysql -uroot -p'mima' zabbix < double.sql
[[email protected] mysql]# mysql -uroot -p'mima' zabbix < history_pk_prepare.sql
④编译安装zabbix:
1、安装依赖:
[[email protected] zabbix-6.0.5]# yum install -y mysql-devel pcre-devel openssl-devel zlib-devel libxml2-devel net-snmp-devel net-snmp libssh2-devel OpenIPMI-devel libevent-devel openldap-devel libcurl-devel
2、进行配置:
[[email protected] zabbix-6.0.5]# ./configure --sysconfdir=/etc/zabbix/ --enable-server --with-mysql --with-net-snmp --with-libxml2 --with-ssh2 --with-openipmi --with-zlib --with-libpthread --with-libevent --with-openssl --with-ldap --with-libcurl --with-libpcre
编译成功的提示:
Configuration file: /etc/zabbix/zabbix_server.conf
External scripts: /usr/local/share/zabbix/externalscripts
Alert scripts: /usr/local/share/zabbix/alertscripts
Modules: /usr/local/lib/modules
3、编译:
[[email protected] zabbix-6.0.5]# make install
4、检查:
[email protected] zabbix-6.0.5]# zabbix_server --version
zabbix_server (Zabbix) 6.0.5
Revision 8da3e1f8419 30 May 2022, compilation time: Jun 24202220:31:28
Copyright (C) 2022 Zabbix SIA
License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it according to
the license. There is NO WARRANTY, to the extent permitted by law.
This product includes software developed by the OpenSSL Project
for use in the OpenSSL Toolkit (http://www.openssl.org/).
Compiled with OpenSSL 1.0.2k-fips 26 Jan 2017
Running with OpenSSL 1.0.2k-fips 26 Jan 2017
[[email protected] zabbix-6.0.5]#
⑤修改zabbix的配置文件:
1、修改配置文件:
[[email protected] ~]# grep -n '^[a-Z]' /etc/zabbix/zabbix_server.conf
12:ListenPort=10051
38:LogFile=/tmp/zabbix_server.log
99:DBName=zabbix
115:DBUser=zabbix
123:DBPassword=zabbix
507:Timeout=4
593:LogSlowQueries=3000
708:StatsAllowedIP=127.0.0.1
[[email protected] ~]#
2、添加zabbix的用户:
[[email protected] ~]# useradd -s /sbin/nolging -M zabbix
[[email protected] ~]#
3、检查zabbix:
[[email protected] ~]# ps -ef|grep zabbix
[[email protected] ~]# netstat -tulnp|grep zabbix
tcp 000.0.0.0:100510.0.0.0:* LISTEN 30417/zabbix_server
[[email protected] ~]#
⑥给zabbix增加systemcctl的管理:
1、管理的书写:
[[email protected] ~]# cat /usr/lib/systemd/system/zabbix-server.service
[Unit]
Description=Zabbix Server with MySQL DB
After=syslog.target network.target mysqld.service
[Service]
Type=simple
ExecStart=/usr/local/sbin/zabbix_server -f
User=zabbix
[Install]
WantedBy=multi-user.target
[[email protected] ~]# systemctl daemon-reload
[[email protected] ~]#
2、 重启进程:
[[email protected] ~]# pkill zabbix
[[email protected] ~]# ps -ef|grep zabbix
root 3130229428022:59 pts/300:00:00grep --color=auto zabbix
[[email protected] ~]# systemctl enable zabbix-server.service
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.
[[email protected] ~]# systemctl start zabbix-server.service
[[email protected] ~]#
⑦zabbix前端代码的部署:
[[email protected] zabbix-6.0.5]# pwd
/root/zabbix-6.0.5
[[email protected] zabbix-6.0.5]# cp -a ui/* /app/code/zbx/
[[email protected] zabbix-6.0.5]# chown -R nginx.nginx /app/code/zbx/
[[email protected] zabbix-6.0.5]#
⑧安装zabbix:
1、安装:
http://120.48.55.178/setup.php
2、报错:{第四个是由于依赖没安装,步骤已经补在前面了}
3、去修改php的配置:
[[email protected] /]# grep -E -n '^(max_.*_time|post_max)' /etc/php.ini
368:max_execution_time = 600
378:max_input_time = 600
656:post_max_size = 80M
[[email protected] /]#
[[email protected] /]# systemctl restart nginx
[[email protected] /]# systemctl restart php-fpm.service
[[email protected] /]#
4、配置php连接数据库:{zabbix连接数据库是配置文件中定义的}
5、给你的zabbix起一个名字:
6、最终确认:
⑨登录:{账户Admin密码zabbix}
http://120.48.55.178/zabbix.php?action=dashboard.view
(2)安装zabbix客户端:
①安装一个agine的客户端:
1、先安装一个源:
[[email protected] zabbix-6.0.5]# rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/6.0/rhel/7/x86_64/zabbix-release-6.0-1.el7.noarch.rpm
2、查看这个源里有没有zabbix-agent2:
[[email protected] zabbix-6.0.5]# yum list|grep zabbix-agent2
zabbix-agent2.x86_64 6.0.5-1.el7 zabbix
[[email protected] zabbix-6.0.5]#
3、安装:{在线安装}太XX慢了
[[email protected] zabbix-6.0.5]# yum -y install zabbix-agent2
更换源:
[[email protected] ~]# sed -i 's#https://repo.zabbix.com/zabbix#https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix#g' /etc/yum.repos.d/zabbix.repo
4:{或者离线安装}
[[email protected] ~]# wget https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/6.0/rhel/7/x86_64/zabbix-agent2-6.0.5-1.el7.x86_64.rpm --no-check-certificate
[[email protected] ~]# rpm -ivh zabbix-agent2-6.0.5-1.el7.x86_64.rpm
7、修改客户端:{地址修改为服务器的ip,现在是在一起所以不用改}
[[email protected] ~]# grep -E '^[Server]' /etc/zabbix/zabbix_agent2.conf
Server=127.0.0.1
ServerActive=127.0.0.1
[[email protected] ~]#
8、启动zabbix客户端:
[[email protected] ~]# systemctl start zabbix-agent2.service
[[email protected] ~]# systemctl enable zabbix-agent2.service
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent2.service to /usr/lib/systemd/system/zabbix-agent2.service.
[[email protected] ~]#
9、检查:
[[email protected] ~]# ps -ef|grep agent2
zabbix 55561001:07 ? 00:00:00 /usr/sbin/zabbix_agent2 -c /etc/zabbix/zabbix_agent2.conf
root 557729428001:07 pts/300:00:00grep --color=auto agent2
[[email protected] ~]# netstat -tulpn|grep agent2
tcp6 00 :::10050 :::* LISTEN 5556/zabbix_agent2
10、查看结果:
边栏推荐
- 站在风暴中心:如何给飞奔中的腾讯更换引擎
- 孙武玩《魔兽》?有图有真相
- 股票开户用客户经理发的开户链接安全吗?知道的给说一下吧
- 力扣每日一题-第26天-506.相对名次
- Wuenda, the new course of machine learning is coming again! Free auditing, Xiaobai friendly
- Rebeco: using machine learning to predict stock crash risk
- Does it count as staying up late to sleep at 2:00 and get up at 10:00? Unless you can do it every day
- 支付宝被风控7天怎么办?付解决方案
- Standing at the center of the storm: how to change the engine of Tencent
- Two common OEE monitoring methods for equipment utilization
猜你喜欢
协作+安全+存储,云盒子助力深圳爱德泰重构数据中心
How to play well in the PMP Exam?
Musk was sued for $258billion in MLM claims. TSMC announced the 2nm process. The Chinese Academy of Sciences found that the lunar soil contained water in the form of hydroxyl. Today, more big news is
中国天眼发现地外文明可疑信号,马斯克称星舰7月开始轨道试飞,网信办:APP不得强制要求用户同意处理个人信息,今日更多大新闻在此...
威马招股书拆解:电动竞争已结束,智能排位赛刚开始
AI writes its own code to let agents evolve! The big model of openai has the flavor of "human thought"
Two common OEE monitoring methods for equipment utilization
The sign in function completes 03 "IVX low code sign in system production"
2点睡10点起不算熬夜?除非你每天都能执行
XML建模
随机推荐
How can novices of cross-border e-commerce prevent store association? What tool is good?
What if Alipay is controlled by risk for 7 days? Payment solution
Xidian AI ranked higher than Qingbei in terms of AI majors, and Nantah ranked the first in China in 2022 in terms of soft science majors
指南针在上面开户安全吗?靠谱吗?
扎克伯格最新VR原型机来了,要让人混淆虚拟与现实的那种
TCC mode explanation and code implementation of Seata's four modes
Skywalking implements cross thread trace delivery
Nacos practice record
Svn deployment
Dr. Sun Jian was commemorated at the CVPR conference. The best student thesis was awarded to Tongji Ali. Lifeifei won the huangxutao Memorial Award
The sign in function completes 03 "IVX low code sign in system production"
ASP. Net conference room booking applet source code booking applet source code
MySql安裝教程
Egg 服务搭建微信公众号的基础服务
ACM. Hj75 common substring calculation ●●
2022年海外电商运营三大关键讲解
存算一体芯片离普及还有多远?听听从业者怎么说 | 对撞派 x 后摩智能
威马招股书拆解:电动竞争已结束,智能排位赛刚开始
Program. Launch (xxx) open file
Wuenda, the new course of machine learning is coming again! Free auditing, Xiaobai friendly