Zabbix是一个非常强大的监控系统,是企业级的软件,来监控IT基础设施的可用性和性能.它是一个能够快速搭建起来的开源的监控系统,Zabbix能监视各种网络参数,保证服务器系统的安全运营,并提供灵活的通知机制以让系统管理员快速定位解决存在的各种问题,Zabbix系统几乎可用于任何系统的监控过程
通过YUM仓库安装
1.在开始安装软件之前,需要配置yum源与zabbix源,这里我们就使用163的YUM源吧.
[root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo [root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo [root@localhost ~]# rpm -ivh http://repo.zabbix.com/zabbix/4.1/rhel/7/x86_64/zabbix-release-4.1-1.el7.noarch.rpm
2.由于Zabbix需要一个Web展现出页面来,所以在这里我们需要自行安装一个LAMP或LNMP环境.
[root@localhost ~]# yum install -y mariadb mariadb-server httpd php php-mysql Package 1:mariadb-5.5.60-1.el7_5.x86_64 already installed and latest version Package 1:mariadb-server-5.5.60-1.el7_5.x86_64 already installed and latest version Package httpd-2.4.6-88.el7.centos.x86_64 already installed and latest version Package php-5.4.16-46.el7.x86_64 already installed and latest version Package php-mysql-5.4.16-46.el7.x86_64 already installed and latest version Nothing to do
3.接着安装Zabbix组件,这里由于是YUM安装所以直接执行yum install
就搞定了.
[root@localhost ~]# yum install -y net-snmp zabbix-web zabbix-agent zabbix-server-mysql zabbix-web-mysql Package 1:net-snmp-5.7.2-37.el7.x86_64 already installed and latest version Package zabbix-web-4.2.0-0.1alpha1.el7.noarch already installed and latest version Package zabbix-agent-4.2.0-0.1alpha1.el7.x86_64 already installed and latest version Package zabbix-server-mysql-4.2.0-0.1alpha1.el7.x86_64 already installed and latest version Package zabbix-web-mysql-4.2.0-0.1alpha1.el7.noarch already installed and latest version Nothing to do
4.配置Zabbix表结构,创建MariaDB用户并用于Zabbix授权使用,并恢复Zabbix表结构.
[root@localhost ~]# systemctl start mariadb [root@localhost ~]# systemctl enable mariadb [root@localhost ~]# mysql Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 2 Server version: 5.5.60-MariaDB MariaDB Server 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; MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix'; MariaDB [(none)]> exit [root@localhost ~]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -pzabbix zabbix
5.将Zabbix的页面文件拷贝到指定目录(跟apache配置的相同即可).
[root@localhost ~]# cp -a /usr/share/zabbix/* /var/www/html/ [root@localhost ~]# chmod 755 -R /var/www/html/ [root@localhost ~]# chown apache.apache -R /var/www/html/* [root@localhost ~]# systemctl restart httpd [root@localhost ~]# systemctl enable httpd
6.修改PHP配置文件,在PHP配置文件的末尾添加即可,主要目的是调整一下PHP参数,否则Zabbix不通过.
[root@localhost ~]# vim /etc/php.ini date.timezone = Asia/Shanghai max_execution_time = 300 max_input_time = 300 post_max_size = 32M memory_limit = 128M mbstring.func_overload = 0
7.配置Zabbix Server端配置文件,主要目的是定义数据库的IP、用户名、密码等.
[root@localhost ~]# vim /etc/zabbix/zabbix_server.conf DBHost=localhost #监控主机数据库IP,这里是本地 DBName=zabbix #数据库名 DBUser=zabbix #访问,数据库的用户名 DBPassword=zabbix #访问,数据库访问密码
8.所有工作配置完成以后,启动一下Zabbix进程和Apache服务.
systemctl restart httpd systemctl restart mariadb systemctl restart zabbix-server systemctl restart zabbix-agent
9.拓展环节:如果你的Zabbix登陆密码忘记了,你可以使用以下命令找回来.
MariaDB [(none)]> update zabbix.users set passwd=md5(123123) where name="Zabbix";
10.解决中文乱码问题,并登陆系统看结果吧.
#在windows系统中:Win+R -> fonts -> 拷贝微软雅黑字体改名为 msyh.ttf [root@localhost ~]# cp -a msyh.ttf /var/www/html/fonts// [root@localhost ~]# vim /var/www/html/include/defines.inc.php #修改 zabbix php 页面配置,将'DejaVuSans' 修改为 'msyh' 65 define('ZBX_GRAPH_FONT_NAME', 'msyh'); // font file name [root@localhost ~]# systemctl restart httpd 用户名:Admin 密码:zabbix
1.在监控之前我们首先要安装一个工具,就是Zabbix的客户端组件.
[RHEL6] [root@localhost ~]# wget http://repo.zabbix.com/zabbix/4.1/rhel/6/x86_64/zabbix-agent-4.2.0-0.1alpha1.el6.x86_64.rpm [root@localhost ~]# rpm -ivh zabbix-agent-4.2.0-0.1alpha1.el6.x86_64.rpm [RHEL7] [root@localhost ~]# wget http://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-agent-4.4.3-1.el7.x86_64.rpm [root@localhost ~]# rpm -ivh zabbix-agent-4.2.0-0.1alpha1.el7.x86_64.rpm
2.编辑Zabbix客户端配置文件,指定Zabbix服务器的IP地址.
[root@localhost ~]# vim /etc/zabbix/zabbix_agentd.conf Server=192.168.1.10 #填写Server的IP地址 ServerActive=192.168.1.10 #修改为Server的IP地址 Hostname=centos_01 #填写本机的HostName
3.启动Zabbix客户端进程,并设置开机自启动.
[root@localhost ~]# systemctl restart zabbix-agent [root@localhost ~]# systemctl enable zabbix-agent [root@localhost ~]# /usr/sbin/zabbix_agentd
1.首先下载监控Windows的客户端组件,并修改一下配置文件.
https://assets.zabbix.com/downloads/3.4.6/zabbix_agents_3.4.6.win.zip https://www.zabbix.com/downloads/4.0.0/zabbix_agents-4.0.0-win-amd64.zip 修改文件:zabbix_agentd.win.conf Server=192.168.1.10 #填写Server的IP地址 ServerActive=192.168.1.10 #修改为Server的IP地址 Hostname=centos_01 #填写本机的HostName
2.打开命令行,并启动相应服务即可.
zabbix_agentd.exe -c C:\zabbix\conf\zabbix_agentd.win.conf -i #将进程添加到 windows 服务管理 zabbix_agentd.exe -c C:\zabbix\conf\zabbix_agentd.win.conf -s #开启服务
通过源码编译安装
1.由于Zabbix是基于Web界面的,所以在编译安装Zabbix之前,我们应该准备好一个LAMP或者LNMP的系统环境,来确保Zabbix能够通过Web展现出来.
[root@localhost ~]# yum install -y gcc httpd httpd-devel mariadb mariadb-server mariadb-devel php php-mysql php-common php-gd php-xml Package gcc-4.8.5-36.el7.x86_64 already installed and latest version Package httpd-2.4.6-88.el7.centos.x86_64 already installed and latest version Package httpd-devel-2.4.6-88.el7.centos.x86_64 already installed and latest version Package 1:mariadb-5.5.60-1.el7_5.x86_64 already installed and latest version Package 1:mariadb-server-5.5.60-1.el7_5.x86_64 already installed and latest version Package 1:mariadb-devel-5.5.60-1.el7_5.x86_64 already installed and latest version Package php-5.4.16-46.el7.x86_64 already installed and latest version Package php-mysql-5.4.16-46.el7.x86_64 already installed and latest version Package php-common-5.4.16-46.el7.x86_64 already installed and latest version Package php-gd-5.4.16-46.el7.x86_64 already installed and latest version Package php-xml-5.4.16-46.el7.x86_64 already installed and latest version Nothing to do [root@localhost ~]# yum install -y libevent-devel php-bcmath php-common php-mbstring Package libevent-devel-2.0.21-4.el7.x86_64 already installed and latest version Package php-bcmath-5.4.16-46.el7.x86_64 already installed and latest version Package php-common-5.4.16-46.el7.x86_64 already installed and latest version Package php-mbstring-5.4.16-46.el7.x86_64 already installed and latest version Nothing to do
2.接着我们先来安装一下Zabbix编译所依赖的包文件,具体操作如下.
[root@localhost ~]# yum install -y net-snmp-devel curl curl-devel libxml2-devel libcurl-devel libevent libevent-devel Package 1:net-snmp-devel-5.7.2-37.el7.x86_64 already installed and latest version Package curl-7.29.0-51.el7.x86_64 already installed and latest version Package libcurl-devel-7.29.0-51.el7.x86_64 already installed and latest version Package libxml2-devel-2.9.1-6.el7_2.3.x86_64 already installed and latest version Package libcurl-devel-7.29.0-51.el7.x86_64 already installed and latest version Package libevent-2.0.21-4.el7.x86_64 already installed and latest version Package libevent-devel-2.0.21-4.el7.x86_64 already installed and latest version Nothing to do
3.继续,我们通过wget命令下载一个Zabbix源码包,执行以下编译过程.
[root@localhost ~]# wget https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/4.0.2/zabbix-4.0.2.tar.gz [root@localhost ~]# useradd -M -s /sbin/nologin zabbix [root@localhost ~]# tar -xzvf zabbix-4.0.2.tar.gz [root@localhost ~]# cd zabbix-4.0.2/ [root@localhost ~]# ./configure --prefix=/usr/local/zabbix --enable-server \ --enable-agent --with-mysql --enable-ipv6 --with-net-snmp \ --with-libcurl --with-libxml2 --enable-java [root@localhost ~]# make && make install
4.配置Zabbix表结构,创建MariaDB用户并用于Zabbix授权使用,并恢复Zabbix表结构.
[root@localhost ~]# systemctl start mariadb [root@localhost ~]# systemctl enable mariadb [root@localhost ~]# mysql Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 2 Server version: 5.5.60-MariaDB MariaDB Server 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 DEFAULT CHARACTER SET utf8 COLLATE utf8_bin; MariaDB [(none)]> grant all on zabbix.* to zabbix@"%" identified by "zabbix"; MariaDB [(none)]> grant all on zabbix.* to zabbix@"localhost" identified by "zabbix"; MariaDB [(none)]> exit [root@localhost ~]# cd /root/zabbix-4.0.2/database/mysql/ [root@localhost mysql]# mysql -uzabbix -pzabbix zabbix <schema.sql [root@localhost mysql]# mysql -uzabbix -pzabbix zabbix <images.sql [root@localhost mysql]# mysql -uzabbix -pzabbix zabbix <data.sql
5.将Zabbix的页面文件拷贝到指定目录(跟apache配置的相同即可).
[root@localhost ~]# cp -a /root/zabbix-4.0.2/frontends/php/* /var/www/html/ [root@localhost ~]# chown -R apache:apache /var/www/html/ [root@localhost ~]# systemctl restart httpd [root@localhost ~]# systemctl enable httpd
6.修改PHP配置文件,在PHP配置文件的末尾添加即可,主要目的是调整一下PHP参数,否则Zabbix不通过.
[root@localhost ~]# vim /etc/php.ini date.timezone = Asia/Shanghai max_execution_time = 300 max_input_time = 300 post_max_size = 32M memory_limit = 128M mbstring.func_overload = 0
7.配置Zabbix Server端配置文件,主要目的是定义数据库的IP、用户名、密码等.
[root@localhost ~]# vim /usr/local/zabbix/etc/zabbix_server.conf DBHost=localhost #监控主机数据库IP,这里是本地 DBName=zabbix #数据库名 DBUser=zabbix #访问,数据库的用户名 DBPassword=zabbix #访问,数据库访问密码
8.所有工作配置完成以后,启动一下Zabbix进程和Apache服务.
[root@localhost ~]# /usr/local/zabbix/sbin/zabbix_server [root@localhost ~]# echo "/usr/local/zabbix/sbin/zabbix_server" >> /etc/bashrc [root@localhost ~]# systemctl restart httpd
9.拓展环节:如果你的Zabbix登陆密码忘记了,你可以使用以下命令找回来.
MariaDB [(none)]> update zabbix.users set passwd=md5(123123) where name="Zabbix";
10.解决中文乱码问题,并登陆系统看结果吧.
#在windows系统中:Win+R -> fonts -> 拷贝微软雅黑字体改名为 msyh.ttf [root@localhost ~]# cp -a msyh.ttf /var/www/html/fonts// [root@localhost ~]# vim /var/www/html/include/defines.inc.php #修改 zabbix php 页面配置,将'DejaVuSans' 修改为 'msyh' 65 define('ZBX_GRAPH_FONT_NAME', 'msyh'); // font file name [root@localhost ~]# systemctl restart httpd 用户名:Admin 密码:zabbix
1.首先安装依赖和,编译环境.
[root@localhost ~]# yum install -y gcc pcre-devel pcre-static pcre-tools
2.编译安装Zabbix客户端监控程序,这里同样适用相同的压缩包.
[root@localhost ~]# wget https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/4.0.2/zabbix-4.0.2.tar.gz [root@localhost ~]# useradd -M -s /sbin/nologin zabbix [root@localhost ~]# tar -xzvf zabbix-4.0.2.tar.gz [root@localhost ~]# cd zabbix-4.0.2/ [root@localhost ~]# ./configure --prefix=/usr/local/zabbix --sysconfdir=/etc/zabbix --enable-agent [root@localhost ~]# make && make install
3.配置Zabbix-Agent端配置文件,修改主机列表.
[root@localhost ~]# vim /etc/zabbix/zabbix_agentd.conf Server=192.168.22.195 #填写Server的IP地址 ServerActive=192.168.22.195 #修改为Server的IP地址 Hostname=centos_1 #填写本机的HostName
4.启动zabbix-agent端,并设置开机自启动.
[root@localhost ~]# /usr/local/zabbix/sbin/zabbix_agentd [root@localhost ~]# echo "/usr/local/zabbix/sbin/zabbix_agentd" >> /etc/bashrc
以上内容由“WiFi之家网”整理收藏!。
评论