這篇文章主要介紹Zabbix如何安裝部署,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!
創(chuàng)新互聯(lián)公司專(zhuān)注于錫林浩特網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗(yàn)。 熱誠(chéng)為您提供錫林浩特營(yíng)銷(xiāo)型網(wǎng)站建設(shè),錫林浩特網(wǎng)站制作、錫林浩特網(wǎng)頁(yè)設(shè)計(jì)、錫林浩特網(wǎng)站官網(wǎng)定制、重慶小程序開(kāi)發(fā)公司服務(wù),打造錫林浩特網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供錫林浩特網(wǎng)站排名全網(wǎng)營(yíng)銷(xiāo)落地服務(wù)。
前言
Zabbix是目前最為主流的開(kāi)源監(jiān)控方案之一,部署本身并不困難,難的是深入理解。根據(jù)在生產(chǎn)環(huán)境的實(shí)踐從新版Zabbix 4.0 LTS開(kāi)始全部使用Docker部署,我相信未來(lái)越來(lái)越多的開(kāi)源組件都會(huì)以容器化的形式呈現(xiàn)在我們面前。
操作系統(tǒng):
[root@MySQL ~]# cat /etc/redhat-release CentOS Linux release 7.5.1804 (Core)
Mysql : 版本5.7.23 192.168.75.251
Zabbix Server:版本3.4.12 192.168.75.250
一、安裝Mysql
1.1下載mysql
關(guān)閉防火墻
#systemctl stop firewalld # systemctl disable firewalld vi /etc/selinux/config SELINUX=enforcing 改為 SELINUX= disabled
Centos7 默認(rèn)數(shù)據(jù)庫(kù)為mariadb ,先卸載
rpm –qa |grep mariadb mariadb-libs-5.5.56-2.el7.x86_64 rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64
這個(gè)版本需要boost 1.9,也要下載
[root@mysql soft]# ll total 132444 -rw-r--r-- 1 root root 83709983 Aug 10 10:26 boost_1_59_0.tar.gz -rw-r--r-- 1 root root 51907462 Aug 10 10:26 mysql-5.7.23.tar.gz
添加mysql用戶(hù),
groupadd mysql useradd -g mysql -s /sbin/nologin mysql
1.2安裝依賴(lài)包
yum install -y cmake bison bison-devel libaio-devel gcc gcc-c++ git ncurses-devel
1.3編譯
解壓mysql ,把boost的壓縮版放到解壓后的mysql目錄內(nèi)
tar xzvf mysql-5.7.23.tar.gz mv boost_1_59_0.tar.gz mysql-5.7.23
進(jìn)入MySQL源文件目錄,新建configure做為編譯目錄,并進(jìn)入該目
cd mysql-5.7.23 mkdir configure cd configure
使用cmake進(jìn)行生成編譯環(huán)境,
cmake .. -DBUILD_CONFIG=mysql_release \ -DINSTALL_LAYOUT=STANDALONE \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DENABLE_DTRACE=OFF \ -DWITH_EMBEDDED_SERVER=OFF \ -DWITH_INNODB_MEMCACHED=ON \ -DWITH_SSL=bundled \ -DWITH_ZLIB=system \ -DWITH_PAM=ON \ -DCMAKE_INSTALL_PREFIX=/var/mysql/ \ -DINSTALL_PLUGINDIR="/var/mysql/lib/plugin" \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DWITH_EDITLINE=bundled \ -DFEATURE_SET=community \ -DCOMPILATION_COMMENT="MySQL Server (GPL)" \ -DWITH_DEBUG=OFF \ -DWITH_BOOST=..
安裝
make && make install
修改配置文件
vim /etc/my.cnf [mysqld] datadir=/var/lib/mysql socket=/var/mysql/mysql.sock port=3306 log_error=/var/mysql/log/error.log basedir=/var/mysql/ [client] socket=/var/mysql/mysql.sock chown mysql.mysql /etc/my.cnf
創(chuàng)建日志文件
mkdir -p /var/mysql/log touch /var/mysql/log/error.log touch /var/mysql/mysql.sock chown -R mysql.mysql /var/mysql/
1.4初始化
#/var/mysql/bin/mysqld --initialize --user=mysql
查看數(shù)據(jù)文件是否生成
#ll /var/lib/mysql total 110628 -rw-r----- 1 mysql mysql 56 Aug 10 11:06 auto.cnf -rw-r----- 1 mysql mysql 417 Aug 10 11:06 ib_buffer_pool -rw-r----- 1 mysql mysql 12582912 Aug 10 11:06 ibdata1 -rw-r----- 1 mysql mysql 50331648 Aug 10 11:06 ib_logfile0 -rw-r----- 1 mysql mysql 50331648 Aug 10 11:06 ib_logfile1 drwxr-x--- 2 mysql mysql 4096 Aug 10 11:06 mysql drwxr-x--- 2 mysql mysql 8192 Aug 10 11:06 performance_schema drwxr-x--- 2 mysql mysql 8192 Aug 10 11:06 sys
查看日志文件是否生成
# ll /var/mysql/log
臨時(shí)密碼生成放在 error.log中
# cat /var/mysql/log/error.log 2019-11-18T09:06:22.922254Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2019-11-18T09:06:24.600401Z 0 [Warning] InnoDB: New log files created, LSN=45790 2019-11-18T09:06:24.853258Z 0 [Warning] InnoDB: Creating foreign key constraint system tables. 2019-11-18T09:06:24.915246Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 5dbf9eac-9c4a-11e8-8768-000c29a48522. 2019-11-18T09:06:24.916709Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened. 2019-11-18T09:06:24.917772Z 1 [Note] A temporary password is generated for root@localhost: NS0+>RzwvHWl
1.5啟動(dòng)
修改初始密碼、修改環(huán)境變量
從模板文件中復(fù)制啟動(dòng)文件:
cp /var/mysql/support-files/mysql.server /etc/init.d/mysqld
修改啟動(dòng)文件:
vim /etc/init.d/mysqld
找到如下二行:
basedir=
datadir=
修改為:
basedir=/var/mysql/ datadir=/var/lib/mysql
更改權(quán)限
#chown -R mysql.mysql /var/mysql /var/lib/mysql
啟動(dòng)
/etc/init.d/mysqld start ln -s /var/mysql/bin/mysql /usr/bin
配置MySQL環(huán)境變量:
vim /root/.bash_profile
找到下面一行:
PATH=$PATH:$HOME/bin
修改為:
PATH=$PATH:$HOME/bin:/var/mysql/bin
利用上面生成的臨時(shí)密碼,登錄
# mysql –u root –p NS0+>RzwvHWl
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.23
Copyright (c) 2000, 2018, 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>
更改初始密碼
mysql> alter user 'root'@'localhost' identified by '123456';
二、安裝Zabbix Server
2.1 安裝php
安裝php7.1版本,zabbix3.0版本要求php5.4及以上。
先查看本地php版本
php -v
檢查當(dāng)前php的安裝包
yum list installed | grep php
將本地php安裝包卸載干凈
yum remove php*
默認(rèn)的yum源無(wú)法升級(jí)PHP,需要添加第三方y(tǒng)um源,我們選擇webtatic庫(kù)
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
安裝php7.1
yum install -y php71w
安裝相關(guān)插件
yum install -y php71w-fpm php71w-opcache php71w-cli php71w-gd php71w-imap php71w-mysqlnd php71w-mbstring php71w-mcrypt php71w-pdo php71w-pecl-apcu php71w-pecl-MongoDB php71w-pecl-redis php71w-pgsql php71w-xml php71w-xmlrpc php71w-devel mod_php71w php71w-ldap php71w-bcmath
修改PHP的配置參數(shù)
vim /etc/php.ini date.timezone= Asia/Shanghai max_execution_time = 300 post_max_size = 32M memory_limit = 128M mbstring.func_overload = 1 max_input_time = 300
Session調(diào)整權(quán)限,
chmod -R 777 /var/lib/php/session/
2.2 安裝zabbix
安裝依賴(lài)包
yum -y install gcc* make curl curl-devel net-snmp net-snmp-devel perl-DBI httpd mariadb* mysql-devel libxml2-devel curl-devel unixODBC-devel net-snmp-devel OpenIPMI-devel openldap openldap-devel libevent-develjava-devellibssh3-devel
創(chuàng)建zabbix用戶(hù)和組
groupadd zabbix useradd -g zabbix zabbix
編譯、安裝
tar zxvf zabbix-3.4.12.tar.gz cd zabbix-3.4.12/ ./configure --prefix=/usr/local/zabbix --enable-server --enable-proxy --enable-agent --enable-ipv6 --with-mysql --with-net-snmp --with-libcurl --with-openipmi --with-unixodbc --with-ldap --with-ssh3 --enable-java make && make install chown -R zabbix.zabbix /usr/local/zabbix
修改zabbix配置文件
vi /usr/local/zabbix/etc/zabbix_server.conf LogFile=/tmp/zabbix_server.log DebugLevel=3 DBHost=192.168.75.251 #server和數(shù)據(jù)庫(kù)分離的寫(xiě)法 DBName=zabbix DBUser=zabbix DBPassword=zabbix DBSocket=/var/mysql/mysql.sock DBPort=3306 StartPollers=10 Timeout=4 AlertScriptsPath=/usr/local/zabbix/share/zabbix/alertscripts LogSlowQueries=3000 CacheSize=1024M
后期配置文件的參數(shù),根據(jù)需求做調(diào)整。
把zabbix程序包中的幾個(gè)sql文件傳到上面的mysql服務(wù)器,導(dǎo)入數(shù)據(jù)庫(kù)文件
[root@zabbix ~]# cd /opt/soft/zabbix-3.4.12/database/mysql [root@zabbix mysql]# ll total 4876 -rw-r--r--. 1 1001 1001 2877497 Jul 30 19:41 data.sql -rw-r--r--. 1 1001 1001 1978341 Jul 30 19:41 images.sql -rw-r--r--. 1 1001 1001 134791 Jul 30 19:41 schema.sql [root@zabbix mysql]# scp * root@192.168.75.251:/opt/
下面在mysql(192.168.75.251)服務(wù)器上操作
#mysql -u root –p
Enter password:
創(chuàng)建zabbix數(shù)據(jù)庫(kù),字符集設(shè)置為utf8
mysql>create database zabbix character set utf8 collate utf8_bin;
在mysql數(shù)據(jù)庫(kù)中創(chuàng)建zabbix用戶(hù),賦予zabbix用戶(hù)對(duì)zabbix數(shù)據(jù)庫(kù)的全部權(quán)限,允許zabbix服務(wù)器遠(yuǎn)程訪問(wèn)mysql
mysql>GRANT ALL PRIVILEGES ON zabbix.* TO zabbix@192.168.75.250IDENTIFIED BY 'zabbix'; mysql>GRANT ALL PRIVILEGES ON zabbix.* TO zabbix@localhost IDENTIFIED BY 'zabbix'; mysql>flush privileges; mysql>show databases ; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | | zabbix | +--------------------+ 5 rows in set (0.00 sec)
導(dǎo)入數(shù)據(jù)文件,在控制臺(tái)操作
#mysql -u zabbix -p zabbix2.3zabbix web部署
回到Zabbix Server主機(jī)操作。在上面已經(jīng)安裝好httpd , 創(chuàng)建apache下創(chuàng)建zabbix目錄
mkdir /var/www/html/zabbix
拷貝zabbix包中的web界面到apache zabbix目錄下
\cp–rf /opt/soft/zabbix-3.4.12/frontends/php/* /var/www/html/zabbix/配置web安全
chown -R apache.apache /var/www/html/zabbix chmod a+x /var/www/html/zabbix/conf/拷貝zabbix包中服務(wù)啟動(dòng)腳本(server/agentd)到linux系統(tǒng)服務(wù)啟動(dòng)目錄
cp /opt/soft/zabbix-3.4.12/misc/init.d/fedora/core/zabbix_server zabbix_agentd/etc/init.d/修改/etc/init.d/zabbix_server和/etc/init.d/zabbix_agentd
BASEDIR=/usr/local修改成 BASEDIR=/usr/local/zabbix/設(shè)置開(kāi)機(jī)啟動(dòng)
systemctl enable httpd systemctl enable zabbix_server systemctl enable zabbix_agentd /etc/init.d/zabbix_server start /etc/init.d/zabbix_agentd start systemctl start httpd2.4web服務(wù)初始化
http://192.168.75.250/zabbix/setup.php
連接數(shù)據(jù)庫(kù)設(shè)置,寫(xiě)mysql服務(wù)器所在機(jī)器,端口,數(shù)據(jù)庫(kù)名稱(chēng),用戶(hù)、密碼
三、安裝Zabbix Proxy
首先,在proxy機(jī)器上安裝mysql ,跟上面的安裝步驟一樣,只是在導(dǎo)入mysql文件時(shí),只導(dǎo)入一個(gè)文件,
#mysql–uzabbix –p zabbix
安裝依賴(lài)包
yum -y install gcc* make curl curl-devel net-snmp net-snmp-devel perl-DBI httpd mariadb* mysql-devel libxml2-devel curl-devel unixODBC-devel net-snmp-devel OpenIPMI-devel openldap openldap-devel libevent-develjava-devellibssh3-devel創(chuàng)建zabbix用戶(hù)和組
groupadd zabbix useradd -g zabbix zabbix編譯、安裝
tar zxvf zabbix-3.4.12.tar.gz cd zabbix-3.4.12/ ./configure --prefix=/opt/server/zabbix_proxy--enable-proxy --enable-agent --enable-ipv6 --with-mysql --with-net-snmp --with-libcurl --with-openipmi --with-unixodbc --with-ldap --with-ssh3 --enable-java make && make install chown -R zabbix.zabbix /opt/server/zabbix_proxy配置文件修改
Vi /usr/local/zabbix/etc/zabbix_proxy.conf Server=192.168.75.250 ServerPort=10051 Hostname=zabbix_proxy LogFile=/tmp/zabbix_proxy.log DBHost=localhost#因?yàn)閙ysql和proxy安裝在同一臺(tái)機(jī)器 DBName=zabbix DBUser=zabbix DBPassword=zabbix DBSocket=/var/mysql/mysql.sock ConfigFrequency=60 DataSenderFrequency=60 StartPollers=5 Timeout=4 LogSlowQueries=3000啟動(dòng)proxy(要加入到開(kāi)機(jī)自啟)
#/opt/server/zabbix_proxy/sbin/zabbix_proxy-c /opt/server/zabbix_proxy/etc/zabbix_proxy.conf systemctl enable zabbix_proxy四、啟動(dòng)zabbix_agentd客戶(hù)端
同上,編譯安裝zabbix時(shí),客戶(hù)端也一起編譯了,把/usr/local 下面的zabbix目錄拷貝到客戶(hù)端,
修改配置文件
vi /usr/local/zabbix/etc/zabbix_agentd.conf Server=zabbix_proxy_IP #建議所以客戶(hù)端都掛在proxy上,擴(kuò)展性強(qiáng) Hostname=zabbix_agentd_hostname #填寫(xiě)客戶(hù)端的主機(jī)名啟動(dòng)(要加入到開(kāi)機(jī)自啟)
/usr/local/zabbix/sbin/zabbix_agentd-c /usr/local/zabbix/etc/zabbix_agentd.conf echo "/usr/local/agent/sbin/zabbix_agentd -c /usr/local/agent/etc/zabbix_agentd.conf" >> /etc/rc.local五、Web管理
添加監(jiān)控主機(jī)
選擇主機(jī)監(jiān)控模版
主機(jī)監(jiān)控成功
以上是“Zabbix如何安裝部署”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對(duì)大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!
文章題目:Zabbix如何安裝部署
網(wǎng)站URL:http://weahome.cn/article/iidisi.html