zabbix4.0原始碼包安裝
阿新 • • 發佈:2018-12-26
-
原始碼包安裝的好處在於配置檔案集中管理易於維護,缺點是對新手不是很友好,需要安裝許多依賴的軟體包,對於剛入門的朋友建議使用rpm方式進行安裝
一、配置mysql和lamp環境
1.配置資料庫yum源
[[email protected] 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
[ [email protected] zabbix]# yum -y install mysql-server
2.啟動資料庫並修改資料庫密碼
[[email protected] zabbix]# systemctl start mysqld
[[email protected] zabbix]# grep password /var/log/mysqld.log
2018-12-17T02:05:16.600100Z 1 [Note] A temporary password is generated for [email protected]: gYyHSdQFN7+r
[ [email protected] 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資料庫使用者和庫並授權
[ [email protected] zabbix]# mysql -u root -p'Abcd123.'
mysql> create user [email protected]'192.168.174.%' identified by 'Abcd123.';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on zabbix.* to [email protected]'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
[[email protected] zabbix]# yum -y install php php-fpm php-mysql php-devel php-mbstring php-bcmath httpd
[[email protected] etc]# cat /etc/httpd/conf.d/zabbix.conf
<VirtualHost zabbix-server:80>
ServerName 192.168.174.140
DocumentRoot "/var/www/html/zabbix/php"
</VirtualHost>
[[email protected] etc]# cp /zabbix/zabbix-4.0.2/frontends/php/ /var/www/html/zabbix/ -r
[[email protected] etc]# chown -R apache. /var/www/html/zabbix
[[email protected] etc]# systemctl start php-fpm
[[email protected] etc]# systemctl start httpd
二、安裝zabbix
1.安裝編譯環境
[[email protected] zabbix-4.0.2]# yum -y install gcc-c++ mysql-devel net-snmp-devel libevent-devel libcurl-devel
2.下載zabbix4.0進行原始碼編譯
[[email protected] zabbix]# ls
zabbix-4.0.2.tar.gz
[[email protected] zabbix]# tar -xf zabbix-4.0.2.tar.gz
[[email protected] zabbix]# ls
zabbix-4.0.2 zabbix-4.0.2.tar.gz
[[email protected] zabbix]# cd zabbix-4.0.2
[[email protected] 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的編譯
[[email protected] 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
[[email protected] zabbix-4.0.2]# make && make install
4.匯入sql
[[email protected] mysql]# cd /zabbix/zabbix-4.0.2/database/mysql/
[[email protected] mysql]# ls
data.sql images.sql Makefile Makefile.am Makefile.in schema.sql
[[email protected] mysql]# mysql -h 192.168.174.140 -uzabbix -p'Abcd123.' zabbix < schema.sql
[[email protected] mysql]# mysql -h 192.168.174.140 -uzabbix -p'Abcd123.' zabbix < images.sql
[[email protected] mysql]# mysql -h 192.168.174.140 -uzabbix -p'Abcd123.' zabbix < data.sql
5.建立zabbix使用者和組
[[email protected] zabbix-4.0.2]# groupadd zabbix
[[email protected] zabbix-4.0.2]# useradd -g zabbix zabbix
[[email protected] etc]# chown -R zabbix. /opt/zabbix*
6.修改zabbix-server配置
[[email protected] 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
[[email protected] 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
[[email protected] sbin]# /opt/zabbix-4.0/sbin/zabbix_server
[[email protected] sbin]# /opt/zabbix-4.0/sbin/zabbix_agent
1.編譯安裝
[[email protected] zabbix-4.0.2]# yum -y install gcc-c++ net-snmp-devel libevent-devel libcurl-devel
[[email protected] zabbix-4.0.2]# ./configure --prefix=/opt/zabbix-agent/ --enable-agent --with-net-snmp --with-libcurl --with-libxml2l
[[email protected] zabbix-4.0.2]# make && make install
2.修改配置
[[email protected] 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.配置使用者
[[email protected] sbin]# groupadd zabbix
[[email protected] sbin]# useradd -g zabbix zabbix
3.啟動agent
[[email protected] sbin]# cd /opt/zabbix-agent/sbin/
[[email protected] sbin]# ./zabbix_agentd
zabbix-proxy原始碼安裝
1.編譯安裝
[[email protected] zabbix-4.0.2]# yum -y install gcc-c++ mysql-devel net-snmp-devel libevent-devel libcurl-devel
[[email protected] zabbix-4.0.2]# ./configure --prefix=/opt/zabbix-proxy/ --enable-proxy --with-mysql=/usr/bin/mysql_config --with-net-snmp --with-libcurl --with-libxml2l
[[email protected] zabbix-4.0.2]# make && make install
2.修改配置
[[email protected] 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檔案中的引數和下列表格中的一致,缺失的依賴包也參照下列表格中的進行安裝