zabbix4.0源码包安装

  • 源码包安装的好处在于配置文件集中管理易于维护,缺点是对新手不是很友好,需要安装许多依赖的软件包,对于刚入门的朋友建议使用rpm方式进行安装,可参考zabbi4.0的安装和使用

  • zabbix官方网站

一、配置mysql和lamp环境

1.配置数据库yum源
[root@zabbix-server zabbix]# vim /etc/yum.repos.d/mysql-community.repo
[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
[root@zabbix-server zabbix]# yum -y install mysql-server

2.启动数据库并修改数据库密码
[root@zabbix-server zabbix]# systemctl start mysqld
[root@zabbix-server zabbix]#  grep password /var/log/mysqld.log
2018-12-17T02:05:16.600100Z 1 [Note] A temporary password is generated for root@localhost: gYyHSdQFN7+r
[root@zabbix-server zabbix]# mysqladmin -u root -p password 'Abcd123.'
Enter password:
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.

3.创建zabbix数据库用户和库并授权
[root@zabbix-server zabbix]# mysql -u root -p'Abcd123.'
mysql> create user zabbix@'192.168.174.%' identified by 'Abcd123.';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on zabbix.* to zabbix@'192.168.174.%' identified by 'Abcd123.';
Query OK, 0 rows affected, 1 warning (0.01 sec)
mysql> create database zabbix character set utf8 collate utf8_general_ci;
Query OK, 1 row affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

4.安装php和httpd
[root@zabbix-server zabbix]# yum -y install php php-fpm php-mysql php-devel php-mbstring php-bcmath httpd
[root@zabbix-server etc]# cat /etc/httpd/conf.d/zabbix.conf

        ServerName 192.168.174.140
        DocumentRoot "/var/www/html/zabbix/php"

[root@zabbix-server etc]# cp /zabbix/zabbix-4.0.2/frontends/php/ /var/www/html/zabbix/ -r
[root@zabbix-server etc]# chown -R apache. /var/www/html/zabbix
[root@zabbix-server etc]# systemctl start php-fpm
[root@zabbix-server etc]# systemctl start httpd

二、安装zabbix

1.安装编译环境
[root@zabbix-server zabbix-4.0.2]# yum -y install gcc-c++ mysql-devel net-snmp-devel libevent-devel libcurl-devel

2.下载zabbix4.0进行源码编译
[root@zabbix-server zabbix]# ls
zabbix-4.0.2.tar.gz
[root@zabbix-server zabbix]#  tar -xf zabbix-4.0.2.tar.gz
[root@zabbix-server zabbix]# ls
zabbix-4.0.2  zabbix-4.0.2.tar.gz
[root@zabbix-server zabbix]# cd zabbix-4.0.2
[root@zabbix-server zabbix-4.0.2]# ls
aclocal.m4  bin    ChangeLog  conf          config.sub  configure.ac  database  frontends  INSTALL     m4           Makefile.in  misc     NEWS    sass
AUTHORS     build  compile    config.guess  configure   COPYING       depcomp   include    install-sh  Makefile.am  man          missing  README  src

3.编译.这里开启了zabbix-server和agent的编译
[root@zabbix-server zabbix-4.0.2]# ./configure --prefix=/opt/zabbix-4.0/ --enable-server --enable-agent --with-mysql=/usr/bin/mysql_config --with-net-snmp --with-libcurl --with-libxml2l
[root@zabbix-server zabbix-4.0.2]# make && make install

4.导入sql
[root@zabbix-server mysql]# cd /zabbix/zabbix-4.0.2/database/mysql/
[root@zabbix-server mysql]# ls
data.sql  images.sql  Makefile  Makefile.am  Makefile.in  schema.sql
[root@zabbix-server mysql]# mysql -h 192.168.174.140 -uzabbix -p'Abcd123.' zabbix < schema.sql
[root@zabbix-server mysql]# mysql -h 192.168.174.140 -uzabbix -p'Abcd123.' zabbix < images.sql
[root@zabbix-server mysql]# mysql -h 192.168.174.140 -uzabbix -p'Abcd123.' zabbix < data.sql

5.创建zabbix用户和组
[root@zabbix-server zabbix-4.0.2]#  groupadd zabbix
[root@zabbix-server zabbix-4.0.2]# useradd -g zabbix zabbix
[root@zabbix-server etc]# chown -R zabbix. /opt/zabbix*

6.修改zabbix-server配置
[root@zabbix-server zabbix-4.0]# egrep -v '(^$|^#)' /opt/zabbix-4.0/etc/zabbix_server.conf
LogFile=/tmp/zabbix_server.log
DBHost=192.168.174.140
DBName=zabbix
DBUser=zabbix
DBPassword=Abcd123.
Timeout=4
LogSlowQueries=3000

7.配置zabbix-agent
[root@zabbix-server etc]# egrep -v '(^$|^#)' /opt/zabbix-4.0/etc/zabbix_agentd.conf
LogFile=/tmp/zabbix_agentd.log
Server=192.168.174.140
ServerActive=192.168.174.140
Hostname=192.168.174.140
Include=/opc/zabbix4.0/etc/zabbix_agentd.conf.d/*.conf

8.启动zabbix-server和agent
[root@zabbix-server sbin]# /opt/zabbix-4.0/sbin/zabbix_server
[root@zabbix-server sbin]# /opt/zabbix-4.0/sbin/zabbix_agent

zabbix-agent源码安装
1.编译安装
[root@zabbix-agent zabbix-4.0.2]# yum -y install gcc-c++ net-snmp-devel libevent-devel libcurl-devel
[root@zabbix-agent zabbix-4.0.2]# ./configure --prefix=/opt/zabbix-agent/ --enable-agent  --with-net-snmp --with-libcurl --with-libxml2l
[root@zabbix-agent zabbix-4.0.2]# make && make install
2.修改配置
[root@zabbix-agent opt]# egrep -v '(^#|^$)' zabbix-agent/etc/zabbix_agentd.conf
LogFile=/tmp/zabbix_agentd.log
Server=192.168.174.140
ServerActive=192.168.174.140
Hostname=192.168.174.141
3.配置用户
[root@zabbix-agent sbin]# groupadd zabbix
[root@zabbix-agent sbin]# useradd -g zabbix zabbix
3.启动agent
[root@zabbix-agent sbin]# cd /opt/zabbix-agent/sbin/
[root@zabbix-agent sbin]# ./zabbix_agentd

zabbix-proxy源码安装
1.编译安装
[root@zabbix-proxy zabbix-4.0.2]# yum -y install gcc-c++ mysql-devel net-snmp-devel libevent-devel libcurl-devel 
[root@zabbix-proxy zabbix-4.0.2]# ./configure --prefix=/opt/zabbix-proxy/ --enable-proxy --with-mysql=/usr/bin/mysql_config --with-net-snmp --with-libcurl --with-libxml2l
[root@zabbix-proxy zabbix-4.0.2]# make && make install
2.修改配置
[root@zabbix-proxy etc]# egrep -v '(^#|^$)' zabbix_proxy.conf
Server=192.168.174.140
Hostname=192.168.174.142
LogFile=/tmp/zabbix_proxy.log
DBHost=192.168.174.140
DBName=zabbix
DBUser=zabbix
DBPassword=Abcd123.
Timeout=4
LogSlowQueries=3000
  • 问题解决,在登录zabbix-web界面时会有php检查的错误,根据错误提示,修改/etc/php.ini文件中的参数和下列表格中的一致,缺失的依赖包也参照下列表格中的进行安装
    zabbix4.0源码包安装_第1张图片

你可能感兴趣的:(zabbix)