1. 程式人生 > >zabbix(1)--服務器端安裝及配置

zabbix(1)--服務器端安裝及配置

zabbix-server

1、zabbix-server配置

zabbix版本選擇LTS的3.0版本、server端OS版本為RHEL 6.5

配置zabbix倉庫,進行yum安裝zabbix

~]# cd /etc/yum.repos.d/

yum.repos.d]# vim zabbix.repo

[zabbix]
name=zabbix repo
baseurl=http://repo.zabbix.com/zabbix/3.0/rhel/6/x86_64/
enabled=1
gpgcheck=0

安裝mysql,進行配置修改並啟動

~]# yum install mysql-server -y

~]# vim /etc/my.cnf 
[mysqld]
datadir=/home/mysqldata
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
skip_name_resolve=on
innodb_file_per_table=on

~]# service mysqld start

創建zabbix庫,並授權鏈接

[[email protected] mysqldata]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.73 Source distribution

Copyright (c) 2000, 2013, 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> CREATE DATABASE zabbix CHARSET ‘utf8‘;
Query OK, 1 row affected (0.00 sec)

mysql> GRANT ALL ON zabbix.* TO [email protected]
/* */ IDENTIFIED BY ‘*‘; Query OK, 0 rows affected (0.00 sec) mysql> GRANT ALL ON zabbix.* TO [email protected]%.%.%‘ IDENTIFIED BY ‘*‘; Query OK, 0 rows affected (0.00 sec) mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec)

安裝zabbix相關組件並進行zabbix庫初始化

~]# yum install zabbix-server-mysql zabbix-web zabbix-agent zabbix-web-mysql zabbix-sender zabbix-get

查看zabbix-mysql相關內容
~]# rpm -ql zabbix-server-mysql
/etc/init.d/zabbix-server
/etc/logrotate.d/zabbix-server
/etc/zabbix/zabbix_server.conf
/usr/lib/zabbix/alertscripts
/usr/lib/zabbix/externalscripts
/usr/sbin/zabbix_server_mysql
/usr/share/doc/zabbix-server-mysql-3.0.9
/usr/share/doc/zabbix-server-mysql-3.0.9/AUTHORS
/usr/share/doc/zabbix-server-mysql-3.0.9/COPYING
/usr/share/doc/zabbix-server-mysql-3.0.9/ChangeLog
/usr/share/doc/zabbix-server-mysql-3.0.9/NEWS
/usr/share/doc/zabbix-server-mysql-3.0.9/README
/usr/share/doc/zabbix-server-mysql-3.0.9/create.sql.gz
/usr/share/man/man8/zabbix_server.8.gz
/var/log/zabbix
/var/run/zabbix

zabbix庫初始化操作

[[email protected] zabbix]# cd /usr/share/doc/zabbix-server-mysql-3.0.9/
[[email protected] zabbix-server-mysql-3.0.9]# gzip -d create.sql.gz 
[[email protected] zabbix-server-mysql-3.0.9]# ll
total 3752
-rw-r--r-- 1 root root  98 Apr 20 20:05 AUTHORS
-rw-r--r-- 1 root root  718465 Apr 20 20:05 ChangeLog
-rw-r--r-- 1 root root   17990 Apr 20 20:05 COPYING
-rw-r--r-- 1 root root 3086105 Apr 24 01:57 create.sql
-rw-r--r-- 1 root root  52 Apr 20 20:05 NEWS
-rw-r--r-- 1 root root 188 Apr 20 20:05 README
[[email protected] zabbix-server-mysql-3.0.9]# mysql -h127.0.0.1 -uzbxuser -p *** < create.sql 
Enter password: 

[[email protected] zabbix-server-mysql-3.0.9]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.1.73 Source distribution

