zabbix--源碼安裝部署zabbix3.2

zabbix運行在lamp環境或者lnmp環境都是能夠的,若是是新系統推薦使用lamp或者lnmp一鍵安裝包,

或者能夠向下面這種方式:

PHP安裝

源碼安裝

rpm -ivh php55w-common-5.5.38-1.w6.x86_64.rpm;

rpm -ivh php55w-cli-5.5.38-1.w6.x86_64.rpm;

rpm -ivh php55w-5.5.38-1.w6.x86_64.rpm;

rpm -ivh t1lib-5.1.2-6.el6_2.1.x86_64.rpm;

rpm -ivh php55w-gd-5.5.38-1.w6.x86_64.rpm;

rpm -ivh php55w-pdo-5.5.38-1.w6.x86_64.rpm;

rpm -ivh php55w-mysql-5.5.38-1.w6.x86_64.rpm;

rpm -ivh php55w-bcmath-5.5.38-1.w6.x86_64.rpm;

rpm -ivh php55w-mbstring-5.5.38-1.w6.x86_64.rpm;

rpm -ivh php55w-xml-5.5.38-1.w6.x86_64.rpm;

rpm -ivh php55w-ldap-5.5.30-1.w6.x86_64.rpm;

PS:遇到的問題,安裝第三個php rpm包時,提示:php

沒有安裝httpd-mmn = 20051115node

 

[root@monitor-server zabbix_file]# rpm -ivh php55w-5.5.38-1.w6.x86_64.rpm
warning: php55w-5.5.38-1.w6.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID cf4c4ff9: NOKEY
error: Failed dependencies:
    httpd-mmn = 20051115 is needed by php55w-5.5.38-1.w6.x86_64
    httpd is needed by php55w-5.5.38-1.w6.x86_64
[root@monitor-server zabbix_file]# 

 

這裏須要安裝httpd服務,但安裝httpd時,提示:mysql

[root@monitor-server zabbix_file]# rpm -ivh httpd-2.2.15-60.el6.centos.4.x86_64.rpm 
error: Failed dependencies:
    apr-util-ldap is needed by httpd-2.2.15-60.el6.centos.4.x86_64
    httpd-tools = 2.2.15-60.el6.centos.4 is needed by httpd-2.2.15-60.el6.centos.4.x86_64
    libapr-1.so.0()(64bit) is needed by httpd-2.2.15-60.el6.centos.4.x86_64
    libaprutil-1.so.0()(64bit) is needed by httpd-2.2.15-60.el6.centos.4.x86_64

由於機器不能訪問外網,我只上傳了個iso鏡像上去作本地yum源,也許改用源碼的方式安裝httpd會靠譜些,但編譯時提示:linux

configure: 
configure: Configuring Apache Portable Runtime library...
configure: 
checking for APR... yes
  setting CC to "gcc"
  setting CPP to "gcc -E"
  setting CFLAGS to " -g -O2 -pthread"
  setting CPPFLAGS to " -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE"
  setting LDFLAGS to " "
configure: 
configure: Configuring Apache Portable Runtime Utility library...
configure: 
checking for APR-util... no
configure: error: APR-util not found.  Please read the documentation.

仍是繞不過上面的那個坎,apr-utilc++

我參考了這篇博客:http://www.linuxidc.com/Linux/2012-06/62289.htmsql

今日編譯apache時出錯:

#./configure --prefix……檢查編輯環境時出現:

checking for APR... no
configure: error: APR not found .  Please read the documentation

解決辦法:

1.下載所需軟件包:

wget http://archive.apache.org/dist/apr/apr-1.4.5.tar.gz  
wget http://archive.apache.org/dist/apr/apr-util-1.3.12.tar.gz  
wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.10/pcre-8.10.zip   
2.編譯安裝:

yum remove apr-util-devel apr apr-util-mysql apr-docs apr-devel apr-util apr-util-docs 
具體步驟以下:

  a:解決apr not found問題>>>>>>

