搭建zabbix詳細步驟


關閉selinux和防火牆

selinux關閉:

1 命令查看出selinux的狀態
sestatus -v
2 臨時關閉 selinux
setenforce 0
3 永久關閉selinux
vi /etc/sysconfig/selinux
把里邊的一行改為
SELINUX=disabled


防火牆關閉:
(之前的版本)
service stop iptables 關閉iptables
chkconfig iptables off 開機不啟動
(現在的版本)
systemctl stop firewalld。service
systemctl disable firewalld。service

一、剛剛開始安裝zabbix時候需要配置zabbix源和epel源

zabbix源配置:

[zabbix]
name=zabbix
baseurl=http: //repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/
# 或則 baseurl=http: //mirrors.aliyun.com/zabbix/zabbix/3.0/rhel/7/x86_64/ 兩個都可以
gpgcheck= 0
enabled= 1
 
epel源配置:(什么版本系統選什么源)

epel(RHEL 7)

	wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

epel(RHEL 6)

	wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo

epel(RHEL 5)

	wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-5.repo


yum makecache 先確定網絡能通,否則:

[root@localhost ~]# yum makecache
已加載插件:fastestmirror
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; 未知的名稱或服務"


One of the configured repositories failed (未知),
and yum doesn't have enough cached data to continue. At this point the only
safe thing yum can do is fail. There are a few ways to work "fix" this:

1. Contact the upstream for the repository and get them to fix the problem.

2. Reconfigure the baseurl/etc. for the repository, to point to a working
upstream. This is most often useful if you are using a newer
distribution release than is supported by the repository (and the
packages for the previous distribution release still work).

3. Run the command with the repository temporarily disabled
yum --disablerepo=<repoid> ...

4. Disable the repository permanently, so yum won't use it by default. Yum
will then just ignore the repository until you permanently enable it
again or use --enablerepo for temporary usage:

yum-config-manager --disable <repoid>
or
subscription-manager repos --disable=<repoid>

5. Configure the failing repository to be skipped, if it is unavailable.
Note that yum will try to contact the repo. when it runs most commands,
so will have to try and fail each time (and thus. yum will be be much
slower). If it is a very temporary problem though, this is often a nice
compromise:

yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true

Cannot find a valid baseurl for repo: base/7/x86_64

 
二、安裝zabbix對應的包(如果一台主機扮演三個端,那么可以都安裝上,但是一般來說,都是在zabbix服務端安裝zabbix-server-mysql ,zabbix-web, zabbix-web-mysql)
yum install -y zabbix-server-mysql zabbix-get # 服務端安裝的包
yum install -y zabbix-agent zabbix-sender # agent端安裝的包
yum install -y zabbix-web zabbix-web-mysql # web-GUI端安裝的包
 
三、安裝zabbix DB:(在/etc/my.cfg中加入   skip_name_resolve=on innodb_file_per_table=on)
yum install mariadb-server
systemctl start mariadb.service

[root@localhost ~]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.56-MariaDB MariaDB Server

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create database zabbix charset 'utf8';
MariaDB [(none)]> grant all on zabbix.* to zabbix@'192.168.23.%' identified by '123456';
MariaDB [(none)]> flush privileges;
 
四、zabbix server數據庫初始化:
2.0系列:導入三個sql腳本,這三個腳本要按順序執行
3.0系列: 導入一個sql腳本 :create.sql
cd /usr/share/doc/zabbix-server-mysql -3.0.10/
gzip -d create.sql.gz
mysql -h192 .168.23.67 -uzabbix -p123456 zabbix < create.sql
登入到mysql,可以查看zabbix數據庫中初始化生成的表
 
五、啟動zabbix-server進程
①:啟動zabbix-server進程會讀取配置文件:/etc/zabbix/zabbix_server.conf,這個配置文件中的指令有四類
GENERAL PARAMETERS
ADVANCED PARAMETERS
LOADABLE MODULES
TLS-RELATED PARAMETERS
 
②:修改 GENERAL PARAMETERS 中的指令
ListenPort=10051 : 監聽的端口號
SourceIP= :授權使用的監控的IP地址,如果服務器有多個IP地址,有必要的情況下,只需要監聽一個IP即可
LogType=file :日志的類型
LogFile=/var/log/zabbix/zabbix_server.log:日志的路徑
LogFileSize=0 :日志滾動的閾值,0表示不滾動
PidFile=/var/run/zabbix/zabbix_server.pid : pid的存放文件
DBHost=192.168.23.67 :指定數據庫的主機地址
DBName=zabbix ( zabbix數據庫名稱)
DBUser=zabbix (連接數據庫的用戶名)
DBPassword=123456 (數據庫密碼)
DBSocket=/var/lib/mysql/mysql.sock ( mariadb是通過yum安裝的,因此socket文件不在/tmp目錄下面)
 
③:啟動服務
systemctl start zabbix-server.service  (按照以上步驟操作,不知道什么情況啟動不了,然后試了一下又可以了,可以的話幫忙解決以下)
④:確保本機的trousers程序包版本一定是 0.3.11之后的版本
 
6、 配置zabbix-web (在安裝 zabbix-web和zabbix-web-mysql的時候,默認會安裝httpd程序包和php-mysql程序包)
①:配置php的時區
1:php.ini
2:/etc/httpd/conf.d/zabbix.conf(使用這個)
php_value date.timezone Asia/ Shanghai :表示在mod_php5.c模塊里面,設定為上海的時間
②:啟動httpd
systemctl start httpd
 
7、登入http: //192.168.23.67/zabbix/頁面
 
8、進入zabbix頁面后需要填寫:Database  type  (mysql)
                                                   Database host (zabbix,service的ip)
                                                   Database port (zabbix配置文件中配置的3306)
                                                   Database name (zabbix)
                                                  User   (zabbox)
                                                  passwd (密碼1234546)
9:設置數據庫的連接方式,如:數據庫名,用戶名,密碼等,如果在設置的時候寫錯了,可以直接修改/etc/zabbix/web/zabbix.conf.php文件
 
10:zabbix-web的登入名為:admin,密碼為:zabbix
 
 
 
 
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM