Thứ Hai, 26 tháng 6, 2017

Cài đặt Zabbix 3 trên CentOS 7.x / RHEL 7.x


Cài đặt Zabbix 3 trên CentOS 7.x / RHEL 7.x


Zabbix là một công cụ giám sát miễn phí và mã nguồn mở được sử dụng để giám sát, theo dõi và hiệu suất của máy chủ, thiết bị mạng và tài sản CNTT khác trong hệ thống.
Zabbix sử dụng cơ sở dữ liệu như MySQL, MariaDB, Oracle và IBM DB2 để lưu trữ dữ liệu của nó. giao diện web Zabbix được viết bằng PHP.
Zabbix có giao diện rất dễ sử đẹp và rất dễ sử dụng.
Zabbix hỗ trợ người dùng tùy biến sâu các đối tượng cần theo dõi.
Để theo dõi một đối tượng mà zabbix không hỗ trợ sẵn thì có thể tùy chỉn bằng userparameter trong /etc/zabbix/zabbix_agentd.d.

MỘT SỐ TÍNH NĂNG NỖI BẬT CỦA ZABBIX 3

  • Giám sát tất cả mọi thứ trên mạng như máy chủ, ứng dụng, cơ sở dữ liệu và các thiết bị mạng.
  • Zabbix cung cấp giao diện quản trị web.
  • Giám sát sử dụng CPU của một quá trình cụ thể hoặc một nhóm các quá trình (proc.cpu.util)
  • Sử dụng quy tắc phát hiện ở low-level, zabbix có thể khám phá VMware hypervisor (ESXi) và máy ảo.
  • Zabbix cũng hỗ trợ giám sát agentless
  • Giám sát các máy chủ cơ sở dữ liệu như MySQL, PostgreSQL, Oracle và Microsoft SQL Server.
  • Zabbix cũng có thể thực hiện các nhiệm vụ quy hoạch năng lực cho môi trường của bạn.
  • Zabbix là nguồn mở nên không có chi phí liên quan và có thể được triển khai trên môi trường nhỏ và lớn.
  • Giám sát phần cứng sử dụng Zabbix qua thông tin IPMI.
  • Giám sát thiết bị mạng sử dụng SNMP
Trong bài viết này chúng tôi sẽ cài đặt phiên bản mới nhất của Zabbix 3.0 trên CentOS 7.x và RHEL 7.x với DB là MariaDB. Dưới đây là các chi tiết cài đặt Zabbix:
  • Hostname = zabbix.skyatc.com
  • Địa chỉ IP = 192.168.1.10
  • OS = CentOS 7.x / RHEL 7.x
Trước khi bắt đầu cài đặt, đầu tiên cập nhật hệ thống của bạn bằng cách sử dụng dưới đây lệnh:
[root@zabbix ~]# yum -y update

setsebool -P httpd_can_connect_zabbix = 1

[root@zabbix ~]# reboot

BƯỚC 1: BẬT EPEL VÀ ZABBIX REPOSITORY

Zabbix gói không có sẵn trong kho yum mặc định, vì vậy chúng tôi sẽ cài zabbix từ kho EPEL. Sử dụng lệnh dưới:
[root@zabbix ~]# yum install epel-release

[root@zabbix ~]#rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-1.el7.noarch.rpm

Bước 2: Cài đặt Zabbix Server, Database, Web Server và các gói PHP

Sử dụng các lệnh dưới đây để cài đặt gói rpm của máy chủ Zabbix, Cơ sở dữ liệu Sever (MariaDB), Web Server (HTTP) và PHP.
[root@zabbix ~]# yum -y install firewalld zabbix-server-mysql zabbix-web-mysql mysql mariadb-server httpd php

Bước: 3: Cấu hình Cơ sở dữ liệu cho Zabbix.

[root@zabbix ~]# systemctl start mariadb

[root@zabbix ~]# systemctl enable mariadb
Thiết lập cài đặt cho MariaDB

[root@zabbix ~]# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
 SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

# Enter
Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

# set root password
Set root password? [Y/n] y 
New password: # set any password
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.