[root@xt test]# tar -zxf apr-1.4.5.tar.gz  
[root@xt test]# cd  apr-1.4.5  
[root@xt apr-1.4.5]# ./configure --prefix=/usr/local/apr  
[root@xt apr-1.4.5]# make && make install  
 
  b:解決APR-util not found問題>>>>

[root@xt test]# tar -zxf apr-util-1.3.12.tar.gz  
[root@xt test]# cd apr-util-1.3.12  
[root@xt apr-util-1.3.12]# ./configure --prefix=/usr/local/apr-util -with- apr=/usr/local/apr/bin/apr-1-config  
[root@xt apr-util-1.3.12]# make && make install 

  c:解決pcre問題>>>>>>>>>

[root@xt test]#unzip -o pcre-8.10.zip  
[root@xt test]#cd pcre-8.10  
[root@xt pcre-8.10]#./configure --prefix=/usr/local/pcre  
[root@xt pcre-8.10]#make && make install 
4.最後編譯Apache時加上:

--with-apr=/usr/local/apr \

--with-apr-util=/usr/local/apr-util/ \

 --with-pcre=/usr/local/pcre

成功編譯完成~

 

不過安裝apr和apr-util以前又遇到個坑:apache

編譯apr時出現這個報錯:configure: error: no acceptable C compiler found in $PATHvim

緣由是系統沒安裝gcc軟件套件,還好這個本地yum有(終於起做用了,好感動),直接yum install gcc就行。centos

安裝pcre時又遇到坑:此次提示g++    在make pcre的時候出現libtool: line 990: g++: command not found錯誤  解決方法:yum -y install gcc+ gcc-c++,都裝了。curl

繼續make pcre又報錯:.libs/pcrecpp.o: could not read symbols: Bad value     解決方法:./configure --disable-shared --with-pic   編譯時多加個參數

好了,繼續源碼安裝apache

./configure  --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre

make && make install

嗯,安裝完php,繼續!

 PS:發現一件尷尬的事情,apr相關的包,在本地yum源裏有。。

配置PHP參數:

[root@mid01 zabbix_file]# sed -i "s@;date.timezone =@date.timezone = Asia/Shanghai@g" /etc/php.ini
[root@mid01 zabbix_file]# sed -i "s@max_execution_time = 30@max_execution_time = 300@g" /etc/php.ini
[root@mid01 zabbix_file]# sed -i "s@post_max_size = 8M@post_max_size = 32M@g" /etc/php.ini
[root@mid01 zabbix_file]# sed -i "s@max_input_time = 60@max_input_time = 300@g" /etc/php.ini
[root@mid01 zabbix_file]# sed -i "s@memory_limit = 128M@memory_limit = 128M@g" /etc/php.ini
[root@mid01 zabbix_file]# sed -i "s@;mbstring.func_overload = 0@ambstring.func_overload = 2@g" /etc/php.ini
[root@mid01 zabbix_file]# sed -i "s@;always_populate_raw_post_data =@always_populate_raw_post_data = -1@g" /etc/php.ini

接着安裝mysql,要查看是否已安裝mysql,若是版本不符合,則須要卸載,重裝:

[root@mid01 zabbix_file]# rpm -qa| grep mysql
mysql-5.1.71-1.el6.x86_64
mysql-server-5.1.71-1.el6.x86_64
php55w-mysql-5.5.38-1.w6.x86_64
qt-mysql-4.6.2-26.el6_4.x86_64
mysql-libs-5.1.71-1.el6.x86_64
強制卸載:
[root@mid01 zabbix_file]# rpm -e --nodeps mysql-5.1.71-1.el6.x86_64
[root@mid01 zabbix_file]# rpm -e --nodeps mysql-server-5.1.71-1.el6.x86_64
warning: /var/log/mysqld.log saved as /var/log/mysqld.log.rpmsave
[root@mid01 zabbix_file]# rpm -e --nodeps mysql-libs-5.1.71-1.el6.x86_64

 下載mysql5.5tar包並解壓:

