zabbix之源码安装

#:官网地址
https://www.zabbix.com/documentation/4.0/zh/manual/installation/install

#:解压并创建用户

root@ubuntu:/usr/local/src# tar xf zabbix-4.0.12.tar.gz
root@ubuntu:/usr/local/src/zabbix-4.0.12# groupadd zabbix
root@ubuntu:/var/www/html/zabbix/conf# useradd -g zabbix zabbix

#安装依赖环境 root@ubuntu:
/usr/local/src/zabbix-4.0.12# apt-get install 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-1 libtiff5 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 snmpd ssl-cert ttf-dejavu-core libmysqlclient-dev libxml2-dev libxml2 snmp libsnmp-dev libevent-dev openjdk-8-jdk curl libcurl4-openssl-dev #:编译安装 root@ubuntu:/usr/local/src/zabbix-4.0.12# ./configure --prefix=/apps/zabbix_server --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2 --enable-java root@ubuntu:/usr/local/src/zabbix-4.0.12# make && make install
#:在另外一台安装一个数据库

root@ubuntu:~# apt install mysql-server -y

#:修改配置文件

create database zabbix character set utf8 collate utf8_bin;
bind-address            = 0.0.0.0

#;启动服务

root@ubuntu:~# systemctl start mysql

#:创建用户,并授权

mysql> create database zabbix_server character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)

mysql> grant all privileges on zabbix.* to 'zabbix'@'192.168.7.%' identified by 'centos';
Query OK, 0 rows affected, 1 warning (0.01 sec)
#:在zabbix上修改连接配置文件

root@ubuntu:/apps/zabbix_server# vim /apps/zabbix_server/etc/zabbix_server.conf

DBHost=192.168.7.106
DBName=zabbix_server
DBUser=zabbix
DBPassword=centos
DBPort=3306

#;安装MySQL客户端

root@ubuntu:/usr/local/src/zabbix-4.0.12/database/mysql# apt install mysql-client-core-5.7 -y


#:导入MySQL数据库(注意有先后顺序)

root@ubuntu:/usr/local/src/zabbix-4.0.12/database/mysql# cd /usr/local/src/zabbix-4.0.12/database/mysql

root@ubuntu:/usr/local/src/zabbix-4.0.12/database/mysql# mysql -uzabbix -pcentos -h192.168.7.106 zabbix_server < schema.sql
root@ubuntu:/usr/local/src/zabbix-4.0.12/database/mysql# mysql -uzabbix -pcentos -h192.168.7.106 zabbix_server < images.sql
root@ubuntu:/usr/local/src/zabbix-4.0.12/database/mysql# mysql -uzabbix -pcentos -h192.168.7.106 zabbix_server < data.sql

#:拷贝网页文件

root@ubuntu:/usr/local/src/zabbix-4.0.12/frontends/php# mkdir /var/www/html/zabbix
root@ubuntu:/usr/local/src/zabbix-4.0.12/frontends/php# cd /usr/local/src/zabbix-4.0.12/frontends/php/
root@ubuntu:/usr/local/src/zabbix-4.0.12/frontends/php# cp -a . /var/www/html/zabbix/

#;找一台空闲电脑拷贝zabbix-server的启动文件到本机
#:修改启动文件
root@ubuntu:/etc/php/7.2/apache2# cat /lib/systemd/system/zabbix-server.service 
[Unit]
Description=Zabbix Server (MySQL/MariaDB)
Documentation=man:zabbix_server
After=network.target mysql.service

[Service]
Type=simple
User=zabbix
Group=zabbix
ExecStart=/usr/sbin/zabbix_server --foreground
ExecReload=/usr/sbin/zabbix_server -R config_cache_reload
Restart=on-abnormal

[Install]
WantedBy=multi-user.target

root@ubuntu:/etc/php/7.2/apache2# ln -sv /apps/zabbix_server/sbin/zabbix_server /usr/sbin/

#:启动服务

root@ubuntu:/etc/php/7.2/apache2# systemctl start zabbix-server
root@ubuntu:/etc/php/7.2/apache2# systemctl restart apache2

#:在页面访问,根据提示修改php

root@ubuntu:/etc/php/7.2/apache2# vim /etc/php/7.2/apache2/php.ini

#:修改好后重启Apache

root@ubuntu:/etc/php/7.2/apache2# systemctl restart apache2

#:安装的时候注意最后时候下载PHP那个文件
#;创建zabbix-agint(先在一个闲置主机将apt安装的agent脚本拷到本机)

root@ubuntu:/apps/zabbix_server/sbin# cat /lib/systemd/system/zabbix-agent.service 
[Unit]
Description=Zabbix Agent
Documentation=man:zabbix_agentd
After=network.target

[Service]
Type=simple
User=zabbix
Group=zabbix
ExecStart=/usr/sbin/zabbix_agentd --foreground
Restart=on-abnormal

[Install]
WantedBy=multi-user.target

root@ubuntu:/apps/zabbix_server/sbin# ln -sv /apps/zabbix_server/sbin/zabbix_agentd /usr/sbin

#:启动服务

root@ubuntu:/apps/zabbix_server/sbin# systemctl start zabbix-agent

 

posted @ 2019-09-20 17:16  Linus小跟班  阅读(260)  评论(0编辑  收藏  举报