Centos7安裝zabbix2.4並進行初始化配置
##騰訊雲實驗室Centos7安裝zabbix2.4(金測試OK)##
#說明:騰訊雲實驗室的yum源提供的是zabbix2.4版的安裝包。
#文件中的紅字程式碼是必須執行的操作。
#關閉防火牆和selinux
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
getenforce
#安裝基礎元件(centos7)
yum install -y gcc gcc-c++
yum install -y httpd mariadb mariadb-server php php-gd php-mysql php-bcmath php-mbstring php-xml curl curl-devel net-snmp net-snmp-devel perl-DBI
yum install -y mariadb-devel curl elinks lynx mlocate
#啟動httpd和mariadb服務
echo `ServerName web01` > /etc/httpd/conf.d/srv.conf
echo `<?php phpinfo() ?>` >/var/www/html/p.php
service httpd restart
service mariadb restart
chkconfig httpd on
chkconfig mariadb on
elinks 127.0.0.1/p.php
==============================
#建立apache與php相關的配置
cat > /etc/httpd/conf.d/zabbix_cf.conf <<-EOF
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 Europe/Riga
php_value date.timezone Asia/Shanghai
EOF
service httpd restart
==============================
#配置資料庫
mysql -u root -e “create database zabbix character set utf8 collate utf8_bin;show databases;”
#mysql -u root -e “insert into mysql.user(Host,User,Password) values(`localhost`,`zabbix`,password(`zabbix`));”
mysql -u root -e “grant all on *.* to admin@`%` identified by `admin` with grant option;flush privileges;”
mysql -u root -e “grant all on zabbix.* to zabbix@`%` identified by `zabbix`;flush privileges;”
mysql -u root -e “grant all on zabbix.* to zabbix@`127.0.0.1` identified by `zabbix`;flush privileges;”
mysql -u root -e “grant all on zabbix.* to zabbix@`localhost` identified by `zabbix`;flush privileges;”
mysql -u root -e “select user,host,password from mysql.user;flush privileges;”
#zabbix的安裝和配置
##安裝方法一:測試OK的安裝方法##
zabbix官方安裝手冊:https://www.zabbix.com/documentation/3.2/manual/installation/install_from_packages/server_installation_with_mysql
1.官方文件地址:
https://www.zabbix.com/documentation/3.2/manual/installation/install_from_packages
2.匯入源:
centos7的zabbix2.4官方yum源:
rpm -ivh http://repo.zabbix.com/zabbix/2.4/rhel/7/x86_64/zabbix-release-2.4-1.el7.noarch.rpm
centos7的zabbix3官方yum源:
rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
==========================
centos6的zabbix2.4官方yum源:
rpm -ivh http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-1.el6.noarch.rpm
centos6的zabbix3官方yum源:
rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/6/x86_64/zabbix-release-3.0-1.el6.noarch.rpm
==========================
3.查zabbix軟體
yum search zabbix
4.安裝zabbix服務端和客戶端。
yum install -y zabbix-server-mysql zabbix-web-mysql zabbix-agent
說明:zabbix-server是伺服器端(管理主控端)。
zabbix-agent是客戶端(管理被控端)。
zabbix-web是zabbix的網站管理平臺。
zabbix-*-mysql是zabbix的資料庫。
5.匯入資料庫。
方法一:首選方法。
updatedb
locate images.sql
cd $(dirname $(locate images.sql))
cd $(dirname $(locate create.sql.gz))
mysql -e “create database zabbix character set utf8 collate utf8_bin;show databases;”
mysql -e “grant all on zabbix.* to zabbix@localhost identified by `zabbix`;”
mysql -e “grant all on *.* to admin identified by `zabbix` with grant option;”
mysql -e “select user,host,password from mysql.user;flush privileges;”
zcat create.sql.gz | mysql -uroot zabbix
方法二:備選方法。
updatedb
locate images.sql
cd $(dirname $(locate images.sql))
cd $(dirname $(locate create.sql.gz))
mysql -u root -e “create database zabbix character set utf8;show databases;”
mysql -u root zabbix < schema.sql
mysql -u root zabbix < images.sql
mysql -u root zabbix < data.sql
方法三:zabbix-3.2原始碼包安裝時匯入資料的方法。
updatedb
locate images.sql
cd $(dirname $(locate images.sql))
cd $(dirname $(locate create.sql.gz))
zcat /usr/share/doc/zabbix-server-mysql-3.2.*/create.sql.gz | mysql -uzabbix -pzabbix zabbix
6、修改zabbix配置檔案。
# vi /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=資料庫密碼
說明:配置檔案中只需要修改DB相關的配置就能正常使用了。(金測OK)
驗證配置檔案:grep -Env `^#|^$` /etc/zabbix/zabbix_server.conf
#檢視內容如下:
30:LogFile=/var/log/zabbix/zabbix_server.log
41:LogFileSize=0
63:PidFile=/var/run/zabbix/zabbix_server.pid
72: DBHost=localhost
82:DBName=zabbix
98:DBUser=zabbix
106: DBPassword=zabbix
115:DBSocket=/var/lib/mysql/mysql.sock
272:SNMPTrapperFile=/var/log/snmptt/snmptt.log
435:AlertScriptsPath=/usr/lib/zabbix/alertscripts
445:ExternalScripts=/usr/lib/zabbix/externalscripts
7、重啟zabbix服務端,設定為開機啟動。(金測OK)
systemctl restart zabbix-server
systemctl enable zabbix-server
systemctl restart zabbix-agent
systemctl enable zabbix-agent
netstat -atunlp|grep zabbix 檢視到有10050、10051埠的程式就說明服務正常
#建立apache與php相關的配置(如果已做了,可以不用再做)
cat > /etc/httpd/conf.d/zabbix_cf.conf <<-EOF
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 Europe/Riga
php_value date.timezone Asia/Shanghai
EOF
service httpd restart
#關閉SELinux:
a、臨時關閉(不用重啟機器):
# setenforce 0 ##設定SELinux 成為permissive模式 (關閉SELinux)
# setenforce 1 ##設定SELinux 成為enforcing模式 (開啟SELinux)
b、修改配置檔案需要重啟機器:
# vi /etc/selinux/config
將SELINUX=enforcing 改為SELINUX=disabled
需重啟機器
#(選做)安裝php-bcmath和php-mbsting
#方法一:
yum install -y php-bcmath php-mbstring
#方法二:
cd /root
rpm -ivh php-bcmath-5.4.16-42.el7.x86_64.rpm
rpm -ivh php-mbstring-5.4.16-42.el7.x86_64.rpm
#安裝web介面
#systemctl restart httpd.service
在瀏覽器中輸入http://127.0.0.1/zabbix進入zabbix的web配置頁面=====》
(如全部OK)NEXT=====》
配置MySQL資料庫資訊,並點選“Test connection”按鍵,如OK====》NEXT=====》
預設,直接NEXT=====》
預設,直接NEXT=====》出現錯誤,提示Fail(忘截圖了)
Configuration file”/var/www/html/zabbix/conf/zabbix.conf.php”
created: Fail
Unable to create the configuration file.Please install it manually, or fix permissions on the conf directory.
Press the “Download configuration file” button, download the configuration file and save it as”/var/www/html/zabbix/conf/zabbix.conf.php”When done, press the “Retry” button
=====》按提示點選“Download configuration file”按鈕,並將下載的zabbix.conf.php儲存到
/var/www/html/zabbix/conf/下,點選“Retry”按鈕重試=====》
顯示OK,點選“Finish”按鈕完成安裝操作。
Zabbix的預設賬號為Admin,密碼為zabbix。
zabbix預設是英文版,更改語言======》Profile
======》在Language中選擇zh_CN,點選Update
=====》已更改為漢語
##新增開機啟動指令碼
cd /root
cd zabbix-2.4.8/
cp -v misc/init.d/fedora/core5/zabbix_server /etc/rc.d/init.d/zabbix_server
cp -v misc/init.d/fedora/core5/zabbix_server /etc/rc.d/init.d/zabbix_agentd
chmod u+x /etc/rc.d/init.d/zabbix_server
chmod u+x /etc/rc.d/init.d/zabbix_agentd
chkconfig zabbix_server on
chkconfig zabbix_agentd on
/usr/local/zabbix/sbin/zabbix_server start
/usr/local/zabbix/sbin/zabbix_agentd start
本文轉自rshare 51CTO部落格,原文連結:http://blog.51cto.com/1364952/1957670,如需轉載請自行聯絡原作者
相關文章
- CentOS7安裝Docker並配置映象加速CentOSDocker
- Docker安裝mysql映象並進行主從配置DockerMySql
- CentOS7上安裝並配置Nginx、PHP、MySqlCentOSNginxPHPMySql
- 安裝ZABBIX2.4全步驟~~~
- centos7 yum下載並安裝jdk並配置環境變數CentOSJDK變數
- 使用滴滴雲DC2,在CentOS7安裝Redis並進行安全加固CentOSRedis
- Centos7 安裝配置MysqlCentOSMySql
- Centos7 安裝配置NFSCentOSNFS
- centos7安裝社群版docker並配置阿里雲映象加速CentOSDocker阿里
- Centos7上進行ftp配置CentOSFTP
- CentOS7 sudo 安裝與配置CentOS
- centos7下cobbler安裝配置CentOS
- CentOS7 安裝配置 GitLabCentOSGitlab
- CentOS7 安裝 配置網路CentOS
- Centos7安裝配置Hive教程。CentOSHive
- Centos7下安裝配置RedsocksCentOS
- MongoDB之安裝並配置MongoDB
- 安裝並配置goldengateGo
- 在 CentOS6 上安裝 Zabbix2.4 ServerCentOSServer
- Centos7下安裝配置elasticsearch 6.3.1CentOSElasticsearch
- centos7安裝配置禪道7.3CentOS
- zabbix docker - 安裝和初始化配置Docker
- Windows 安裝並配置 MySQL 5.6WindowsMySql
- CentOS7 下 Nginx 的安裝和配置CentOSNginx
- CentOS7安裝完之後的配置CentOS
- CentOS7下RabbitMQ服務安裝配置CentOSMQ
- CentOS7安裝配置vsftp搭建FTPCentOSFTP
- [轉載] centos7 安裝和配置vncserverCentOSVNCServer
- Centos7下安裝配置MySQL5.7CentOSMySql
- CentOS7 切換阿里映象源並安裝 dockerCentOS阿里Docker
- VMware安裝映象Centos7,並連線XshellCentOS
- Centos7 離線安裝 KVM,並安裝 Csr1000vCentOS
- docker 安裝 nginx 並配置反向代理DockerNginx
- 快速安裝配置 GitLab 並漢化Gitlab
- linux配置multipath 並安裝racLinux
- centos7 安裝 ElasticSearch 配置外網訪問CentOSElasticsearch
- centos7上keepalived的安裝和配置CentOS
- centos7 hadoop 單機模式安裝配置CentOSHadoop模式