[root@mid01 zabbix_file]# tar -xvf MySQL-5.5.56-1.el6.x86_64.rpm-bundle.tar 
MySQL-shared-5.5.56-1.el6.x86_64.rpm
tar: MySQL-shared-5.5.56-1.el6.x86_64.rpm: time stamp 2017-04-28 02:06:41 is 15825714.217439403 s in the future
MySQL-test-5.5.56-1.el6.x86_64.rpm
tar: MySQL-test-5.5.56-1.el6.x86_64.rpm: time stamp 2017-04-28 02:06:45 is 15825717.725779682 s in the future
MySQL-server-5.5.56-1.el6.x86_64.rpm
tar: MySQL-server-5.5.56-1.el6.x86_64.rpm: time stamp 2017-04-28 02:06:31 is 15825702.522847995 s in the future
MySQL-embedded-5.5.56-1.el6.x86_64.rpm
tar: MySQL-embedded-5.5.56-1.el6.x86_64.rpm: time stamp 2017-04-28 02:06:10 is 15825680.34405559 s in the future
MySQL-client-5.5.56-1.el6.x86_64.rpm
tar: MySQL-client-5.5.56-1.el6.x86_64.rpm: time stamp 2017-04-28 02:06:02 is 15825671.899264437 s in the future
MySQL-devel-5.5.56-1.el6.x86_64.rpm
tar: MySQL-devel-5.5.56-1.el6.x86_64.rpm: time stamp 2017-04-28 02:06:07 is 15825676.822329417 s in the future
MySQL-shared-compat-5.5.56-1.el6.x86_64.rpm
tar: MySQL-shared-compat-5.5.56-1.el6.x86_64.rpm: time stamp 2017-04-28 02:06:42 is 15825711.705837133 s in the future
[root@mid01 zabbix_file]# ls
MySQL-5.5.56-1.el6.x86_64.rpm-bundle.tar     MySQL-test-5.5.56-1.el6.x86_64.rpm      php55w-mysql-5.5.38-1.w6.x86_64.rpm
MySQL-client-5.5.56-1.el6.x86_64.rpm         php55w-5.5.38-1.w6.x86_64.rpm           php55w-pdo-5.5.38-1.w6.x86_64.rpm
MySQL-devel-5.5.56-1.el6.x86_64.rpm          php55w-bcmath-5.5.38-1.w6.x86_64.rpm    php55w-xml-5.5.38-1.w6.x86_64.rpm
MySQL-embedded-5.5.56-1.el6.x86_64.rpm       php55w-cli-5.5.38-1.w6.x86_64.rpm       php-ldap-5.5.29-1.mga4.x86_64.rpm
MySQL-server-5.5.56-1.el6.x86_64.rpm         php55w-common-5.5.38-1.w6.x86_64.rpm    t1lib-5.1.2-6.el6_2.1.x86_64.rpm
MySQL-shared-5.5.56-1.el6.x86_64.rpm         php55w-gd-5.5.38-1.w6.x86_64.rpm
MySQL-shared-compat-5.5.56-1.el6.x86_64.rpm  php55w-mbstring-5.5.38-1.w6.x86_64.rpm

共八個rpm包,暫時只須要用到server和client:

[root@mid01 zabbix_file]# rpm -ivh MySQL-server-5.5.56-1.el6.x86_64.rpm 
warning: MySQL-server-5.5.56-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
   1:MySQL-server           ########################################### [100%]
[root@mid01 zabbix_file]# rpm -ivh MySQL-client-5.5.56-1.el6.x86_64.rpm 
warning: MySQL-client-5.5.56-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
   1:MySQL-client           ########################################### [100%]

不過我把全部mysql rpm包都裝了順序是:

 

rpm -ivh mysql-community-common-5.7.11-1.el6.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.11-1.el6.x86_64.rpm
rpm -ivh mysql-community-client-5.7.11-1.el6.x86_64.rpm
rpm -ivh mysql-community-server-5.7.11-1.el6.x86_64.rpm
rpm -ivh mysql-community-devel-5.7.11-1.el6.x86_64.rpm
rpm -ivh mysql-community-embedded-5.7.11-1.el6.x86_64.rpm
rpm -ivh mysql-community-embedded-devel-5.7.11-1.el6.x86_64.rpm
rpm -ivh mysql-community-libs-compat-5.7.11-1.el6.x86_64.rpm
rpm -ivh mysql-community-test-5.7.11-1.el6.x86_64.rpm

 

 

 

