Zabbix源码安装部署
zabbix源码部署安装
参考文档:https://www.zabbix.com/documentation/4.0/manual/installation/install
https://www.zabbix.com/documentation/4.0/manual/appendix/install/db_scripts
这里以zabbix-4.0.1为例,环境为CentOS 7
源码包下载地址:https://www.zabbix.com/download_sources
源码包下载
cd /usr/local/src/
wget https://superb-dca2.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/4.0.1/zabbix-4.0.1.tar.gz
tar xf zabbix-4.0.1.tar.gz
创建zabbix用户
groupadd zabbix
useradd -g zabbix zabbix
数据库操作
安装zabbix server之前,需要先准备数据库,这里以Mysql数据库为例进行安装,其它数据库请参考https://www.zabbix.com/documentation/4.0/manual/appendix/install/db_scripts
mysql -uroot -p<password>
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by '<password>';
mysql> quit;
cd /usr/local/src/zabbix-4.0.1/database/mysql
mysql -uzabbix -p<password> zabbix < schema.sql
# 如果是安装zabbix-proxy,不需要导入下面的数据
mysql -uzabbix -p<password> zabbix < images.sql
mysql -uzabbix -p<password> zabbix < data.sql
安装
Server端
yum -y install libevent-devel libxml2-devel curl-devel net-snmp-devel mysql-devel libssh2-devel
#自Zabbix 3.0.0起,支持SMTP认证需要具有cURL 7.20.0或更高版本的--with-libcurl配置选项。 自Zabbix 2.2.0起支持虚拟机监视需要--with-libcurl和--with-libxml2配置选项
cd /usr/local/src/zabbix-4.0.1
./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --with-ssh2 --with-net-snmp --with-libcurl --with-libxml2
make install
Agent端
cd /usr/local/src
tar xf zabbix-4.0.1.tar.gz
./configure --prefix=/usr/local/zabbix_agent --enable-agent
make install
修改配置文件
#server配置文件
egrep -v "^#|^$" /usr/local/zabbix/etc/zabbix_server.conf
LogFile=/tmp/zabbix_server.log
PidFile=/tmp/zabbix_server.pid
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=your_password #修改密码
DBSocket=/var/lib/mysql/mysql.sock
DBPort=3306
Timeout=4
LogSlowQueries=3000
#agent配置文件
egrep -v "^#|^$" /usr/local/zabbix/etc/zabbix_agentd.conf
LogFile=/tmp/zabbix_agentd.log
Server=127.0.0.1
ServerActive=127.0.0.1 #主动通知
Hostname=Zabbix server #各个agent不能相同
启动
/usr/local/zabbix/sbin/zabbix_server
/usr/local/zabbix/sbin/zabbix_agentd
Web配置
安装Nginx和PHP(此处我是使用yum安装的PHP,php-fpm)
yum -y install php-bcmath php-gd php-xmlwriter php-mbstring php-mysql
systemctl restart php-fpm
PHP需要配置
Pre-requisite | Minimum value | Description |
---|---|---|
PHP version | 5.4.0 | |
PHP memory_limit option | 128MB | In php.ini: memory_limit = 128M |
PHP post_max_size option | 16MB | In php.ini: post_max_size = 16M |
PHP upload_max_filesize option | 2MB | In php.ini: upload_max_filesize = 2M |
PHP max_execution_time option | 300 seconds (values 0 and -1 are allowed) | In php.ini: max_execution_time = 300 |
PHP max_input_time option | 300 seconds (values 0 and -1 are allowed) | In php.ini: max_input_time = 300 |
PHP session.auto_start option | must be disabled | In php.ini: session.auto_start = 0 |
Database support | One of: MySQL, Oracle, PostgreSQL, IBM DB2 | One of the following modules must be installed: mysql, oci8, pgsql, ibm_db2 |
bcmath | php-bcmath | |
mbstring | php-mbstring | |
PHP mbstring.func_overload option | must be disabled | In php.ini: mbstring.func_overload = 0 |
PHP always_populate_raw_post_data option | must be disabled | Required only for PHP versions 5.6.0 or newer. In php.ini: always_populate_raw_post_data = -1 |
sockets | php-net-socket. Required for user script support. | |
gd | 2.0 or higher | php-gd. PHP GD extension must support PNG images (--with-png-dir), JPEG (--with-jpeg-dir) images and FreeType 2 (--with-freetype-dir). |
libxml | 2.6.15 | php-xml or php5-dom |
xmlwriter | php-xmlwriter | |
xmlreader | php-xmlreader | |
ctype | php-ctype | |
session | php-session | |
gettext | php-gettext Since Zabbix 2.2.1, the PHP gettext extension is not a mandatory requirement for installing Zabbix. If gettext is not installed, the frontend will work as usual, however, the translations will not be available. |