Copyright (c) 2000, 2013, 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> use zabbix
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> SHOW tables;
+----------------------------+
| Tables_in_zabbix   |
+----------------------------+
| acknowledges   |
| actions|
| alerts |
| application_discovery  |
| application_prototype  |
| application_template   |
| applications   |
| auditlog   |
| auditlog_details   |
| autoreg_host   |
| conditions |
| config |
| dbversion  |
| dchecks|
| dhosts |
| drules |
| dservices  |
| escalations|
| events |
| expressions|
| functions  |
| globalmacro|
| globalvars |
| graph_discovery|
| graph_theme|
| graphs |
| graphs_items   |
| group_discovery|
| group_prototype|
| groups |
| history|
| history_log|
| history_str|
| history_text   |
| history_uint   |
| host_discovery |
| host_inventory |
| hostmacro  |
| hosts  |
| hosts_groups   |
| hosts_templates|
| housekeeper|
| httpstep   |
| httpstepitem   |
| httptest   |
| httptestitem   |
| icon_map   |
| icon_mapping   |
| ids|
| images |
| interface  |
| interface_discovery|
| item_application_prototype |
| item_condition |
| item_discovery |
| items  |
| items_applications |
| maintenances   |
| maintenances_groups|
| maintenances_hosts |
| maintenances_windows   |
| mappings   |
| media  |
| media_type |
| opcommand  |
| opcommand_grp  |
| opcommand_hst  |
| opconditions   |
| operations |
| opgroup|
| opinventory|
| opmessage  |
| opmessage_grp  |
| opmessage_usr  |
| optemplate |
| profiles   |
| proxy_autoreg_host |
| proxy_dhistory |
| proxy_history  |
| regexps|
| rights |
| screen_user|
| screen_usrgrp  |
| screens|
| screens_items  |
| scripts|
| service_alarms |
| services   |
| services_links |
| services_times |
| sessions   |
| slides |
| slideshow_user |
| slideshow_usrgrp   |
| slideshows |
| sysmap_element_url |
| sysmap_url |
| sysmap_user|
| sysmap_usrgrp  |
| sysmaps|
| sysmaps_elements   |
| sysmaps_link_triggers  |
| sysmaps_links  |
| timeperiods|
| trends |
| trends_uint|
| trigger_depends|
| trigger_discovery  |
| triggers   |
| users  |
| users_groups   |
| usrgrp |
| valuemaps  |
+----------------------------+
113 rows in set (0.00 sec)

啟動zabbix-server進程

進程
/etc/init.d/zabbix-server

配置文件說明:
/etc/zabbix/zabbix_server.conf


指令有四類:
############ GENERAL PARAMETERS #################
############ ADVANCED PARAMETERS ################
####### LOADABLE MODULES #######
####### TLS-RELATED PARAMETERS #######



配置文檔修改如下:
    ListenPort=10051
    SourceIP=
    LogType=file
    LogFile=/var/log/zabbix/zabbix_server.log
    LogFileSize=1024 #日誌切換
    PidFile=/var/run/zabbix/zabbix_server.pid

    DBHost=127.0.0.1
    DBName=zabbix
    DBUser=zbxuser
    DBPassword=*****
    DBSocket=/var/lib/mysql/mysql.sock  #根據mysql具體配置設置


啟動zabbix服務
[[email protected] ~]# service zabbix-server start
Starting Zabbix server:[  OK  ]
[[email protected] ~]# service zabbix-server status
zabbix_server (pid  10995) is running...

2、配置zabbix-web

由於zabbix-web對php版本有最低配置,首先對php相關組件進行處理

升級PHP
配置webtatic源
~]# rpm -ivh http://repo.webtatic.com/yum/el6/latest.rpm
卸載舊版本php
~]# yum erase php php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mcrypt php-mbstring php-devel php-pecl-memcached php-pecl-memcache  php-common php-pdo php-cli php-fpm libmemcached
安裝新版本php
~]# yum install httpd php56w php56w-mysql php56w-gd php56w-imap php56w-ldap php56w-odbc php56w-pear php56w-xml php56w-xmlrpc php56w-mcrypt php56w-mbstring php56w-devel php56w-pecl-memcached  php56w-common php56w-pdo php56w-cli php56w-pecl-memcache php56w-bcmath php56w-fpm

配置php的時區指定

~]# vim /etc/php.ini
date.timezone = Asia/Shanghai
post_max_size = 32M
max_execution_time = 300
max_input_time = 300
always_populate_raw_post_data = -1

啟動web server

service httpd start

創建zabbix的web資源,並授予相關權限

~]# mkdir /var/www/html/zabbix
~]# cd /usr/share/zabbix/
~]# cp -a . /var/www/html/zabbix/
~]# chown -R apache:apache /var/www/html/zabbix

配置結束後將相關服務添加至開啟自啟動(httpd,mysqld,zabbix-server,zabbix-agent)

chkconfig httpd on
chkconfig mysqld on
chkconfig zabbix-server on
chkconfig zabbix-agentd on

service zabbix-server restart

備註,啟動http時有一個報錯,修改相應權限後正常

[Mon May 22 15:39:53 2017] [error] [client 10.55.56.86] PHP Warning:  require_once(/etc/zabbix/web/maintenance.inc.php): failed to open stream: Permission denied in /var/www/html/zabbix/include/classes/core/ZBase.php on line 269

]# chmod -R 755 /etc/zabbix/web

配置完成後便可進入web進行配置,訪問URL:http://server/zabbix

技術分享

技術分享

技術分享

技術分享

技術分享

手動download並拷貝過去

技術分享

技術分享


初始密碼:admin zabbix

本文出自 “Open World” 博客,請務必保留此出處http://voidyao000.blog.51cto.com/12458042/1929843

zabbix(1)--服務器端安裝及配置