zabbix编译安装
环境:Ubuntu 18.04.1安装参考文档
https://www.zabbix.com/documentation/4.0/zh/manual/installation/install
包下载
https://www.zabbix.com/cn/manuals
https://www.zabbix.com/cn/download_sources#tab:40LTS
安装
ip
安装
192.168.47.102
zabbix-server
192.168.47.103
mariadb
此次安装版本:zabbix-4.0.35.tar.gz
对于 Zabbix server 和 proxy 守护进程以及 Zabbix 前端,必须需要一个数据库。
但是 Zabbix agent 并不需要mariadb安装
apt-get install mariadb-server-y
MariaDB [(none)]> create database zabbix_server character set utf8 collate utf8_bin;
MariaDB [(none)]> grant all privileges on zabbix_server.* to zabbix@"192.168.47.%" identified by '123456';
修改配置文件
root@ubuntu:~# vim/etc/mysql/mariadb.conf.d/50-server.cnf
bind-address = 0.0.0.0
root@ubuntu:~# systemctl restart mariadb
测试
root@ubuntu:~# apt-get install mariadb-client -y
root@ubuntu:~# mysql -uzabbix -p123456 -h192.168.47.103zabbix-server安装
#1.安装依赖包
apt-get update
apt-getinstall apache2 apache2-bin apache2-data apache2-utils fontconfig-config \
fonts-dejavu-core fping libapache2-mod-php libapache2-mod-php7.2 libapr1 libaprutil1 \
libaprutil1-dbd-sqlite3 libaprutil1-ldap libfontconfig1 libgd3 libiksemel3 \
libjbig0 libjpeg-turbo8 libjpeg8 liblua5.2-0 libodbc1 libopenipmi0 libsensors4 \
libsnmp-base libsnmp30 libsodium23 libssh2-1libtiff5 libwebp6 libxpm4 php-bcmath \
php-common php-gd php-ldap php-mbstring php-mysql php-xml php7.2-bcmath php7.2-cli \
php7.2-common php7.2-gd php7.2-json php7.2-ldap php7.2-mbstring php7.2-mysql \
php7.2-opcache php7.2-readline php7.2-xml snmpdssl-cert ttf-dejavu-core \
libmysqlclient-devlibxml2-devlibxml2 snmplibsnmp-dev libevent-dev\
openjdk-8-jdk curl libcurl4-openssl-dev-y
#2.编译安装
root@ubuntu:~# cd zabbix-4.0.35/
root@ubuntu:~/zabbix-4.0.35# groupadd zabbix && useradd -g zabbix zabbix
root@ubuntu:~/zabbix-4.0.35# ./configure --prefix=/usr/local/zabbix \
--enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl \
--with-libxml2 --enable-java
root@ubuntu:~/zabbix-4.0.35# make
root@ubuntu:~/zabbix-4.0.35# make install
#3.下载源
wget https://repo.zabbix.com/zabbix/4.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_4.0-2+bionic_all.deb
dpkg -i zabbix-release_4.0-2+bionic_all.deb
cat/etc/apt/sources.list.d/zabbix.list
-------------------------------------------------------------------------------
deb http://repo.zabbix.com/zabbix/4.0/ubuntu bionic main
deb-src http://repo.zabbix.com/zabbix/4.0/ubuntu bionic main
-------------------------------------------------------------------------------
apt update
#4.导入数据库
root@ubuntu:~/zabbix-4.0.35/database/mysql# ll
total 6196
drwxr-xr-x 2 taotao 4096 Dec 28 09:37 ./
drwxr-xr-x 8 taotao 4096 Dec 28 09:37 ../
-rw-r--r-- 1 taotao4175260 Oct 18 16:00 data.sql
-rw-r--r-- 1 taotao1978341 Sep6 21:44 images.sql
-rw-r--r-- 1 root root 15625 Dec 28 09:37 Makefile
-rw-r--r-- 1 taotao 392 Oct 18 16:00 Makefile.am
-rw-r--r-- 1 taotao 15888 Oct 18 16:00 Makefile.in
-rw-r--r-- 1 taotao 140265 Oct 18 16:00 schema.sql
mysql -uzabbix -p123456 -h192.168.47.103 zabbix_server < schema.sql
# stop here if you are creating database for Zabbix proxy
mysql -uzabbix -p123456 -h192.168.47.103 zabbix_server < images.sql
mysql -uzabbix -p123456 -h192.168.47.103 zabbix_server < data.sql
#5.修改配置文件
root@ubuntu:~/zabbix-4.0.35/database/mysql# vim /usr/local/zabbix/etc/zabbix_server.conf
DBPassword=123456
DBHost=192.168.47.103
DBName=zabbix_server
#6.运行
root@ubuntu:~/zabbix-4.0.35# chown -R zabbix.zabbix /usr/local/zabbix/
/usr/local/zabbix/sbin/zabbix_server -c/usr/local/zabbix/etc/zabbix_server.conf
端口:10051
root@ubuntu:~/zabbix-4.0.35# rm -f/var/www/html/index.html
root@ubuntu:~/zabbix-4.0.35# mkdir /var/www/html/zabbix
root@ubuntu:~/zabbix-4.0.35# cp -a frontends/php/*/var/www/html/zabbix/
root@ubuntu:~/zabbix-4.0.35# chownzabbix.zabbix/var/www/html/zabbix/* -R
root@ubuntu:~/zabbix-4.0.35# systemctl restart apache2
访问:192.168.47.102/zabbix/setup.php
解决报错
root@ubuntu:/var/www/html/zabbix# vim /etc/php/7.2/apache2/php.ini
-----------------------------------------------------------
post_max_size= 16M
max_execution_time= 300
max_input_time= 300
date.timezone= Asia/Shanghai
-----------------------------------------------------------
root@ubuntu:/var/www/html/zabbix# systemctl restart apache2
下载的zabbix.conf.php放在/var/www/html/zabbix/conf/目录下
root@ubuntu:/var/www/html/zabbix/conf# chown zabbix.zabbixzabbix.conf.php
直接刷新网页
zabbix-server启动脚本
#后台启动
/usr/local/zabbix/sbin/zabbix_agentd-c/usr/local/zabbix/etc/zabbix_agentd.conf
#关闭
ps -ef |grep zabbix_server
pkill zabbix_server
#启动脚本
cat > /lib/systemd/system/zabbix-server.service << EOF
Description=Zabbix Server
After=syslog.target
After=network.target
Environment="CONFFILE=/usr/local/zabbix/etc/zabbix_server.conf"
EnvironmentFile=-/etc/default/zabbix-server
Type=forking
Restart=on-failure
PIDFile=/usr/local/zabbix/run/zabbix_server.pid
KillMode=control-group
ExecStart=/usr/local/zabbix/sbin/zabbix_server -c $CONFFILE
ExecStop=/bin/kill -SIGTERM $MAINPID
RestartSec=10s
TimeoutSec=infinity
WantedBy=multi-user.target
EOF
mkdir /usr/local/zabbix/run
chown zabbix.zabbix/usr/local/zabbix/run
vim /usr/local/zabbix/etc/zabbix_server.conf
---------------------------------------------------------------------------
PidFile=/usr/local/zabbix/run/zabbix_server.pid #与启动脚本pid路径要一致
---------------------------------------------------------------------------
systemctl daemon-reload
systemctl start zabbix-server
#日志路径
LogFile=/tmp/zabbix_server.log中文显示及字体乱码修改
参考:https://blog.51cto.com/u_14814545/4849159
https://blog.51cto.com/u_14814545/4850174
页:
[1]