Zabbix 最新版 5.0 LTS 版本安装
zabbix 5.0 版本于 5 月 11 日正式发布,是最新的 LTS(长期支持)版本,5.0 带来很多功能和特性,后面会陆续推出文章介绍,下面主要介绍下 5.0 版本的安装。
环境要求
5.0 版本对基础环境的要求有大的变化,最大的就是对 php 版本的要求,最低要求 7.2.0 版本,对 php 扩展组件版本也有要求,详见官网文档https://www.zabbix.com/documentation/current/manual/installation/requirements
zabbix 5.0 版本于 5 月 11 日正式发布,是最新的 LTS(长期支持)版本,5.0 带来很多功能和特性,后面会陆续推出文章介绍,下面主要介绍下 5.0 版本的安装。
YUM 安装
基本环境
操作系统 | 安装方式 |
---|---|
CentOS Linux release 7.8.2003 (Core) x86_64 | 最小化安装 |
1,安装好操作系统后,关闭防火墙和 selinux 并重启
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
systemctl disable --now firewalld
reboot
2,下载 Zabbix 官网最新源码:https://www.zabbix.com/cn/download_sources
3,yum scl 安装 Apache httpd php7.2 集成系统
yum install centos-release-scl-rh -y
# yum search php
yum install rh-php72 -y
yum install rh-php72 rh-php72-php rh-php72-php-gd rh-php72-php-mbstring rh-php72-php-ldap rh-php72-php-bcmath rh-php72-php-intl rh-php72-php-pecl-apcu -y
yum install rh-php72-php-mysqlnd -y
scl -l
scl enable rh-php72 "php -v"
scl enable rh-php72 bash
php -v
php -myum install -y httpd
systemctl start httpd
systemctl enabled httpdln -s /opt/rh/httpd24/root/etc/httpd/conf.d/rh-php72-php.conf /etc/httpd/conf.d/
ln -s /opt/rh/httpd24/root/etc/httpd/conf.modules.d/15-rh-php72-php.conf /etc/httpd/conf.modules.d/
ln -s /opt/rh/httpd24/root/etc/httpd/modules/librh-php72-php7.so /etc/httpd/modules/systemctl restart httpd
4,安装编译zabbix 5.2 源码
tar -xzvf zabbix-5.2.1.tar.gz
cd zabbix-5.2.1/yum -y install gcc gcc-c++ curl curl-devel net-snmp net-snmp-devel perl-DBI libxml2-devel libevent-devel pcregroupadd zabbix
useradd -g zabbix zabbix
usermod -s /sbin/nologin zabbix./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2
make&&make install
chown zabbix:zabbix /usr/local/zabbix/ -Rln -s /usr/local/zabbix/sbin/zabbix_* /usr/local/sbin/
cd zabbix-5.2.1/
cp misc/init.d/tru64/{zabbix_agentd,zabbix_server} /etc/init.d/;chmod o+x /etc/init.d/zabbix_*cd zabbix-5.2.1/
cp -a ui/* /var/www/html/
chown -R apache:apache /var/www/html/cd /usr/local/zabbix/etc/
cp zabbix_server.conf zabbix_server.conf.bak修改zabbix_server.conf配置文件中代码设置为如下:
########################################
LogFile=/tmp/zabbix_server.log
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=123456
########################################修改/etc/opt/rh/rh-php72/php.ini
########################################
PHP option "post_max_size" 8M 16M Fail
PHP option "max_execution_time" 30 300 Fail
PHP option "max_input_time" 60 300 Fail
pdo_mysql.default_socket= /tmp/mysql.sock
mysqli.default_socket = /tmp/mysql.sock
########################################chmod -R 777 /var/www/html/conf//etc/init.d/zabbix_server restart
systemctl restart httpd
5,安装mysql数据库
yum -y install wget gcc gcc-c++ ncurses ncurses-devel cmake numactl.x86_64 libaio
wget http://mirrors.ustc.edu.cn/mysql-ftp/Downloads/MySQL-5.7/mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz
tar -zxvf mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
mv /usr/local/mysql-5.7.24-linux-glibc2.12-x86_64/ /usr/local/mysql
cd /usr/local/mysql/
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
cat >/etc/my.cnf <<EOF
[client]
port=3306
socket=/tmp/mysql.sock
[mysqld]
port=3306
socket=/tmp/mysql.sock
skip-external-locking
key_buffer_size = 38M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
basedir=/usr/local/mysql
datadir=/var/lib/mysql
bind-address=0.0.0.0
innodb_flush_log_at_trx_commit=1
sync_binlog=1
log-bin=/var/lib/mysql/mysql_logbin
log-error=/var/log/mariadb
slow_query_log =1
slow_query_log_file=/tmp/mysql_slow.log
server-id=1
symbolic-links=0
[mysqld_safe]
pid-file=/var/run/mariadb/mariadb.pid
EOFuseradd mysql
mkdir -p /var/lib/mysql
chown mysql:mysql /var/lib/mysql
mkdir -p /var/log/mariadb
chown mysql:mysql /var/log/mariadb/
mkdir -p /var/run/mariadb
chown mysql:mysql /var/run/mariadb/
touch /var/run/mariadb/mariadb.pid
cat >> /etc/profile << EOF
export PATH=\$PATH:/usr/local/mysql/bin:/usr/local/mysql/lib
EOF
source /etc/profile
chmod -R 777 /var/log
mysqld --defaults-file=/etc/my.cnf --user=mysql --initialize-insecure
/etc/init.d/mysql startmysql -u root -p
update mysql.user set authentication_string=password('123456') where user='root';
flush privileges;####################################################################################
mysql -u root -p
#########################
create database zabbix character set utf8 collate utf8_bin;
grant all on zabbix.* to zabbix@localhost identified by '123456';
flush privileges;
use zabbix;
source /root/zabbix-5.2.1/database/mysql/schema.sql
source /root/zabbix-5.2.1/database/mysql/images.sql
source /root/zabbix-5.2.1/database/mysql/data.sql
flush privileges;
#########################ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock
访问:http://118.89.23.220/ , 切记 数据库连接host填 “127.0.0.1”
使用浏览器访问 http://ip 即可访问 zabbix 的 web 页面
日志位置:/var/log/zabbix/zabbix_server.log
更多资讯或疑问内容请关注 微信公众号 “让梦飞起来” 或添加小编微信, 后台回复 “Python” ,领取更多资料哦