eam8 发表于 2019-11-2 22:06

Debian10下安装zabbix

什么是zabbix?
Zabbix 是由Alexei Vladishev 开发的一种网络监视、管理系统,基于 Server-Client 架构。可用于监视各种网络服务、服务器和网络机器等状态。Zabbix 使用 MySQL、PostgreSQL、SQLite、Oracle 或 IBM DB2 储存资料。


安装完系统后,进行一次更新检查
root@www:~#apt update
root@www:~#apt upgrade安装配置apache

root@www:~# apt -y install apache2

root@www:~# nano /etc/apache2/conf-enabled/security.conf
# 更改第25行

ServerTokens Prod

root@www:~# nano /etc/apache2/mods-enabled/dir.conf
# 第2行更改

DirectoryIndex index.html index.htm

root@www:~# nano /etc/apache2/apache2.conf
# 第70行添加服务名

ServerName www.leam.ml

root@www:~# nano /etc/apache2/sites-enabled/000-default.conf
# 第11行更改管理员邮箱

ServerAdmin webmaster@leam.ml

重启apache
root@www:~# systemctl restart apache2 通过http://(你的域名 or 服务器IP 地址)就可以访问,看到基本页面了。

安装php和扩展
root@www:~# apt -y install php php-cgi libapache2-mod-php php-common php-pear php-mbstring

root@www:~# a2enconf php7.3-cgi

Enabling conf php7.3-cgi.
To activate the new configuration, you need to run:
systemctl reload apache2

root@www:~# nano /etc/php/7.3/apache2/php.ini
# 更改第960行:设置你所在的时区

date.timezone = "Asia/Shanghai"

root@www:~# systemctl restart apache2

root@www:~# nano/var/www/html/index.php
输入以下信息:

<?php

phpinfo();

?>安装mysql数据库
root@www:~# apt -y install mariadb-server 初始化数据库
root@www:~# 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):
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
New 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
... 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
... 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
- 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
... 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@www:~# mysql -u root -p

Enter password:   # root password you set
Welcome to the MariaDB monitor.Commands end with ; or \g.
Your MariaDB connection id is 55
Server version: 10.3.15-MariaDB-1 Debian 10

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

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

# show user list
MariaDB [(none)]> select user,host,password from mysql.user;
+------+-----------+-------------------------------------------+
| user | host      | password                                  |
+------+-----------+-------------------------------------------+
| root | localhost | ***************************************** |
+------+-----------+-------------------------------------------+
1 row in set (0.00 sec)

# show database list
MariaDB [(none)]> show databases;
+--------------------+
| Database         |
+--------------------+
| information_schema |
| mysql            |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)

# logout
MariaDB [(none)]> exit
Bye

安装zabbix4
root@www:~# wget https://repo.zabbix.com/zabbix/4.0/debian/pool/main/z/zabbix-release/zabbix-release_4.0-3+buster_all.deb

root@www:~# dpkg -i zabbix-release_4.0-3+buster_all.deb

Selecting previously unselected package zabbix-release.
(Reading database ... 32617 files and directories currently installed.)
Preparing to unpack zabbix-release_4.0-3+buster_all.deb ...
Unpacking zabbix-release (1:4.0-3+buster) ...
Setting up zabbix-release (1:4.0-3+buster) ...

root@www:~# apt update
root@www:~# apt -y install zabbix-server-mysql zabbix-agent zabbix-frontend-php php-mysql php-gd php-xml-util php-bcmath php-net-socket php-gettext
创建zabbix数据库文件,用户名zabbix和密码password请自行定义root@www:~# mysql

Welcome to the MariaDB monitor.Commands end with ; or \g.
Your MariaDB connection id is 55
Server version: 10.3.15-MariaDB-1 Debian 10

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 zabbix;
Query OK, 1 row affected (0.00 sec)

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

MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@'%' identified by '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
导入zabbix数据
root@www:~# cd /usr/share/doc/zabbix-server-mysql*/

root@www:/usr/share/doc/zabbix-server-mysql# gzip -d create.sql.gz

root@www:/usr/share/doc/zabbix-server-mysql# mysql zabbix < create.sql
配置和启动 Zabbix Server
root@www:~# vi /etc/zabbix/zabbix_server.conf
# 第100行: 数据库名

DBName=zabbix
# 第116行: 连接数据库的用户名

DBUser=zabbix
# 第124行: 连接数据库的密码

DBPassword=password

重新启动 zabbix-server
root@www:~# systemctl restart zabbix-server


root@www:~# nano /etc/zabbix/zabbix_agentd.conf
#第150行: 更改为被监控的主机名

Hostname=leam.ml
root@www:~# systemctl restart zabbix-agent
配置并启动Zabbix代理
root@www:~# vi /etc/apache2/conf-enabled/zabbix.conf
# 第10行: 如果有需要,可以更改指定ip访问

#
Allow from all
Allow from 10.0.0.10/24

重启apache
root@www:~# systemctl restart apache2

然后通过网址进行zabbix配置:

http://(服务器网址 或者 ip地址)/zabbix/setup.php


网页安装就不再累赘,安装后如果出错,可以重复上面的网址打开再安装配置。


页: [1]
查看完整版本: Debian10下安装zabbix