2019年10月1日 星期二

在 Red Hat Enterprise Linux/CentOS 7 上安裝 Zabbix Server 4.2


Install Zabbix 4.2 在 RHEL7 

常見的開源監控軟體,有Zabbix、Nagios、Prometheus.......。
其中 Zabbix Server非常容易安裝,參考原廠安裝手冊,以下分享整個安裝過程與詳細指令。一個小時內可以完成安裝設定。




安裝元件介紹

使用標準的LAMP組合


  1. RHEL7
  2. Apache
  3. MySQL (Mariadb 5.5)
  4. PHP
  5. zabbix-4.2-2.el7 rpm pacakge


關閉Linux防火牆

systemctl stop firewalld
systemctl disable firewalld

SELinux

To do this edit the "/etc/selinux/config" file, making sure the SELINUX flag is set as follows.
If SELinux is configured after installation, the server will need a reboot for the change to take effect.

SELINUX=permissive

getenforce
setenforce permissive
getenforce

Frontend installation prerequisites

Zabbix frontend requires additional packages not available in basic installation. You need to enable repository of optional rpms in the system you will run Zabbix frontend on:

ll /etc/yum.repos.d/
vi public-yum-ol7.repo

[root@aot-zbx02 yum.repos.d]# vi public-yum-ol7.repo
[ol7_optional_latest]
name=Oracle Linux $releasever Optional Latest ($basearch)
baseurl=https://yum.oracle.com/repo/OracleLinux/OL7/optional/latest/$basearch/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
gpgcheck=1
enabled=1


安裝MariaDB

yum repolist
yum list mariadb*
yum install mariadb*


安裝 php, httpd

yum install nmap httpd policycoreutils-python net-snmp net-snmp-utils php-bcmath php-mbstring php-xml curl curl-devel net-snmp-devel perl-DBI
yum install php php-gd php-ldap php-mysql php-odbc php-pdo php-pear php-pecl-memcache php-soap php-xmlrpc


Start MariaDB

systemctl start mariadb
systemctl enable mariadb
systemctl status mariadb


修改資料庫root密碼 (選用)

mysqladmin -uroot password 1234qwer


Adding Zabbix repository

rpm -Uvh http://repo.zabbix.com/zabbix/4.2/rhel/7/x86_64/zabbix-release-4.2-2.el7.noarch.rpm


Install Zabbix Server, Zabbix Forntend and Zabbix Agent

yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent


Creating database

MySQL - Character set utf8 and utf8_bin collation is required for Zabbix server to work properly with MySQL database.

mysql -uroot
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';


Importing data

zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -pzabbix zabbix

mysql -uzabbix -pzabbix zabbix

mysql> SELECT
table_name AS `Table`,
round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB`
FROM information_schema.TABLES
WHERE table_schema = "zabbix";


Configure database for Zabbix server

vi /etc/zabbix/zabbix_server.conf

LogFileSize=10
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix


Starting Zabbix server process

systemctl start zabbix-server
systemctl enable zabbix-server
systemctl status zabbix-server


Zabbix frontend configuration

For RHEL 7 and later the Apache configuration file for Zabbix frontend is located in /etc/httpd/conf.d/zabbix.conf.

vi /etc/httpd/conf.d/zabbix.conf

        # php_value date.timezone Europe/Riga
        php_value date.timezone Asia/Taipei


systemctl start httpd
systemctl enable httpd


Frontend installation steps 

Allow you to access your newly installed Zabbix.
Note that a Zabbix proxy does not have a frontend; it communicates with Zabbix server only.

http://zabbix-frontend-hostname/zabbix

Enter password of zabbix




Configure and start Zabbix Agent


vi /etc/zabbix/zabbix_agentd.conf
LogFileSize=10
Server=127.0.0.1
ServerActive=127.0.0.1
Hostname=Zabbix server


systemctl start zabbix-agent
systemctl status zabbix-agent
systemctl enable zabbix-agent


All jobs are completed 


Zabbix frontend is available at http://zabbix-frontend-hostname/zabbix in the browser. Default username/password is Admin/zabbix.



參考資訊~~原廠手冊 

https://www.zabbix.com/documentation/4.2/manual/installation/install_from_packages/rhel_centos

沒有留言:

張貼留言