#環境安裝
在centos6中安裝3.0以上版本並沒有那麼簡單,因爲需要6中自帶的yum源中MYSQL,PHP,CURL版本不能使用。所以在安裝前要做如下步驟。
1.首頁安裝Webtatic EL6 YUM源
> rpm -ivh http://repo.webtatic.com/yum/el6/latest.rpm
2.安裝mysql5.6
>rpm -ivh http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
>yum install mysql-community-server mysql-devel
3.安裝PHP5.6和gcc等
>rpm -ivh http://ftp.iij.ad.jp/pub/linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
>yum -y install php56w.x86_64
>yum -y install php56w-gd.x86_64 php56w-ldap.x86_64 php56w-mbstring.x86_64 php56w-mcrypt.x86_64 php56w-mysql.x86_64 php56w-pdo.x86_64 php56w-opcache.x86_64 php-xmlwriter *bcmath* --skip-broken
>yum install gcc make wget -y
>yum install libxml2-devel unixODBC-devel net-snmp net-snmp-devel libssh2-devel curl-devel OpenIPMI OpenIPMI-devel -y
#安裝zabbix
1.同步服務端的時間,保持所有服務器時間一致避免出現時間不同導致的不可用的監控數據
>yum -y install ntpdate
>ntpdate pool.ntp.org #ntpdate命令需要安裝
2.創建zabbix服務運行所需要的用戶和組
>groupadd -g 201 zabbix
>useradd -g zabbix -u 201 -m zabbix
3.初始化mysql服務器
>/etc/init.d/mysqld start
4.創建zabbix運行所需要的數據庫及用戶權限
修改mysql初始密碼123456
>/etc/init.d/mysqld stop
>/usr/bin/mysqld_safe --skip-grant-tables
另外開個SSH連接
[root@localhost ~]# mysql
mysql>use mysql
mysql>update user set password=password("123456") where user="root";
mysql>flush privileges;
mysql>exit
登錄
mysql -uroot -p123456
create database zabbix character set utf8;
創建用戶名爲’zabbixuser’,密碼’zabbix’的賬號對於zabbix數據庫有權限。
grant all privileges on zabbix.* to zabbixuser@'%' identified by 'zabbix';
grant all privileges on zabbix.* to zabbixuser@'localhost' identified by 'zabbix';
flush privileges;
exit;
5.下載zabbix源碼包
http://www.zabbix.com/download
下拉,zabbix sources下載tar.gz格式源碼包。
tar -zxvf zabbix-xxxxx
將zabbix的初始數據導入到數據庫中
cd zabbix-xxxx
mysql -uzabbixuser -pzabbix zabbix < database/mysql/schema.sql
mysql -uzabbixuser -pzabbix zabbix < database/mysql/images.sql
mysql -uzabbixuser -pzabbix zabbix < database/mysql/data.sql
登錄數據庫查看下錶是否都創建成功
6.編譯安裝zabbix
>./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2 --enable-proxy --with-openipmi --with-unixodbc -with-ssh2 --enable-ipv6
make && make install
此處指定配置文件的路徑就在/usr/local/zabbix/目錄下了
7.複製zabbixserver端跟agent端的啓動腳本,並設置執行權限,文件在解壓後的zabbix目錄中。
>cp misc/init.d/tru64/zabbix_agentd /etc/init.d/
cp misc/init.d/tru64/zabbix_server /etc/init.d/
cp /usr/local/zabbix/sbin/zabbix_server /usr/local/sbin/
chmod +x /etc/init.d/zabbix_*
8.將zabbix的頁面文件copy到指定目錄(跟apache配置的相同即可)
>mkdir /var/www/html/zabbix
cp -a zabbix-xxxxx/frontends/php/* /var/www/html/zabbix/
chown -R apache.apache /var/www/html/zabbix/
9.配置php文件,適應zabbix安裝所需的參數
>vim /etc/php.ini
date.timezone = Asia/Shanghai
max_execution_time = 300
max_input_time = 300
post_max_size = 32M
memory_limit = 128M
mbstring.func_overload = 2
10.配置apache文件,定義安裝訪問zabbix的虛擬主機
>vim /etc/httpd/conf/httpd.conf
ServerName 127.0.0.1
DocumentRoot "/var/www/html"
ServerName 192.168.239.130 #替換爲本機ip
11.修改zabbix server端的文件,定義數據庫的IP、用戶名、密碼.
>vim /usr/local/zabbix/etc/zabbix_server.conf
LogFile=/tmp/zabbix_server.log
PidFile=/tmp/zabbix_server.pid
ListenIP=192.168.239.130 #替換自己設置的參數
DBName= zabbix
DBUser=zabbixuser
DBPassword=zabbix
12.啓動apache服務跟zabbix服務
>/etc/init.d/httpd start
>/etc/init.d/zabbix_server start
14.訪問安裝界面
http://192.168.239.130/zabbix/setup.php #替換ip
15.出現如下圖片,可能會出現一些fail,可以根據提示的進行修改/etc/php.ini和下載缺失的php模塊。
可用類似以下命令安裝缺少的插件
yum -y install php56w-bcmath
16.所有都顯示ok後,填入預設的mysql信息
host: ip
port:3306
name:zabbix
user:zabbixuser
password:zabbix
17.之後一直默認點擊下一步,即可配置成功進入zabbix主頁,到了這步算是安裝配置完成了,可以開始實際使用了。
#初步配置
其實上面的一些步驟已經可以正常使用了,但是某些配置還是不適合我們使用習慣,所以下面有一些方面使用的配置方法。
1.修改主頁登錄鏈接
初始設置是輸入 http://ip/zabbix 進入主頁登錄,每次登錄都不方便。以下就是講主頁改成直接輸入ip就可以進入主頁。
/etc/httpd/conf/httpd.conf
修改DocumentRoot如下
DocumentRoot “/var/www/html/zabbix/”
重啓httpd服務即可