Tải bản đầy đủ (.docx) (26 trang)

Cài đặt trên zabbix server

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (1.16 MB, 26 trang )

Mơ Hình Thực Hiện

Cài đặt trên Zabbix Server
Bước 1: Vơ hiệu Selinux
Đầu tiên bạn kiểm tra xem selinux có đang tắt khơng, nếu đang bật thì bạn tắt đi nhé. Bạn
kiểm tra bằng lệnh sau sestatus . Nếu Disable thì thơi, cịn đang Enable thì bạn tắt bằng
cách sau.
vi /etc/sysconfig/selinux



Change SELINUX=enforcing to SELINUX=disabled
Bước 2: Cài đặt và cấu hình Apache
ạn thực hiện chạy các lệnh sau
Cài đặt httpd
yum -y install httpd



Start httpd
systemctl start httpd.service



Kích hoạt httpd khi khởi động
systemctl enable httpd.service



Kiểm tra trạng thái httpd
systemctl status httpd.service






Cấu hình các repo cần thiết
Cài đặt epel và remi repos
yum -y install epel-release -y
yum install -y
Bước 3: Cài đặt PHP
yum install php php-pear php-cgi php-common php-mbstring php-snmp php-gd php-peclmysql php-xml php-mysql php-gettext php-bcmath -y



Chỉnh sửa time Zone PHP tại file php.ini
vi /etc/php.ini
Bạn bỏ comment và chỉnh sửa như sau (data..timezone ở dòng 878)
date.timezone = Asia/Ho_Chi_Minh
Bước 4: Cài đặt MariaDB
Bạn chạy lệnh sau để cài đặt
yum --enablerepo=remi install mariadb-server -y



Start MariaDB
systemctl start mariadb.service



Kích hoạt MariaDB khi boot hệ thống
systemctl enable mariadb.service




Kiểm tra trạng thái MariaDB


systemctl status mariadb.service

