软件 | 版本 |
---|---|
Apache | 1.3.12 或以上 |
PHP | 5.4.0 或以上 |
MySQL | 5.0.3 或以上 使用 MySQL 作为 Zabbix 后端数据库。需要 InnoDB 引擎。 |
Oracle | 10g 或以上 使用 Oracle 作为 Zabbix 后端数据库。 |
PostgreSQL | 8.1 或以上 使用 PostgreSQL 作为 Zabbix 后端数据库。建议使用 PostgreSQL 8.3 以上的版本。以 提供更好的 VACUUM 性能 。 |
SQLite | 3.3.5 或以上 使用 SQLite 作为 Zabbix 后端数据库。 |
IBM DB2 | 9.7 或以上 使用 IBM DB2 作为 Zabbix 后端数据库。 |
类型 | 描述 | 地址 |
---|---|---|
Zabbix服务器 | CentOS7 | 10.1.3.21 |
Zabbix客户端 | CentOS, AIX, Windows | 10.1.1.xxx/10.1.2.xxx |
安装Zabbix官方YUM源
shell> rpm -Uvh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
安装EPEL官方YUM源
shell> rpm -Uvh http://ftp.cuhk.edu.hk/pub/linux/fedora-epel/7/x86_64/e/epel-release-7-9.noarch.rpm
安装必要的依赖包以及组件包
shell> yum install gcc php php-gd php-mysql php-bcmath php-mbstring php-xml curl curl-devel net-snmp net-snmp-devel perl-DBI OpenIPMI-devel openssl-devel libcurl-devel httpd fping ntp ntpdate libiksemel libssh2
Zabbix几个常用的组件包:
安装Zabbix Server
shell> yum install zabbix-agent zabbix-server-mysql zabbix-web-mysql zabbix-get zabbix-web
Zabbix安装常用的几个组件包:
数据库安装PerconaDB, 获取PerconaDB官方YUM源
shell> yum install http://www.percona.com/downloads/percona-release/redhat/0.1-4/percona-release-0.1-4.noarch.rpm
使用YUM安装PerconaDB57
shell> yum remove mariadb* #移除自带的Mariadb
shell> yum install Percona-Server-server-57
初始化PerconaDB并启动
shell> cat /etc/my.cnf #按需修改PerconaDB的配置文件
注意: Mysql socket的文件位置必须为/var/lib/mysql/mysql.sock, 否则zabbix会提示连不到数据库
shell> cat /var/log/mysqld.log
2017-04-28T08:07:09.138876Z 1 [Note] A temporary password is generated for root@localhost: y:Pw/=XIS5oq
shell> mysqld --initialize --datadir=/data/mysql/
shell> systemctl start mysqld
shell> systemctl enable mysqld
shell> mysqladmin -uroot -p password
Enter password: # 输入mysqld.log的临时密码
New password: # 输入新的密码
Confirm new password: # 再次输入以确认
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
shell> mysql -u root -p
在PerconaDB里创建Zabbix数据库, 并赋予用户权限
shell> mysql -uroot -p
root@mysqldb 17:16: [(none)]> create database zabbix character set utf8; #创建数据库zabbix,并且数据库编码使用utf8;
Query OK, 1 row affected (0.02 sec)
root@mysqldb 17:16: [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix'; # 赋予权限, 允许账户能从本机连接至数据库zabbix,地址写的为localhost(亦可写为127.0.0.1),那么后面的相关配置配置就都要写localhost,否则连接数据库就会有问题;
Query OK, 0 rows affected, 2 warnings (0.01 sec)
root@mysqldb 17:16: [(none)]> flush privileges; # 刷新系统权限
Query OK, 0 rows affected (0.02 sec)
root@mysqldb 17:16: [(none)]> show databases # 查看创建的数据库
-> ;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| zabbix |
rows in set (0.01 sec)
Zabbix-Server对时间的精确要求比较高, 时间对数据的计算等都有影响, 因此, 最好设置ntp时间自动同步时间, 也可以用crontab进行同步:
shell> ntpdate -u ntp.sjtu.edu.cn > /dev/null 2>&1
shell> systemctl enable ntpd
Created symlink from /etc/systemd/system/multi-user.target.wants/ntpd.service to /usr/lib/systemd/system/ntpd.service.
shell> systemctl restart ntpd
shell> echo '*/30 * * * * /usr/sbin/ntpdate ntp.sjtu.edu.cn >/dev/null 2>&1'>>/var/spool/cron/root
确认Zabbix数据库文件的位置
shell> cd /usr/share/doc/zabbix-server-mysql-3.0.7
shell> ls
AUTHORS ChangeLog COPYING create.sql.gz NEWS README
将Zabbix数据库导入至PerconaDB中
shell> cd /usr/share/doc/zabbix-server-mysql-3.0.7
shell> zcat create.sql.gz | mysql -uzabbix -pzabbix zabbix
mysql: [Warning] Using a password on the command line interface can be insecure.
系统中的selinux必须关闭, 否则后面启动Zabbix Server的时候会报错.
shell> systemctl disable firewalld
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.
shell> systemctl stop firewalld
shell> sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
这里需要定义zabbix连接mysql的数据库, 用户名, 密码, 这里的参数必须和之前建立数据库的信息一直, 否则后面运行Zabbix server会有报错提示无法连接数据库.
shell> pwd
/etc/zabbix/
shell> vi zabbix_server.conf
DBName=zabbix ##91行, 修改为数据库名(zabbix)
DBUser=zabbix ##107行, 修改为数据库用户名(zabbix)
DBPassword=zabbix ##115行, 修改为数据库密码(zabbix)
在zabbix3.0中无须对php配置文件做修改, 只需要修改php的时区显示即可.
shell> sed -i "s@# php_value date.timezone Europe/Riga@php_value date.timezone Asia/Shanghai@g" /etc/httpd/conf.d/zabbix.conf
将微软雅黑的字体上传到/usr/share/zabbix/fonts/
目录下:
shell> pwd
/usr/share/zabbix/fonts
shell> ll
total 23056
lrwxrwxrwx 1 root root 33 Mar 30 2016 graphfont.ttf -> /etc/alternatives/zabbix-web-font
-rw-r--r-- 1 root root 23608184 Mar 30 00:10 msyh.ttc
shell> vi /usr/share/zabbix/include/defines.inc.php
45 define('ZBX_GRAPH_FONT_NAME', 'graphfont'); // font file name
93 define('ZBX_FONT_NAME', 'graphfont');
设置开机启动httpd, 重启httpd, 访问apache的默认页面.
shell> systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
shell> systemctl restart httpd
启动zabbix-agent和zabbix-server, 并添加开机自启动
shell> systemctl start zabbix-agent
shell> systemctl start zabbix-server
shell> systemctl enable zabbix-agent
shell> systemctl enable zabbix-server
停止Zabbix-Server和Zabbix-Agent
shell> systemctl stop zabbix-server
shell> systemctl stop zabbix-agent
直接yum update进行升级
shell> yum update zabbix*
使用脚本导出当前数据库.
shell> systemctl stop zabbix-server
shell> ./zabbixdb_backup.sh mysqldump
修改/etc/zabbix/zabbix_server.conf
配置文件.
shell> cat /etc/zabbix/zabbix_server.conf |grep -v ^#
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
DebugLevel=3
PidFile=/var/run/zabbix/zabbix_server.pid
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
Timeout=4
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
优化Zabbix的性能(以下内容按需修改, 下面配置适用于50-100的NVPS环境中)
shell> cat /etc/zabbix/zabbix_server.conf
StartPollers=5
StartIPMIPollers=10
StartPollersUnreachable=10
StartTrappers=10
StartPingers=10
StartDiscoverers=10
JavaGateway=10.66.1.81
StartJavaPollers=5
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
ListenIP=127.0.0.1
CacheSize=512M
StartDBSyncers=40
HistoryCacheSize=128M
TrendCacheSize=128M
ValueCacheSize=128M
Timeout=30 # 如果使用自定义的脚本方式监控, 对应的zabbix_agent.conf也需要修改
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=10000
获取下载地址:
下载地址:http://www.zabbix.com/download.php
修改zabbix_agentd.win.conf配置文件, 其中LogFile是日志存放的目录, Server为zabbix的服务器IP, ServerActive为开启主动模式并配置zabbix服务器IP,Hostname为本机客户端的主机名.
LogFile=c:\\Zabbix\\zabbix_agentd.log
Server=10.1.1.2
ServerActive=10.1.1.2:10051
Hostname= Windows Host
使用zabbix_agentd.exe安装Zbbix agent,-i参数为安装, -c参数为执行配置文件的目录, -s为启动agent服务,
C:\\Zabbix\\bin\\win64>zabbix_agentd.exe -i -c "C:\\Zabbix\\conf\\zabbix_agentd.win.conf"
C:\\Zabbix\\bin\\win64>zabbix_agentd.exe -s
关于命令的其他语法, 使用zabbix_agentd.exe --help查看.
由于在3.0版本之后, 官方没有发布AIX Agent对应的二进制文件, 这里使用源码进行安装
shell> rpm -ivh libgcc-4.8.5-1.aix6.1.ppc.rpm
shell> rpm -ivh libstdc++-4.8.3-1.aix6.1.ppc.rpm
shell> rpm -ivh libstdc++-devel-4.8.3-1.aix6.1.ppc.rpm
shell> rpm -ivh gmp-6.0.0a-1.aix5.1.ppc.rpm
shell> rpm -ivh mpfr-3.1.2-1.aix5.1.ppc.rpm
shell> rpm -ivh libmpc-1.0.2-1.aix5.1.ppc.rpm
shell> rpm -ivh gcc-4.8.5-1.aix6.1.ppc.rpm --nodeps
shell> rpm -ivh gcc-cpp-4.8.5-1.aix6.1.ppc.rpm --nodeps
shell> rpm -ivh gcc-gfortran-4.8.5-1.aix6.1.ppc.rpm --nodeps
shell> rpm -ivh libstdcplusplus-4.8.5-1.aix6.1.ppc.rpm
shell> rpm -ivh libstdcplusplus-devel-4.8.5-1.aix6.1.ppc.rpm --nodeps
shell> gunzip -c zabbix-3.0.7.tar.gz |tar -xvf -
shell> cd zabbix-3.0.7
shell> ./configure --enable-agent
shell> make && make install
如果觉得我的文章对您有用,请点赞。您的支持将鼓励我继续创作!
赞17
添加新评论5 条评论
2020-08-24 08:46
2018-07-13 15:32
2018-01-17 14:47
2018-01-08 09:55
2018-01-05 15:38