zabbix-3.2.3安裝

環境:lapp 
操作系統: rhel7.0
apache: apache-2.4
數據庫: postgresql-9.2.10
php: php-5.4.16-21
zabbix: zabbix-3.2.3

各個主機selinux Firewalld 關閉
各主機的hosts文件中添加各主機的hostname
192.168.28.20 zabbix
192.168.28.11 rs1
192.168.28.12 rs2
192.168.28.8 lvs

一、數據庫部分

1.數據庫安裝

源碼位置:https://www.postgresql.org/ftp/source/
1.1 解壓源碼包之後進入postgresql-9.2.10目錄進行配置
tar -xf /opt/postgresql-9.2.10.tar.bz2
cd /opt/postgresql-9.2.10
./configure --prefix=/opt/postgresql --enable-profiling --with-blocksize=8 --with-wal-blocksize=8

1.2 編譯安裝,在編譯過程中請確定是否有gcc,make等工具
make
make install

1.3 創建postgres用戶,將postgresql屬主改爲postgres,並以postgres身份進行初始化
useradd postgres;
chown postgres /opt/postgresql
su - postgres
cd /opt/postgress/bin

./initdb --encoding=utf8 -D /opt/postgresql/data


1.4 初始化完數據庫後會有下面提示,按照提示啓動數據庫。
Success. You can now start the database server using:

./postgres -D /opt/postgresql/data
or
./pg_ctl -D /opt/postgresql/data -l logfile start

2 設置環境變量

2.1 在/etc/profile添加PATH路徑及如下兩行
PATH=$PATH:$HOME/.local/bin:$HOME/bin:/opt/postgresql/bin
export PGHOME=/opt/postgresql
export PGDATA=/opt/postgresql/data
執行如下命令使環境變量生效 source /etc/profile 
2.2 啓動和停止數據庫
pg_ctl start
pg_ctl stop 

在後續的zabbix安裝中需要給zabbix賬號及數據庫,所以在這部分提前設置

3 創建zabbix賬號及遠程登錄設置

3.1 psql -U postgres -d postgres
postgres#create role zabbix  superuser login;  //創建zabbix角色
postgres#\c topwalk zabbix  //切換登錄賬號
postgres#create database zabbix  //創建zabbix數據庫
postgres#alter user zabbix with password 'zabbix';   //修改zabbix用戶密碼


3.2 數據庫訪問

PostgreSQL數據庫爲了安全,它不會監聽除本地以外的所有連接請求,當用戶通過遠程或JDBC訪問時,會報一些如下的異常:
FATAL: no pg_hba.conf entry for host
要解決這個問題,只需要在PostgreSQL數據庫的安裝目錄下找到/opt/postgresql/data/pg_hba.conf,找到“# IPv4 local connections:” 在其下加上請求連接的機器IP
#TYPE DATABASEUSERADDRESSMETHOD
host allall127.0.0.1/32md5
32是子網掩碼的網段;md5是密碼驗證方法,可以改爲trust。在此,本次實驗改爲如下
host zabbix zabbix 192.168.28.0/24 trust
在遠程主機客戶端工具psql驗證
psql -U zabbix -d zabbix -好192.168.28.20 -W

4.常見問題(不定時更新)

4.1 編譯過程中遇到configure: error: readline library not found 或 configure: error: zlib library not found 一般是缺少開發包,只需安裝readline-devel和zlib-devel即可
4.2 

二、php和apache部分

php和apache都是通過rhel自帶yum源進行安裝,直接利用yum install php php-gd php-pgsql php-xml php-bcmath php-mbstring httpd 即可
這裏需要注意的是php-bcmath和php-mbstring兩個模塊在自帶yum源裏不存在,需要額外下載,下面爲下載地址
http://rpm.pbone.net/index.php3/stat/4/idpl/27387023/dir/scientific_linux_7/com/php-mbstring-5.4.16-21.el7.x86_64.rpm.html
http://rpm.pbone.net/index.php3/stat/4/idpl/27387012/dir/scientific_linux_7/com/php-bcmath-5.4.16-21.el7.x86_64.rpm.html

三、zabbix部分

源碼包位置:https://www.zabbix.com/download

1 zabbix源碼安裝

tar -xf zabbix-3.2.3.tar.gz
./zabbix-3.2.3/configure --prefix=/opt/zabbix --enable-server --enable-agent --with-postgresql=/opt/postgresql/bin/pg_config
make && make install 

2配置postgresql 

將zabbix相關數據庫信息導入數據庫
cd /root/zabbix-3.2.3/database/postgresql
psql  -U zabbix -d zabbix -W -f schema.sql
psql  -U zabbix -d zabbix -W -f images.sql
psql  -U zabbix -d zabbix -W -f data.sql

3 配置zabbix server

grep -Ev '^$|^#' /opt/postgresql/etc/zabbix_server.conf
LogFile=/tmp/zabbix_server.log
PidFile=/tmp/zabbix_server.pid
DBHost=
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
VMwareTimeout=30
Timeout=30
LogSlowQueries=3000

4 配置zabbix agent

[root@zabbix ~]# grep -Ev '^$|^#' /opt/zabbix/etc/zabbix_agentd.conf
LogFile=/tmp/zabbix_agentd.log
Server=zabbix
StartAgents=10
ServerActive=zabbix
Hostname=zabbix
Timeout=30

5 配置php

修改/etc/php.ini中的如下內容
max_input_time = 360
max_execution_time = 300
post_max_size = 16M
date.timezone ="Asia/Shanghai"

將zabbix中的php項目放入到/var/www/html/zabbix/下面
mkdir -p /var/www/html/zabbix
cp -rf /root/zabbix-3.2.3/frontends/php/*  /var/www/html/zabbix/
chown apache.apache /var/www/html/zabbix -R 

四、登錄web進程安裝

到此爲止,包括頁面安裝所需的相關配置也已配置完畢,只需點擊next即可,知道看到登錄頁面說明已安裝成功(默認登錄用戶:Admin,密碼:zabbix)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章