查看mysql安裝路徑:

 

[root@mid01 zabbix_file]# find / -name mysql -print
/etc/rc.d/init.d/mysql
/etc/logrotate.d/mysql
/usr/lib64/perl5/DBD/mysql
/usr/lib64/perl5/auto/DBD/mysql
/usr/lib64/mysql
/usr/share/mysql
/usr/bin/mysql
/var/lib/mysql
/var/lib/mysql/mysql

data默認目錄:/var/lib/mysql
mysql默認安裝目錄:/usr/share/mysql

PS:在mysql5.5 的安裝目錄裏會有多個cnf配置文件,根據須要複製一個到/etc/my.cnf。mysql5.5以後的就默認只有一個配置文件了/etc/my.cnf(linux版本)

 

 

設置帳號、密碼、字符編碼:

剛剛安裝的mysql不輸入密碼也能夠進入mysql交互界面,重置root有多種方法,這裏介紹其中一種:

在my.cnf的[mysqld]下面加一行:skip-grant-tables

而後重啓mysql,再進入交互界面重置密碼,最後再刪了skip-grant-tables

[root@mid01 mysql]# vim /etc/my.cnf
[root@mid01 mysql]# service mysql restart
Shutting down MySQL.                                       [  OK  ]
Starting MySQL...                                          [  OK  ]
[root@mid01 mysql]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.56-log MySQL Community Server (GPL)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

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> UPDATE user SET password=PASSWORD("zabbix_server") WHERE user='root';
ERROR 1046 (3D000): No database selected
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| test               |
+--------------------+
3 rows in set (0.00 sec)

mysql> use mysql;
Database changed
mysql> UPDATE user SET password=PASSWORD("zabbix_server") WHERE user='root';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3  Changed: 3  Warnings: 0

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)
若是安裝lnmp沒問題,接下來就是安裝zabbix裝。https://www.zabbix.com/documentation/2.4/manual/installation/install
這個是官網上面的教程選擇「4 Installation from sources」這個選項,意思就是源文件安裝。
1.先解壓源文件:$tar -zxvf zabbix-2.4.7.tar.gz
2.在/database/mysql文件夾下找到schema.sql、images.sql、data.sql這三個文件
3.建立mysql帳號
mysql -u root -p
mysql> create user 'zabbix'@'localhost' identified by 'zabbix';
mysql> create database zabbix;
mysql> grant all privileges on zabbix.* to 'zabbix'@'localhost';
mysql> flush privileges;
mysql> exit;
4.導入初始化數據
mysql -u zabbix -p zabbix < schema.sql
mysql -u zabbix -p zabbix < images.sql
mysql -u zabbix -p zabbix < data.sql
這樣Zabbix的初始數據就導入了。
5.而後:groupadd zabbix
useradd -g zabbix zabbix
 
6.Configure the sources
./configure --prefix=/usr/local --enable-server --enable-agent --with-mysql
--enable-ipv6 --with-libcurl --with-libxml2 --with-net-snmp
configure後面的 --prefix=/usr/local最好是加上,加上以後後面一步的make install就能安裝到這
個/usr/local/文件夾下了。
最後的 --with-net-snmp加了會報錯,不加以後就行了。(固然,net-snmp這個最好安裝一下,目前還
不知道不加這個有沒有什麼問題,暫時沒有發現影響)
PS:我用lnmp一鍵安裝包部署的環境,mysql不在默認路徑下,我須要把--with-mysql 改爲:--with-mysql=/usr/local/mysql/bin/mysql_config 能夠經過find / -name mysql_config搜到具體路徑
 
在編譯的過程當中,會須要說某某rpm包找不到,這時能夠經過yum安裝。
 

 

yum -y install gcc+ gcc-c++

相關文章
相關標籤/搜索