您好,登錄后才能下訂單哦!
一.添加yum 第三方源:
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
二.添加zabbix源:
rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
三.安裝服務端zabbix包
yum install -y zabbix-server-mysql zabbix-web-mysql zabbix-agent zabbix-get
#(清楚的看一下要安裝那些包httpd php基本都依賴安裝了)
Dependencies Resolved
===========================================================================================
Package Arch Version Repository Size
===========================================================================================
Installing:
zabbix-server-mysql x86_64 3.0.8-2.el7 zabbix 1.7 M
zabbix-web-mysql noarch 3.0.8-2.el7 zabbix 4.5 k
Installing for dependencies:
OpenIPMI-libs x86_64 2.0.19-15.el7 base 502 k
OpenIPMI-modalias x86_64 2.0.19-15.el7 base 15 k
dejavu-fonts-common noarch 2.33-6.el7 base 64 k
dejavu-sans-fonts noarch 2.33-6.el7 base 1.4 M
fping x86_64 3.10-4.el7 epel 46 k
httpd x86_64 2.4.6-45.el7.centos base 2.7 M
httpd-tools x86_64 2.4.6-45.el7.centos base 84 k
iksemel x86_64 1.4-6.el7 epel 50 k
libXpm x86_64 3.5.11-3.el7 base 54 k
libtool-ltdl x86_64 2.4.2-21.el7_2 base 49 k
libxslt x86_64 1.1.28-5.el7 base 242 k
libzip x86_64 0.10.1-8.el7 base 48 k
mailcap noarch 2.1.41-2.el7 base 31 k
net-snmp-libs x86_64 1:5.7.2-24.el7_2.1 base 747 k
php x86_64 5.4.16-42.el7 base 1.4 M
php-bcmath x86_64 5.4.16-42.el7 base 57 k
php-cli x86_64 5.4.16-42.el7 base 2.7 M
php-common x86_64 5.4.16-42.el7 base 564 k
php-gd x86_64 5.4.16-42.el7 base 127 k
php-ldap x86_64 5.4.16-42.el7 base 52 k
php-mbstring x86_64 5.4.16-42.el7 base 505 k
php-mysql x86_64 5.4.16-42.el7 base 101 k
php-pdo x86_64 5.4.16-42.el7 base 98 k
php-xml x86_64 5.4.16-42.el7 base 125 k
t1lib x86_64 5.1.2-14.el7 base 166 k
unixODBC x86_64 2.3.1-11.el7 base 413 k
zabbix-web noarch 3.0.8-2.el7 zabbix 3.5 M
Transaction Summary
===========================================================================================
四.數據庫相關操作
CentOS 7 版本將MySQL數據庫軟件從默認的程序列表中移除,用mariadb代替了。mariadb命令語句和mysql都是一樣的,不想折騰了,所以安裝mariadb
1、安裝MariaDB
yum -y install mariadb mariadb-server
安裝完成MariaDB,首先啟動MariaDB
systemctl start mariadb
設置開機啟動
systemctl enable mariadb
接下來進行MariaDB的相關簡單配置
mysql_secure_installation
首先是設置密碼,會提示先輸入密碼
Enter current password for root (enter for none):<–初次運行直接回車設置密碼
Set root password? [Y/n] <– 是否設置root用戶密碼,輸入y并回車或直接回車
New password: <– 設置root用戶的密碼
Re-enter new password: <– 再輸入一次你設置的密碼
Remove anonymous users? [Y/n] <– 是否刪除匿名用戶,回車
Disallow root login remotely? [Y/n] <–是否禁止root遠程登錄,回車,
Remove test database and access to it? [Y/n] <– 是否刪除test數據庫,回車
Reload privilege tables now? [Y/n] <– 是否重新加載權限表,回車
初始化MariaDB完成,接下來測試登錄
mysql -uroot -p
會提示你輸入密碼,登錄成功,證明MariaDB安裝成功。
2、配置MariaDB的字符集
vi /etc/my.cnf
在[mysqld]標簽下添加
init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake
====================================
vi /etc/my.cnf.d/client.cnf
在[client]中添加
default-character-set=utf8
=====================================
vi /etc/my.cnf.d/mysql-clients.cnf
在[mysql]中添加
default-character-set=utf8
=====================================
全部配置完成,重啟mariadb
systemctl restart mariadb
進入MariaDB查看字符集
mysql> show variables like "%character%";show variables like "%collation%";
顯示為
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)
+----------------------+-----------------+
| Variable_name | Value |
+----------------------+-----------------+
| collation_connection | utf8_unicode_ci |
| collation_database | utf8_unicode_ci |
| collation_server | utf8_unicode_ci |
+----------------------+-----------------+
3 rows in set (0.00 sec)
字符集配置完成。
3、添加用戶,設置權限
mysql -uroot -p
mysql> create database zabbixdb character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
mysql> grant all privileges on zabbixdb.* to zabbix@localhost identified by 'Zabbix@2008';
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye
4、初始化數據庫
cd /usr/share/doc/zabbix-server-mysql-3.0.8
zcat create.sql.gz | mysql -uroot -p'你數據庫root密碼' zabbixdb
五.啟動zabbix server服務
修改配置文件:
vi /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbixdb
DBUser=zabbix
DBPassword=Zabbix@2008
備注:實際上我的配置文件修改的是DBHost和DBPassword去掉前面的#號。
啟動zabbix服務,設置開機自啟動
systemctl start zabbix-server
systemctl enable zabbix-server
六.編輯zabbix前端的PHP配合配置
vi /etc/httpd/conf.d/zabbix.conf
php_value max_execution_time 300
php_value memory_limit 128M
php_value post_max_size 16M
php_value upload_max_filesize 2M
php_value max_input_time 300
php_value always_populate_raw_post_data -1
php_value date.timezone Asia/Shanghai
備注:實際上我就是修改了時區
七.啟動apache服務,設置開機自啟動
systemctl start httpd
systemctl enable httpd
八.登陸zabbix
http://IP/zabbix/
顯示的界面
點擊next會出現檢查狀態:
點擊next配置mysql:
點擊下一步。此步出現錯誤,發現無法連接數據庫,最后發現zabbix這個數據庫中,沒有任何數據,檢查時加紅色的那部分出問題。
next到最后
默認用戶名/密碼:Admin/zabbix
進入主頁面:下面進行,將語言改為中文。
[zabbix@miyan zabbix-server-mysql-.]$ vim /usr/share/zabbix/include/locales.inc.php
找到第55行,將false改為true
點擊zabbix右上角小人,進行修改:
######################################################################
客戶端安裝和配置
Centos6客戶端: rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/6/x86_64/zabbix-release-3.0-1.el6.noarch.rpm
Centos7 客戶端: rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
#yum clean all #yum -y install zabbix-agent 配置: vim /etc/zabbix/zabbix_agentd.conf Server=192.168.0.50 #服務端IP ServerActive=192.168.0.50 #服務端IP 配置完以上之后就是添加監控主機了
檢測:
ps -ef | grep zabbix netstat -ntl | grep 10050 (默認使用 100050 端口)
啟動并開機:
Centos7 客戶端: systemctl start zabbix-agent systemctl enable zabbix-agent Centos6 客戶端: /etc/init.d/zabbix-agent start chkconfig zabbix-agent on
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。