192.168.247.142 server 安装zabbix-server提供监控服务,也可以安装agent监控自己
zabbix是一个高度集成的网络监控套件,通过一个软件包即可提供如下特性
①zabbix server
关闭网络管理器
[root@localhost ~]# hostnamectl set-hostname server
[root@localhost ~]# su
[root@server ~]#
[root@server ~]# systemctl stop NetworkManager
[root@server ~]# systemctl disable NetworkManager
Removed symlink /etc/systemd/system/multi-user.target.wants/NetworkManager.service.
Removed symlink /etc/systemd/system/dbus-org.freedesktop.NetworkManager.service.
Removed symlink /etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service.
[root@server ~]# setenforce 0
setenforce: SELinux is disabled
[root@server ~]# sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config
[root@server ~]# iptables -F
[root@nginx ~]# hostnamectl set-hostname client
[root@nginx ~]# su
[root@client ~]# systemctl stop NetworkManager
[root@client ~]# systemctl disable NetworkManager
Removed symlink /etc/systemd/system/multi-user.target.wants/NetworkManager.service.
Removed symlink /etc/systemd/system/dbus-org.freedesktop.NetworkManager.service.
Removed symlink /etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service.
[root@client ~]# setenforce 0
[root@client ~]# sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config
[root@client ~]# iptables -F
[root@client ~]#
具体的接下来会做演示
早几年前流行的监控是nagios
Nagios是一款开源的免费网络监视工具,能有效监控Windows、Linux和Unix的主机状态,交换机路由器等网络设备,打印机等。在系统或服务状态异常时发出邮件或短信报警第一时间通知网站运维人员,在状态恢复后发出正常的邮件或短信通知。
nagios的插件特别多,所以有的工程师会用cacti
Cacti是一套基于PHP,MySQL,SNMP及RRDTool开发的网络流量监测图形分析工具。
cacti的视觉感会更好一点
nagios的功能性会比较全,但是组件很多,麻烦
但自从zabbix的出现,就取代了nagios和cacti
zabbix是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案。
zabbix能监视各种网络参数,保证服务器系统的安全运营;并提供灵活的通知机制以让系统管理员快速定位/解决存在的各种问题。
zabbix由2部分构成,zabbix server与可选组件zabbix agent。
zabbix server可以通过SNMP,zabbix agent,ping,端口监视等方法提供对远程服务器/网络状态的监视,数据收集等功能,它可以运行在Linux,Solaris,HP-UX,AIX,Free BSD,Open BSD,OS X等平台上。
zabbix可以做分布式监控,依赖于proxy
要借助proxy去做分布式
zabbix监控的服务器有一个上限值,300-500,一般做300左右,
zabbix由两个部分构成,zabbix server与可选组件zabbix agent
zabbix agent 用来安装在被监控端
像普罗米修斯监控用来管理K8S
zabbix可以自动发现服务机制
4.0是用的最稳定版本
5.0 2020年才推出
lts指的是测试
4.4跟4.0没有区别
阿里云平台可以选择postgreSQL
5.0可以支持nginx
这种浏览模式用到的是异步刷新,ajax,把下面的做了一个div块,是前端的一个技术
php72w-mysql是驱动,让php可以去找mysql进行增删改查
中间也会加一个中间件redis,在与其他组件进行交互时,会增加一个kafka,rabbitmq
client作为被监控端
[root@server ~]# yum install wget -y
[root@server ~]# wget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
--2020-05-21 20:43:23-- http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
Resolving nginx.org (nginx.org)... 62.210.92.35, 95.211.80.227, 2001:1af8:4060:a004:21::e3
Connecting to nginx.org (nginx.org)|62.210.92.35|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4680 (4.6K) [application/x-redhat-package-manager]
Saving to: ‘nginx-release-centos-7-0.el7.ngx.noarch.rpm’
100%[===============================================================================================>] 4,680 2.63KB/s in 1.7s
2020-05-21 20:43:25 (2.63 KB/s) - ‘nginx-release-centos-7-0.el7.ngx.noarch.rpm’ saved [4680/4680]
[root@server ~]# ls
anaconda-ks.cfg nginx-release-centos-7-0.el7.ngx.noarch.rpm
[root@server ~]# vim /etc/yum.conf
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=1
[root@server ~]# cd /var/cache/yum/$basearch/$releasever
[root@server yum]# ls
x86_64
[root@server yum]# cd x86_64/
[root@server x86_64]# ls
7
[root@server x86_64]# cd 7/
[root@server 7]# ls
base docker-ce-stable extras timedhosts timedhosts.txt updates
[root@server 7]# pwd
/var/cache/yum/x86_64/7
手动创建nginx yum安装源
[root@server 7]# vim /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1
[root@server 7]# yum list
[root@server 7]# yum install nginx -y
Installed:
nginx.x86_64 1:1.18.0-1.el7.ngx
Complete!
[root@server 7]# systemctl start ngginx
Failed to start ngginx.service: Unit not found.
[root@server 7]# systemctl start nginx
[root@server 7]# systemctl enable nginx
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
[root@server 7]# netstat -natp | grep nginx
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 125691/nginx: maste
[root@server 7]# yum install mariadb mariadb-server -y
[root@server 7]# systemctl enable mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@server 7]# systemctl start mariadb
[root@server 7]# netstat -natp | grep 3306
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 128096/mysqld
初始化数据库
[root@server 7]# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
Enter current password for root (enter for none): //回车
OK, successfully used password, moving on...
Set root password? [Y/n] y
New password: 123123
Re-enter new password: 123132
Password updated successfully!
Reloading privilege tables..
... Success!
Remove anonymous users? [Y/n] n
... skipping.
Disallow root login remotely? [Y/n] n
... skipping.
Remove test database and access to it? [Y/n] n
... skipping.
Reload privilege tables now? [Y/n] y
... Success!
Cleaning up...
Thanks for using MariaDB!
本地验证登录数据库
[root@server 7]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 6
Server version: 5.5.65-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)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)
MariaDB [(none)]> quit
Bye
[root@server ~]# rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
#或者yum install epel-release -y
Retrieving https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
warning: /var/tmp/rpm-tmp.ooODVn: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:epel-release-7-12 ################################# [100%]
[root@server ~]# ll /etc/yum.repos.d/ #此时增加epel*.repo
-rw-r--r-- 1 root root 1050 Sep 18 2019 epel.repo
-rw-r--r-- 1 root root 1149 Sep 18 2019 epel-testing.repo
[root@server ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
Retrieving https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
warning: /var/tmp/rpm-tmp.CrKvHr: Header V4 RSA/SHA1 Signature, key ID 62e74ca5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:webtatic-release-7-3 ################################# [100%]
[root@server ~]# ll /etc/yum.repos.d/ #增加webtatic*.rpeo
-rw-r--r-- 1 root root 963 Oct 9 2014 webtatic-archive.repo
-rw-r--r-- 1 root root 865 Oct 9 2014 webtatic.repo
-rw-r--r-- 1 root root 963 Oct 9 2014 webtatic-testing.repo
php72w php
php72w-devel php的开发工具包
php72w-fpm php的fpm接收动态模块
php72w-gd php的处理图片的扩展库
php72w-mbstring php的扩展多字节
php72w-mysql php连接mysql的组件
[root@server ~]# yum install -y php72w php72w-devel php72w-fpm php72w-gd php72w-mbstring php72w-mysql
查看php版本
[root@server ~]# php -v
PHP 7.2.27 (cli) (built: Jan 26 2020 15:49:49) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
[root@server ~]# vim /etc/php-fpm.d/www.conf
8 user = nginx
10 group = nginx
[root@server ~]# vim /etc/nginx/conf.d/default.conf
8 location / {
9 root /usr/share/nginx/html;
10 index index.html index.htm index.php;
11 }
默认情况下php模块是被注释的
[root@server ~]# vim /etc/nginx/conf.d/default.conf
30 location ~ \.php$ {
31 root /nginx/html;
32 fastcgi_pass 127.0.0.1:9000;
33 fastcgi_index index.php;
34 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
35 include fastcgi_params;
36 }
#把fastcgi_param种的/scripts改为$document_root
#root 是配置php程序放置服务的根目录站点
执行时间是在一个程序执行过程中能等待的多长时间
从zabbix检测到这个服务掉线时,到发送数据给工程师,让工程师知晓,如果时间太短,会在时间结束后,直接把这个进程断掉,防止进程卡死,如果生产环境中的业务很多,占用很多流程,可以适当放宽
接收数据等待时间要一致
[root@server ~]# vim /etc/php.ini
202 short_open_tag = On #支持php短标签
359 expose_php = off #隐藏php版本
####———————以下为zabbix配置要求,优化配置———————
368 max_execution_time = 300 #执行时间
378 max_input_time = 300 #接收数据等待时间
389 memory_limit = 128M #每个脚本占用内存
656 post_max_size = 16M #post数据大小,post 提交数据安全,get提交不安全,get会把数据卸载url上,post可以适当放宽
799 upload_max_filesize = 2M #下载文件大小
800 always_populate_raw_post_data = -1 #这一行添加进去
#可以用$HTTP_RAW_POST_DATA接收post raw data(原始未处理数据)
877 date.timezone = Asia/Shanghai #时区
[root@server ~]# systemctl start php-fpm
[root@server ~]# systemctl enable php-fpm
Created symlink from /etc/systemd/system/multi-user.target.wants/php-fpm.service to /usr/lib/systemd/system/php-fpm.service.
[root@server ~]# systemctl restart nginx
[root@server ~]# mkdir -p /nginx/html
[root@server ~]# vim /nginx/html/index.php
phpinfo();
?>
[root@server ~]# netstat -natp | grep fpm
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 48176/php-fpm: mast
如果配置文件中语法有问题,服务时开不了的
[root@server ~]# vim /nginx/html/index.php
备注:mysql_connect扩展自PHP 5.5.0 起已废弃,改用mysqli或pdo_mysql
connect 是php的函数
进入数据库,给zabbix用户权限
为zabbix创建数据库
对于mysql种那些字符类型的列,如VARCHAR、CHAR、TEXT类型的列,都需要有一个collate类型来告知mysql如何对该列进行排序和比较。collate会影响到order by的语句顺序,会影响到where条件中大于小于号筛选出来的结果
[root@server ~]# mysql -uroot -p
Enter password: 123123
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.01 sec)
MariaDB [(none)]> grant all privileges on *.* to 'zabbix'@'%' identified by 'zabbix123';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
| zabbix |
+--------------------+
5 rows in set (0.00 sec)
[root@server ~]# vim /nginx/html/index.php
[root@server ~]# mysql -uzabbix -p
Enter password:
ERROR 1045 (28000): Access denied for user 'zabbix'@'localhost' (using password: YES)
[root@server ~]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
MariaDB [(none)]> select user,host from mysql.user
-> ;
+--------+-----------+
| user | host |
+--------+-----------+
| zabbix | % |
| root | 127.0.0.1 |
| root | ::1 |
| | localhost |
| root | localhost |
| | server |
| root | server |
+--------+-----------+
7 rows in set (0.00 sec)
MariaDB [(none)]> drop user ''@localhost
-> ;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> drop user ''@server;
Query OK, 0 rows affected (0.00 sec)
flush privileges;
[root@server ~]# mysql -u zabbix -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 13
Server version: 5.5.65-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)]>
MariaDB [(none)]> use zabbix;
Database changed
MariaDB [zabbix]> show tables
-> ;
Empty set (0.01 sec)
[root@server ~]# rpm -Uvh https://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm
Retrieving https://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm
warning: /var/tmp/rpm-tmp.pPAy7B: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:zabbix-release-4.4-1.el7 ################################# [100%]
[root@server ~]# yum list #不适用yum clean all ,因为开启了yum缓存
[root@server ~]# yum install zabbix-server-mysql zabbix-agent zabbix-web-mysql -y
#zabbix-web-mysql在4.4的nginx版本没有提示安装,4.0的zabbix需要安装
Error downloading packages:
zabbix-web-4.4.8-1.el7.noarch: [Errno 256] No more mirrors to try.
zabbix-server-mysql-4.4.8-1.el7.x86_64: [Errno 256] No more mirrors to try.
zabbix-agent-4.4.8-1.el7.x86_64: [Errno 256] No more mirrors to try.
[root@server ~]# yum install zabbix-server-mysql zabbix-agent zabbix-web-mysql -y
尝试到第二次,只差两个没有安装了
Error downloading packages:
zabbix-web-4.4.8-1.el7.noarch: [Errno 256] No more mirrors to try.
zabbix-server-mysql-4.4.8-1.el7.x86_64: [Errno 256] No more mirrors to try.
#继续重复执行下载任务
Installed:
zabbix-agent.x86_64 0:4.4.8-1.el7 zabbix-server-mysql.x86_64 0:4.4.8-1.el7
zabbix-web-mysql.noarch 0:4.4.8-1.el7
Dependency Installed:
OpenIPMI.x86_64 0:2.0.27-1.el7 OpenIPMI-libs.x86_64 0:2.0.27-1.el7
OpenIPMI-modalias.x86_64 0:2.0.27-1.el7 apr.x86_64 0:1.4.8-5.el7
apr-util.x86_64 0:1.5.2-6.el7 dejavu-fonts-common.noarch 0:2.33-6.el7
dejavu-sans-fonts.noarch 0:2.33-6.el7 fontpackages-filesystem.noarch 0:1.44-8.el7
fping.x86_64 0:3.10-4.el7 httpd.x86_64 0:2.4.6-93.el7.centos
httpd-tools.x86_64 0:2.4.6-93.el7.centos libevent.x86_64 0:2.0.21-4.el7
mailcap.noarch 0:2.1.41-2.el7 net-snmp-libs.x86_64 1:5.7.2-48.el7_8
php72w-bcmath.x86_64 0:7.2.27-1.w7 php72w-ldap.x86_64 0:7.2.27-1.w7
php72w-xml.x86_64 0:7.2.27-1.w7 unixODBC.x86_64 0:2.3.1-14.el7
zabbix-web.noarch 0:4.4.8-1.el7
Complete!
[root@server ~]#
重试了十几次,下载成功
#!/bin/bash
#这个是阿里云的源
echo -e "请给出要安装的zabbix版本号,建议使用4.x的版本 \033[31musage:./zabbix_aliyun.sh 4.0|4.4|4.5 \033[0m"
echo "例如要安装4.4版本,在命令行写上 ./zabbix_aliyun.sh 4.4"
if [ -z $1 ];then
exit
fi
VERSION=$1
if [ -f /etc/yum.repos.d/zabbix.repo ];then
rm -rf /etc/repos.d/zabbix.repo
fi
rpm -qa | grep zabbix-release && rpm -e zabbix-release
rpm -Uvh https://mirrors.aliyun.com/zabbix/zabbix/$VERSION/rhel/7/x86_64/zabbix-release-$VERSION-1.el7.noarch.rpm
sed -i "s@zabbix/.*/rhel@zabbix/$VERSION/rhel@g" /etc/yum.repos.d/zabbix.repo
sed -i '[email protected]@mirrors.aliyun.com/zabbix@g' /etc/yum.repos.d/zabbix.repo
[ $? -eq 0 ] && echo "阿里云的zabbix源替换成功" || exit 1
yum clean all
yum makecache fast
下面的源是阿里云的zabbix源
baseurl=https://mirrors.aliyun.com/zabbix/zabbix/4.0/rhel/7/$basearch/
baseurl=https://mirrors.aliyun.com/zabbix/non-supported/rhel/7/$basearch/
[root@server ~]# cd /etc/zabbix/
[root@server zabbix]# tree .
.
├── web
│ └── maintenance.inc.php
├── zabbix_agentd.conf
├── zabbix_agentd.d
└── zabbix_server.conf
2 directories, 3 files
[root@server zabbix]# zcat /usr/share/doc/zabbix-server-mysql-4.4.8/
AUTHORS ChangeLog COPYING create.sql.gz NEWS README
[root@server zabbix]# zcat /usr/share/doc/zabbix-server-mysql-4.4.8/create.sql.gz | mysql -uzabbix -p zabbix
Enter password:
zact代表不执行解压,直接看
这样就可以解压到内存当中,不占用空间
[root@server zabbix]# mysql -uzabbix -pzabbix123
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 17
Server version: 5.5.65-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)]> use zabbix;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
MariaDB [zabbix]> show tables
-> ;
+----------------------------+
| Tables_in_zabbix |
+----------------------------+
| acknowledges |
······························
退出数据库
[root@server zabbix]# vim /etc/zabbix/zabbix_server.conf
38 LogFile=/var/log/zabbix/zabbix_server.log
49 LogFileSize=0 #日志容量没有上限
72 PidFile=/var/run/zabbix/zabbix_server.pid
82 SocketDir=/var/run/zabbix
91 DBHost=localhost #开启
100 DBName=zabbix
116 DBUser=zabbix
124 DBPassword=zabbix123 #修改本行
356 SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
473 Timeout=4
516 AlertScriptsPath=/usr/lib/zabbix/alertscripts
527 ExternalScripts=/usr/lib/zabbix/externalscripts
563 LogSlowQueries=3000 #慢日志
慢日志,漫长操作的动作,会被记录到慢日志,记录了执行速度特别慢的SQL语句
[root@server zabbix]# vim /usr/share/zabbix/include/defines.inc.php
#使用末行模式
:% s /graphfont/kaiti/g
[root@server zabbix]# mkdir fonts
[root@server zabbix]# ll
total 36
drwxr-xr-x 2 root root 6 May 21 23:01 fonts
drwxr-x--- 2 apache apache 33 May 21 22:48 web
-rw-r--r-- 1 root root 13936 Apr 27 18:23 zabbix_agentd.conf
drwxr-xr-x 2 root root 6 Apr 27 18:22 zabbix_agentd.d
-rw-r----- 1 root zabbix 19778 May 21 23:00 zabbix_server.conf
[root@server zabbix]# cd fonts/
[root@server fonts]# ll
total 12440
-rw-r--r-- 1 root root 12736196 May 21 23:04 STKAITI.TTF
[root@server fonts]# pwd
/etc/zabbix/fonts
[root@server fonts]# pwd
/nginx/html/zabbix/fonts
[root@server fonts]# cp /etc/zabbix/fonts/STKAITI.TTF .
[root@server fonts]# cp -r /usr/share/zabbix /nginx/html/
[root@server fonts]# chown -R zabbix:zabbix /etc/zabbix/
[root@server fonts]# chown -R zabbix:zabbix /usr/share/nginx/
[root@server fonts]# chown -R zabbix:zabbix /usr/lib/zabbix/
[root@server fonts]# chmod -R 755 /etc/zabbix/web/
[root@server fonts]# chmod -R 777 /var/lib/php/session/
[root@server nginx]# chown -R zabbix:zabbix /nginx/
[root@server ~]# chown -R zabbix:zabbix /nginx/
[root@server fonts]# systemctl start zabbix-server
[root@server fonts]# systemctl enable zabbix-server
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-server.service to /usr/lib/systemd/system/zabbix-server.service.
[root@server fonts]# systemctl start zabbix-agent
[root@server fonts]# systemctl enable zabbix-agent
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
[root@server fonts]# netstat -natp | grep zabbix
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 6048/zabbix_agentd
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 5671/zabbix_server
tcp6 0 0 :::10050 :::* LISTEN 6048/zabbix_agentd
tcp6 0 0 :::10051 :::* LISTEN 5671/zabbix_server
[root@server fonts]# systemctl restart php-fpm
[root@server fonts]# systemctl restart nginx
访问结果发现404报错
8 location / {
9 root /nginx/html; #修改站点为/nginx/html
10 index index.html index.htm index.php;
11 }
然后重启,
[root@server ~]# systemctl restart nginx
可以了
备注:业务站点为了稳定,可以不用修改站点目录,以免混淆
Download the configuration file
Save it as "/etc/zabbix/web/zabbix.conf.php"
备注:给这个/etc/zabbix/web/zabbix.conf.php文件一个zabbix的权限
[root@server web]# chown zabbix.zabbix zabbix.conf.php
可以重新启动一下zabbix-server
systemctl restart zabbix-server
用户默认:Admin
被监控的服务端都需要安装zabbix-agent
宏函数官方文档:
https://www.zabbix.com/documentation/4.0/zh/manual/config/macros/macro_functions
用户宏变量官方文档:
https://www.zabbix.com/documentation/4.0/zh/manual/config/macros/usermacros
自动发现宏(LLD)
https://www.zabbix.com/documentation/4.0/zh/manual/config/macros/lld_macros
[root@client ~]# rpm -Uvh https://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm
Retrieving https://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm
warning: /var/tmp/rpm-tmp.QTmVVB: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:zabbix-release-4.4-1.el7 ################################# [100%]
[root@client ~]# yum list
[root@client ~]# yum install -y zabbix-agent
[root@client ~]# vim /etc/zabbix/zabbix_agentd.conf
13 PidFile=/var/run/zabbix/zabbix_agentd.pid
32 LogFile=/var/log/zabbix/zabbix_agentd.log
43 LogFileSize=0
98 Server=192.168.247.142 #指向zabbix-server服务端
139 ServerActive=192.168.247.142 #指向zabbix-server服务端
150 Hostname=client1 #zabbix-agent名称
290 Include=/etc/zabbix/zabbix_agentd.d/*.conf
[root@client ~]# setenforce 0
[root@client ~]# sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config
[root@client ~]# systemctl stop NetworkManager
[root@client ~]# systemctl disable NetworkManager
[root@client ~]# iptables -F
[root@client ~]# systemctl start zabbix-agent.service
[root@client ~]# systemctl enable zabbix-agent.service
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-agent.service to /usr/lib/systemd/system/zabbix-agent.service.
[root@client ~]# netstat -natp | grep zabbix
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 48909/zabbix_agentd
tcp6 0 0 :::10050 :::* LISTEN 48909/zabbix_agentd
配置——主机——创建主机
可以手动添加,也可以做一个自动发现机制
[root@client ~]# systemctl status sshd
● sshd.service - OpenSSH server daemon
Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2020-05-21 15:41:55 CST; 17h ago
Docs: man:sshd(8)
man:sshd_config(5)
Main PID: 985 (sshd)
CGroup: /system.slice/sshd.service
└─985 /usr/sbin/sshd -D
May 21 15:41:55 nginx systemd[1]: Starting OpenSSH server daemon...
May 21 15:41:55 nginx sshd[985]: Server listening on 0.0.0.0 port 22.
May 21 15:41:55 nginx sshd[985]: Server listening on :: port 22.
May 21 15:41:55 nginx systemd[1]: Started OpenSSH server daemon.
May 21 15:51:16 nginx sshd[2480]: Accepted password for root from 192.168.247.1 port 64983 ssh2
May 21 20:19:03 client sshd[128870]: Accepted password for root from 192.168.247.1 port 50651 ssh2
May 22 08:26:39 client sshd[112471]: Accepted password for root from 192.168.247.1 port 59045 ssh2
Hint: Some lines were ellipsized, use -l to show in full.
[root@client ~]# systemctl status httpd
Unit httpd.service could not be found.
[root@client ~]# systemctl stop sshd
等一会
zabbix-server缺少traceroute工具
[root@server ~]# yum install traceroute -y
[root@client ~]# systemctl start sshd
[root@client ~]# systemctl status sshd
● sshd.service - OpenSSH server daemon
Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2020-05-22 09:48:46 CST; 4s ago
Docs: man:sshd(8)
man:sshd_config(5)
Main PID: 75812 (sshd)
CGroup: /system.slice/sshd.service
└─75812 /usr/sbin/sshd -D
May 22 09:48:46 client systemd[1]: Starting OpenSSH server daemon...
May 22 09:48:46 client sshd[75812]: Server listening on 0.0.0.0 port 22.
May 22 09:48:46 client sshd[75812]: Server listening on :: port 22.
May 22 09:48:46 client systemd[1]: Started OpenSSH server daemon.