# remove anonymous users
Remove anonymous users? [Y/n] y 
 ... Success!

Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.

# disallow root login remotely
Disallow root login remotely? [Y/n] y 
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.

# remove test database
Remove test database and access to it? [Y/n] y 
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

# reload privilege tables
Reload privilege tables now? [Y/n] y 
 ... Success!

Cleaning up...

All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!
[root@zabbix ~]
Cấu hình DB cho Zabbix trên MariaDB
[root@zabbix ~]# mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 5.5.47-MariaDB MariaDB Server

Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> create database zabbix;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by <new_password>;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> exit
Bye
[root@zabbix ~]
Import DB của Zabbix vào MariaDB
[root@zabbix ~]# cd /usr/share/doc/zabbix-server-mysql-3.0.1
[root@zabbix zabbix-server-mysql-3.0.1]# gunzip create.sql.gz
[root@zabbix zabbix-server-mysql-3.0.1]# mysql -u root -p zabbix < create.sql
Enter password:
[root@zabbix ~]

BƯỚC 4: CHỈNH SỬA FILE CẤU HÌNH DB CỦA ZABBIX

Chỉnh sửa tập tin cấu hình Zabbix Server ( /etc/zabbix/zabbix_server.conf ) và ghi rõ tên cơ sở dữ liệu cho zabbix, tên người sử dụng cơ sở dữ liệu và mật khẩu của mình.
[root@zabbix ~]# vi /etc/zabbix/zabbix_server.conf
...................................
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=XXXXXXX
...................................
Lưu và thoát khỏi các tập tin.
Cấu hình PHP Setting
Thiết lập các thông số dưới đây trong tập tin cấu hình PHP (/etc/php.ini)
[root@zabbix ~]# vi /etc/php.ini
................................
max_execution_time = 600
max_input_time = 600
memory_limit = 256M
post_max_size = 32M
upload_max_filesize = 16M
date.timezone =  Asia/Ho_Chi_Minh
...............................

Cho phép các port trong tường lửa
[root@zabbix ~]# firewall-cmd --permanent --add-port=10050/tcp
success
[root@zabbix ~]# firewall-cmd --permanent --add-port=10051/tcp
success
[root@zabbix ~]# firewall-cmd --permanent --add-port=80/tcp
success
[root@zabbix ~]# firewall-cmd --reload 
success
[root@zabbix ~]# systemctl restart firewalld
[root@zabbix ~]#
Đặt quy tắc SELinux.
[root@zabbix ~]# setsebool -P httpd_can_connect_zabbix=1
[root@zabbix ~]#
Bắt đầu Zabbix và Web Server Service.
[root@zabbix ~]# systemctl start zabbix-server
[root@zabbix ~]# systemctl enable zabbix-server
ln -s '/usr/lib/systemd/system/zabbix-server.service' '/etc/systemd/system/multi-user.target.wants/zabbix-server.service'
[root@zabbix ~]# 
[root@zabbix ~]# systemctl start httpd
[root@zabbix ~]# systemctl enable httpd
ln -s '/usr/lib/systemd/system/httpd.service' '/etc/systemd/system/multi-user.target.wants/httpd.service'
[root@zabbix ~]#

Bước: 5 Duyệt các giao diện Web Zabbix sử dụng bên dưới URL

Thay thế địa chỉ IP hoặc tên máy theo thiết lập của bạn.
1

Nhấp vào ‘Next Step’
Mở Bước nàyZabbix Pre-requisites được kiểm tra và xác minh

2

* lưu ý với Apache >=2.4:

2.2 configuration:

Order deny,allow
Deny from all

2.4 configuration:

Require all denied
In this example, there is no authentication and all requests are allowed.

2.2 configuration:

Order allow,deny
Allow from all

2.4 configuration:

Require all granted
In the following example, there is no authentication and all hosts in the example.org domain are allowed access; all other hosts are denied access.

2.2 configuration:

Order Deny,Allow
Deny from all
Allow from example.org

2.4 configuration:

Require host example.org




Share This!


Không có nhận xét nào:

Đăng nhận xét