离线服务器安装zabbix
因为机房内的服务器并不是所有都能上外网,所以利用zabbix官方源的安装方法就行不通了,又嫌弃编译安装麻烦,所以这里选择离线RPM包安装zabbix。(如需完整rpm包可以留言与我联系)
下载zabbix离线安装包
1.首先在可以上外网的测试机上(测试机系统版本需要与离线服务器相同)安装zabbix的官方源,随便挑一个版本
1 2 3 4 | rpm -i https: //repo .zabbix.com /zabbix/3 .4 /rhel/7/x86_64/zabbix-release-3 .4-2.el7.noarch.rpm ##3.4 rpm -i https: //repo .zabbix.com /zabbix/3 .2 /rhel/7/x86_64/zabbix-release-3 .2-1.el7.noarch.rpm ##3.2 rpm -i https: //repo .zabbix.com /zabbix/3 .0 /rhel/7/x86_64/zabbix-release-3 .0-1.el7.noarch.rpm ##3.0 rpm -i https: //repo .zabbix.com /zabbix/2 .2 /rhel/7/x86_64/zabbix-release-2 .2-1.el7.noarch.rpm ##2.2 |
2. 利用yum的下载包功能,将zabbix需要的所有软件都下载下来(yum会解决rpm包的依赖问题)
1 | [root@localhost ~]# yum install --downloadonly --downloaddir=/root zabbix-XXXXXXXXXX |
因为zabbix需要LAMP的环境,所以上面利用yum下载的包还应该有httpd、php、php-mysql、mariadb、mariadb-server包。同时离线服务器可能没有安装createrepo,无法生成yum索引,所以这里还要下载一个createrepo软件
3.下载完成后,所有的rpm包都在root目录下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | [root@localhost ~]# ls /root apr-1.4.8-3.el7_4.1.x86_64.rpm apr-util-1.5.2-6.el7.x86_64.rpm dejavu-fonts-common-2.33-6.el7.noarch.rpm dejavu-sans-fonts-2.33-6.el7.noarch.rpm fontpackages-filesystem-1.44-8.el7.noarch.rpm fping-3.10-1.el7.x86_64.rpm httpd-2.4.6-80.el7.centos.1.x86_64.rpm httpd-tools-2.4.6-80.el7.centos.1.x86_64.rpm iksemel-1.4-2.el7.centos.x86_64.rpm libevent-2.0.21-4.el7.x86_64.rpm libtool-ltdl-2.4.2-22.el7_3.x86_64.rpm libXpm-3.5.12-1.el7.x86_64.rpm libxslt-1.1.28-5.el7.x86_64.rpm libzip-0.10.1-8.el7.x86_64.rpm mailcap-2.1.41-2.el7.noarch.rpm mariadb-5.5.56-2.el7.x86_64.rpm mariadb-libs-5.5.56-2.el7.x86_64.rpm mariadb-server-5.5.56-2.el7.x86_64.rpm net-snmp-libs-5.7.2-33.el7_5.2.x86_64.rpm OpenIPMI-libs-2.0.23-2.el7.x86_64.rpm OpenIPMI-modalias-2.0.23-2.el7.x86_64.rpm openssl-1.0.2k-12.el7.x86_64.rpm openssl-libs-1.0.2k-12.el7.x86_64.rpm perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64.rpm perl-Compress-Raw-Zlib-2.061-4.el7.x86_64.rpm perl-Data-Dumper-2.145-3.el7.x86_64.rpm perl-DBD-MySQL-4.023-6.el7.x86_64.rpm perl-DBI-1.627-4.el7.x86_64.rpm perl-IO-Compress-2.061-2.el7.noarch.rpm perl-Net-Daemon-0.48-5.el7.noarch.rpm perl-PlRPC-0.2020-14.el7.noarch.rpm php-5.4.16-45.el7.x86_64.rpm php-bcmath-5.4.16-45.el7.x86_64.rpm php-cli-5.4.16-45.el7.x86_64.rpm php-common-5.4.16-45.el7.x86_64.rpm php-fpm-5.4.16-45.el7.x86_64.rpm php-gd-5.4.16-45.el7.x86_64.rpm php-ldap-5.4.16-45.el7.x86_64.rpm php-mbstring-5.4.16-45.el7.x86_64.rpm php-mysql-5.4.16-45.el7.x86_64.rpm php-pdo-5.4.16-45.el7.x86_64.rpm php-xml-5.4.16-45.el7.x86_64.rpm t1lib-5.1.2-14.el7.x86_64.rpm unixODBC-2.3.1-11.el7.x86_64.rpm zabbix-agent-3.4.11-1.el7.x86_64.rpm zabbix- get -3.4.11-1.el7.x86_64.rpm zabbix-proxy-mysql-3.4.11-1.el7.x86_64.rpm zabbix-sender-3.4.11-1.el7.x86_64.rpm zabbix-server-mysql-3.4.11-1.el7.x86_64.rpm zabbix-web-3.4.11-1.el7.noarch.rpm zabbix-web-mysql-3.4.11-1.el7.noarch.rpm |
离线服务器安装zabbix
4.将这些rpm包通过xftp等工具拷出来,放在U盘等其他介质里,拷贝到离线服务器中
5.在离线服务器中新建个/zabbix文件夹存放这些rpm包
1 | [root@localhost ~] # mkdir /zabbix |
5.1.将下载好的zabbix离线安装包通过xftp传入服务器内
6.在/etc/yum.repos.d文件夹中添加myzabbix.repo文件,并将其他的repo移至back文件夹中
1 2 3 4 5 6 7 8 9 | [root@localhost ~]# cd /etc/yum.repos.d/ [root@localhost yum.repos.d]# mkdir back [root@localhost yum.repos.d]# mv *.repo back [root@localhost yum.repos.d]# vi myzabbix.repo [ base ] name= base baseurl=file: ///zabbix enable=1 gpgcheck=0 |
7.前面提到,可能这台离线服务器没有安装createrepo软件,所以去刚刚的rpm文件夹中安装。这里因为诶依赖关系可能会报错,不过依赖的两个包都已经下载下来了。
1 | [root@localhost zabbix]# rpm -ivh createrepo |
8.生成本地zabbix源的索引文件
1 2 3 4 5 6 7 8 | [root@localhost yum.repos.d]# createrepo /zabbix/ Spawning worker 0 with 51 pkgs Workers Finished Saving Primary metadata Saving file lists metadata Saving other metadata Generating sqlite DBs Sqlite DBs complete |
9.清空yum缓存后,在查看所有可以安装的软件
1 2 3 4 5 6 | [root@localhost yum.repos.d]# yum clean all Loaded plugins: fastestmirror, langpacks Cleaning repos: base Cleaning up everything Cleaning up list of fastest mirrors [root@localhost yum.repos.d]# yum list all |
10.如果没有报错的话,就可以用yum直接装LAMP环境和zabbix了。如果中途提示缺少依赖性软件,代表第二步没有下载完整
1 | [root@localhost zabbix] # yum install mariadb-server zabbix-server-mysql zabbix-web-mysql -y |
调试数据库及PHP
1.新建zabbix数据库,并把其数据库所有权限赋予给zabbix用户,密码为password
1 2 3 4 | [root@localhost ~] mysql -uroot ##初始没密码 mysql> create database zabbix character set utf8 collate utf8_bin; ##调整编码格式 mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'password' ; ##给本地的zabbix权限 mysql> quit; |
1 | zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix |
3.在zabbix服务端配置文件中,将刚刚设置的密码填写到对应位置,注意大小写
1 2 | [root@localhost ~]# vi /etc/zabbix/zabbix_server.conf DBPassword=password ##注意大小写 |
4.更改httpd中zabbix.conf中的时区为上海
1 2 | [root@localhost ~]# vi /etc/httpd/conf.d/zabbix.conf php_value date.timezone Asia/shanghai |
5.linux版本zabbix客户端的安装
1 2 3 4 5 6 7 8 9 | #安装客户端 [root@localhost zabbix] # yum install zabbix-agent-3.4.11-1.el7.x86_64.rpm -y #修改配置文件 [root@localhost ~] # vi /etc/zabbix/zabbix_agentd.conf Server=127.0.0.1 ##允许哪个主机来取数据 ServerActive=127.0.0.1 ##将数据发送给哪个主机 #启动并开机自启客户端 [root@localhost zabbix] # systemctl start zabbix-agent [root@localhost zabbix] # systemctl enable zabbix-agent |
5.1.windows版本zabbix客户端的安装
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | #在C盘下新建zabbix文件夹 C:\zabbix #解压下载的zabbix客户端安装包,将文件夹内的bin\win64\zabbix_agentd.exe和conf\zabbix_agentd.win.conf两个文件复制到刚刚新建的zabbix文件夹内 #编辑zabbix_agentd.win.conf文件,指定server地址到对应服务器 #运行cmd命令,安装客户端程序 C:\> c:\zabbix\zabbix_agentd.exe -c c:\zabbix\zabbix_agentd.win.conf -i #到服务下,启动客户端程序 #下面是官方文档 Agent on Windows systems Zabbix agent on Windows runs as a Windows service. Preparation Zabbix agent is distributed as a zip archive. After you download the archive you need to unpack it. Choose any folder to store Zabbix agent and the configuration file , e. g. C:\zabbix Copy bin\win64\zabbix_agentd.exe and conf\zabbix_agentd.win.conf files to c:\zabbix. Edit the c:\zabbix\zabbix_agentd.win.conf file to your needs, making sure to specify a correct “Hostname” parameter. Installation After this is done use the following command to install Zabbix agent as Windows service: C:\> c:\zabbix\zabbix_agentd.exe -c c:\zabbix\zabbix_agentd.win.conf -i Now you should be able to configure “Zabbix agent” service normally as any other Windows service. See more details on installing and running Zabbix agent on Windows. |
5.2.到这一步,基本的部署工作就做完了,只剩下启动服务,在启动服务之前,需要确定一下SElinux,firewalld是否为关闭状态。因为这些应用都会干扰zabbix的正常运行。
1 2 3 4 5 6 7 8 9 10 11 | #查看selinux状态 [root@localhost zabbix] # getenforce Enforcing #开启状态 #设置selinux为被动模式 [root@localhost zabbix] # setenforce 0 [root@localhost zabbix] # getenforce Permissive #被动模式 [root@localhost zabbix] # vi /etc/selinux/config SELINUX=disable |
1 2 3 4 5 6 7 8 9 10 11 12 13 | #查看firewall是否开机启动 [root@localhost zabbix] # systemctl list-unit-files | grep fire firewalld.service enabled #查看firewall是否正在运行 [root@localhost zabbix] # systemctl status firewalld.service [root@localhost zabbix] # systemctl list-units | grep fire #停掉firewall,并禁止开机启动 [root@localhost zabbix] # systemctl stop firewalld.service [root@localhost zabbix] # systemctl disable firewalld.service #再次查看selinux和firewall是否停掉了 |
6.开启服务
1 2 | [root@localhost ~]# systemctl start httpd zabbix-server zabbix-agent [root@localhost ~]# systemctl restart mariadb.service |
7.打开浏览器输入http://serverIP/zabbix
8.点击下一步后,右侧显示都OK继续
9.下一步后,对照刚才的配置填写密码
10.给自己的zabbix起个名字
11.确认刚才的配置
12.结束就完事了
13.登录时,默认的用户名是Admin,密码为zabbix,注意大小写
14.到这一步,安装就已经都完成了
解决zabbix图形乱码问题
从windows字体库中,将楷体字复制出来,放到/usr/share/zabbix/fonts/目录下
1 2 3 4 5 6 7 8 | [root@localhost zabbix] # cd /usr/share/zabbix/fonts/ [root@localhost fonts] # ls graphfont.ttf simkai.ttf #将默认字体改为楷体 [root@localhost fonts] # vi /usr/share/zabbix/include/defines.inc.php define( 'ZBX_GRAPH_FONT_NAME' , 'simkai' ); // font file name define( 'ZBX_FONT_NAME' , 'simkai' ); |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)