Sau đó bạn chạy lệnh sau để cấu hình bảo mật MariaDB
mysql_secure_installation
Bạn chọn Y và thêm vào pass root mới cho MariaDB và tiếp tục, khi nhận thông báo bạn
cứ chọn Y hết nhé.
[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 current password for root (enter for none): <== Nhấn enter
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? [Y/n] y
New password: <== Nhập vào password mới
Re-enter new password: <== Nhập lại lần nữa
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? [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? [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 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 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!
Bước 5: Tạo Database cho Zabbix

Bạn thực hiện chạy các lệnh sau sau khi đăng nhập vào DB server
[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.64-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> create database nghiadeptrai CHARACTER SET UTF8 COLLATE
UTF8_BIN; ## lệnh tạo DB có tên là nghiadeptrai
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> create user 'zabbixuser'@'localhost' identified BY 'tdc111!!!'; ## Tạo
User DB
Query OK, 0 rows affected (0.01 sec)
MariaDB [(none)]> grant all privileges on nghiadeptrai.* to zabbixuser@localhost; ##
Gán quyền DB với DB User
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> grant all privileges on nghiadeptrai.* to ; ##
Gán quyền DB với DB User
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> quit; ## Nhấn để thoát
Bye



Bước 6: Cài đặt Zabbix và các gói liên quan

Bạn thực hiện chạy các lệnh sau
Thêm Zabbix repository bằng cách copy lệnh bên dưới và chạy
rpm -ivh />


Cài đặt Zabbix


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

Bước 7: Configure Zabbix
Thay đổi Time Zone trong cấu hình Zabbix Apache, bạn mở
file /etc/httpd/conf.d/zabbix.conf và sửa như sau.
Bạn umcomment Time Zone và sửa như sau.
php_value date.timezone Asia/Ho_Chi_Minh


Tiếp theo bạn truy cập vào thư mục sau /usr/share/doc/zabbix-server-mysql-4.0.31/ và
import MySQL.
Lưu ý: Tùy phiên bản mà chổ mình tơ đỏ sẽ khác, để chắc chắn bạn kiểm tra và truy cập
cho đúng nhé
zcat create.sql.gz | mysql -u zabbixuser -p nghiadeptrai

Sau khi import hoàn tất bạn bắt đầu chỉnh sửa cấu hình Database như sau
Mở file zabbix_server.conf tại đây
vi /etc/zabbix/zabbix_server.conf
Tại đây bạn tìm đến dịng số 91, 100, 116, 125 và thay đổi thơng số cấu hình mặc định
thành thơng tin database mà bạn đã tạo trước đó ở Bước 5
DBHost=localhost
DBName=nghiadeptrai

DBUser=zabbixuser
DBPassword=tdc111!!!


Sau khi chỉnh sửa hoàn tất bạn Restart lại dịch vụ Zabbix
Start Zabbix
systemctl start zabbix-server.service



Kích hoạt Zabbix khi boot
systemctl enable zabbix-server.service



Restart lại Zabbix
systemctl restart zabbix-server.service



Kiểm tra trạng thái
systemctl status zabbix-server.service


Nếu máy chủ có cấu hình firewalld thì bạn thực hiện thay đổi firewall rules như sau
firewall-cmd --add-service={http,https} –permanent
firewall-cmd --add-port={10051/tcp,10050/tcp} --permanent
firewall-cmd --reload
systemctl restart httpd
Bước 8: Setup Zabbix

Bây giờ bạn truy cập Zabbix tại trình duyệt với URL như sau


http://ip/zabbix hoặc http://server-host-name/zabbix
Ví dụ: http://192.168.1.1/zabbix


Tiếp tục chọn Next Step


Tại đây bạn nhập vào thông tin Database đã tạo ở Bước 5 và đã set trong file cấu hình ở
trên

Chổ Name bạn nhập tên vào


Tiếp tục nhấn Next Step

Thơng báo Setup hồn tất Zabbix



Cửa sổ đăng nhập bây giờ bạn hãy đăng nhập với thông tin mặc định là:
Username: Admin
Password: zabbix

*Lưu ý:
Trường hợp nếu không đăng nhập được mật khẩu hoặc quên mật khẩu ta có thể vào SQL
dùng lệnh để reset password
# mysql -u root –p

Mariadb [(none)]> use nghiadeptrai;


Mariadb [(none)]> select * from users;
Mariadb [(none)]> update zabbix.users set passwd=md5('mat_khau_moi')
where alias='Admin';

*Tạo mật khẩu md5:
echo -n pass123 | openssl md5
(stdin)= 32250170a0dca92d53ec9624f336ca24


Đây là cửa số quản trị.

Check Zabbix server Statistics :
Sau vài giây, bấm vào Tab Monitoring ở top menu bar và chọn “Latest data”.
Chọn Host Groups: Zabbix servers

Và chọn Apply. Bạn sẽ thấy những thông số chi tiết của Zabbix Server:


Để xem màn hình, Click vào Monitoring -> Screens từ Zabbix Dashboard :

Như vậy là chúng ta đã hoàn tất cấu hình cho Server. Cùng tiếp tục đi qua Client để cấu
hình.
Cấu hình Zabbix Agent trên máy Server Client:
Tiến hành Install Zabbix Agent
Để cài đặt gói Zabbix Agent trên client chạy Centos 7 Linux, nhập lệnh sau vào
Terminal:
rpm -Uvh />

yum install zabbix-agent -y


Cấu hình:
Edit file /etc/zabbix/zabbix_agentd.conf
vi /etc/zabbix/zabbix_agentd.conf
Thêm địa chỉ IP của server và hostname của client :
[...]
## Specify Zabbix's server IP address ##
Server=192.168.1.1 dòng 98
[...]
##Specify Zabbix's server IP address ##
ServerActive=192.168.1.1 dòng 139
## Specify client system hostname ##
Hostname=zabbixagent.nghiadeptrai.vn dịng 150
[...]
Trong đó :
192.168.1.1 : Địa chỉ IP của server Zabbix
zabbixagent : hostname của máy client

Cấu hình firewalld
firewall-cmd --zone=public --add-port=10050/tcp --permanent
firewall-cmd --reload


Restart service zabbix-agent bằng dòng lệnh :
#systemctl start zabbix-agent
#systemctl enable zabbix-agent
Thêm Monitoring cho Host :
Vào dashboard của Zabbix Server. Để add Target để monitor, vào Configuration -> Hosts.

Bấm vào Create Host ở phía bên phải.

Nhập vào Hostname, chọn Group và IP Address trong bảng bên dưới.

Tiếp theo, ở Templates chọn Template của bạn.
Ở đây máy mình cài dịch vụ FTP ; SSH ; ICMP ; Zabbix Agent ; HTTP.
Nên chọn:
Templates FTP Service
Templates App SSH Service
Templates App Zabbix Agent


Templates Module ICMP Ping
Templates App HTTP Service

Ở cửa sổ kế tiếp, chọn Add và Update
Bây giờ, bạn đã thấy Host mới được Add vào Monitoring list.

Nếu có bất cứ vấn đề gì xảy ra với hệ thống của client, bạn có thể xem chúng từ
Dashboard của Zabbix Server.
Đi đến Monitoring -> Latest data để kiểm tra chi tiết thông tin về máy.



Kiểm tra trạng thái FTP ( Up )

Xem dạng biểu đồ (Up)

Kiểm tra trạng thái FTP ( Down )



Kiểm tra trạng thái Zabbix Agent (Up)

Xem dạng biểu đồ (Up)

Kiểm tra trạng thái Zabbix Agent (Down)


Kiểm tra trạng thái ICMP(Up)

Xem dạng biểu đồ (Up)

Kiểm tra trạng thái ICMP(Down)

Xem dạng biểu đồ (Down)


Kiểm tra trạng thái HTTP (Up)

Xem dạng biểu đồ (Up)

Kiểm tra trạng thái HTTP (Down)


Kiểm tra trạng thái SSH(Up)

Xem dạng biểu đồ (Up)

Kiểm trạng thái SSH(Down)


Thông báo trên Dashboard (Trạng thái bị tắt)


Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×