centos 8 源码安装zabbix

安装zabbix

  • 下载zabbix

https://www.zabbix.com/download_sources

image-20210513181515258

  • 用xftp传到本地(略)
  • 安装依赖
[root@z1 ~]# yum install -y libxml2 libxml2-devel  net-snmp-devel libevent-devel
  • 创建用户和组
[root@z1 zabbix]# groupadd -r zabbix
[root@z1 zabbix]# useradd -r -g zabbix -M -s /sbin/nologin zabbix
  • 编译安装zabbix
[root@z1 ~]# ls
mysql-5.7.33-el7-x86_64.tar.gz  proxychains-ng  zabbix-5.2.6.tar.gz
[root@z1 ~]# tar xf zabbix-5.2.6.tar.gz -C /usr/local/
[root@z1 ~]# cd /usr/local/
[root@z1 local]# ls
apache  apr-util  etc    include  lib64    mysql     sbin   src
apr     bin       games  lib      libexec  password  share  zabbix-5.2.6
[root@z1 local]# mv zabbix-5.2.6/ zabbix
[root@z1 local]# cd zabbix/
[root@z1 zabbix]# ./configure --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2
[root@z1 zabbix]# make install
  • 数据库配置
[root@z1 zabbix]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.33 MySQL Community Server (GPL)

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create database zabbix character set utf8 collate utf8_bin; #
Query OK, 1 row affected (0.01 sec)

mysql>  grant all privileges on zabbix.* to zabbix@192.168.80.21 identified by 'zabbbix123!'; #一定要写该主机的ip
mysql>  grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix123!';
Query OK, 0 rows affected, 1 warning (0.01 sec)

mysql> flush privileges; #刷新权限
Query OK, 0 rows affected (0.00 sec)
[root@z1 zabbix]# cd /usr/local/zabbix/database/mysql/
[root@z1 mysql]# mysql -uzabbix -pzabbix123! zabbix < schema.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@z1 mysql]# mysql -uzabbix -pzabbix123! zabbix < images.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@z1 mysql]# mysql -uzabbix -pzabbix123! zabbix < data.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@z1 mysql]# vim /usr/local/etc/zabbix_server.conf
118  DBPassword=zabbix123!                #118行改成这样

  • apche配置
[root@z1 mysql]# mkdir /usr/local/apache/htdocs/zabbix
[root@z1 zabbix]# cd /usr/local/zabbix
[root@z1 zabbix]# ls
aclocal.m4  compile        config.sub    depcomp     Makefile     missing  ui
AUTHORS     conf           configure     include     Makefile.am  NEWS
bin         config.guess   configure.ac  INSTALL     Makefile.in  README
build       config.log     COPYING       install-sh  man          sass
ChangeLog   config.status  database      m4          misc         src
[root@z1 zabbix]# cp -a ui /usr/local/apache/htdocs/zabbix/
[root@z1 zabbix]# cd /usr/local/apache/htdocs/zabbix/
[root@z1 zabbix]# ls
ui
[root@z1 zabbix]# mv ui/* .
[root@z1 zabbix]# ls
actionconf.php       host_discovery.php           overview.php
api_jsonrpc.php      hostgroups.php               queue.php
app                  hostinventoriesoverview.php  report2.php
assets               hostinventories.php          report4.php
audio                host_prototypes.php          robots.txt
auditacts.php        hosts.php                    screenconf.php
browserwarning.php   httpconf.php                 screenedit.php
chart2.php           httpdetails.php              screen.import.php
chart3.php           image.php                    screens.php
chart4.php           imgstore.php                 services.php
chart5.php           include                      setup.php
chart6.php           index_http.php               slideconf.php
chart7.php           index.php                    slides.php
chart.php            index_sso.php                srv_status.php
composer.json        items.php                    sysmap.php
composer.lock        js                           sysmaps.php
conf                 jsLoader.php                 templates.php
conf.import.php      jsrpc.php                    toptriggers.php
correlation.php      local                        tr_events.php
discoveryconf.php    locale                       trigger_prototypes.php
disc_prototypes.php  maintenance.php              triggers.php
favicon.ico          map.import.php               ui
graphs.php           map.php                      vendor
history.php          modules                      zabbix.php
[root@z1 zabbix]# rm -rf ui
[root@z1 zabbix]# vim /etc/httpd24/extra/vhosts.conf
<VirtualHost *:80>
    DocumentRoot "/usr/local/apache/htdocs/zabbix" #路径一定要对
    ServerName www.zhanglei.host
    ProxyRequests Off    ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/usr/local/apache/htdocs/zabbix/$1 #路径一定要对
    <Directory "/usr/local/apache/htdocs/zabbix"> #路径一定要对
        Options none
        AllowOverride none
        Require all granted
    </Directory>
</VirtualHost>
[root@z1 zabbix]# chmod 777 /usr/local/apache/htdocs/zabbix/conf
  • php配置
[root@z1 zabbix]# vim /etc/httpd24/extra/vhosts.conf
[root@z1 zabbix]# chmod 777 /usr/local/apache/htdocs/zabbix/conf
[root@z1 zabbix]# sed -ri 's/(post_max_size =).*/\1 16M/g' /etc/php.ini
[root@z1 zabbix]# sed -ri 's/(max_execution_time =).*/\1 300/g' /etc/php.ini
[root@z1 zabbix]# sed -ri 's/(max_input_time =).*/\1 300/g' /etc/php.ini
[root@z1 zabbix]# sed -i '/;date.timezone/a date.timezone = Asia/Shanghai' /etc/php.ini
  • 重启所有服务
[root@z1 zabbix]# systemctl restart php-fpm.service 
[root@z1 zabbix]# apachectl restart
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.80.21. Set the 'ServerName' directive globally to suppress this message
[root@z1 zabbix]# service mysqld restart
Shutting down MySQL.. SUCCESS! 
Starting MySQL. SUCCESS! 
[root@z1 zabbix]# 
  • 启动zabbix
[root@z1 zabbix]# zabbix_server
[root@z1 zabbix]# zabbix_agentd
[root@z1 zabbix]# ss -antl
State    Recv-Q   Send-Q     Local Address:Port      Peer Address:Port   Process   
LISTEN   0        128              0.0.0.0:111            0.0.0.0:*                
LISTEN   0        32         192.168.122.1:53             0.0.0.0:*                
LISTEN   0        128              0.0.0.0:22             0.0.0.0:*                
LISTEN   0        5              127.0.0.1:631            0.0.0.0:*                
LISTEN   0        128              0.0.0.0:10050          0.0.0.0:*  #服务端口            
LISTEN   0        128              0.0.0.0:10051          0.0.0.0:*  #agentd端口           
LISTEN   0        80                     *:3306                 *:*                
LISTEN   0        128                 [::]:111               [::]:*                
LISTEN   0        128                    *:80                   *:*                
LISTEN   0        128                 [::]:22                [::]:*                
LISTEN   0        5                  [::1]:631               [::]:*                
LISTEN   0        128                    *:9000                 *:*                
[root@z1 zabbix]# 

  • 关闭防火墙
[root@z1 zabbix]# setenforce 0
setenforce: SELinux is disabled
[root@z1 zabbix]# systemctl restart firewalld

image-20210513184859779

image-20210513184911960

image-20210513185003208

image-20210513185027121

image-20210513185550786

image-20210513185610229

image-20210513185626759

image-20210513185704685

image-20210513185721111

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值