作为一名合格的云计算工程师,监控服务器的运行是必不可少的。
监控信息的收集方式
主动上报:优点是实时性比较好,缺点是消耗资源特别大。
被动监测:定时进行监测状态。
基本环境
zabbix-server 监控端一般单独装在一个服务器上(192.168.100.10)
官网:https://www.zabbix.com/documentation/3.2
环境:
IP 主机名角色
192.168.100.10 zabbix_server 监控服务器
192.168.100.20 web1 业务主机
Installing Zabbix packages
设置主机名: hostname zabbix_server
防火墙:systemctl stop firewalld.service
systemctl disable firewalld.service
selinux:setenforce 0
准备Zabbix-repo
rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
安装Zabbix服务器
yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-get zabbix-agent
zabbix-server-mysql:数据库
zabbix-web-mysql:WEB用来提供web页面
zabbix-get: 单命令行的查看工具
zabbi-agent:代理程序(上报信息的程序)
Creating initial database
1.安装数据库
yum -y install mariadb mariadb-server
2.启动数据库
systemctl start mariadb
systemctl enable mariadb
(此处还需要在数据库中插入一些表用来存放监控的数据)
3.授权zabbix账号
mysql
create database zabbix character set utf8 collate utf8_bin;
grant all privileges on zabbix.* to zabbix@localhost identified by 'tianyun';
flush privileges;
4.初始化zabbix
注意3.2.的版本
[root@zabbix_server ~]# cd /usr/share/doc/zabbix-server-mysql-3.2.3/
[root@zabbix_server zabbix-server-mysql-3.2.3]# zcat create.sql.gz | mysql -uroot -p zabbix
Starting Zabbix server process
配置sql账号密码:
vim /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=tianyun
此处注意:要使用搜索选项搜索内容,配置文件里有一些已经配置好的项目
启动zabbix
systemctl start zabbix-server.service
systemctl enable zabbix-server.service
修改时区Editing PHP configuration for Zabbix frontend
vim /etc/httpd/conf.d/zabbix.conf
php_value date.timezone Asia/Shanghai
(默认值,只需要配置时区。)
systemctl start httpd
systemctl enable httpd
欢迎页面:
PHP检测
数据库信息
数据库信息报错:
服务器命名:
恭喜:
登录
用户名:Admin (区分大小写)
密码:zabbix
administration>users>admin user
右上角用户图标,更换语言
设置中文后,查看图形有乱码,文字变成了方块
界面乱码解决方法
解决方法:
Win+R打开运行,输入fonts,回车进入Windows字体目录,找到微软雅黑-常规字体,复制出来将文件名修改为msyh.ttf,注意后缀ttf
将msyh.ttf上传到服务器zabbix字体目录中:/usr/share/zabbix/fonts/
chmod 777 /usr/share/zabbix/fonts/msyh.ttf
查看字体配置
# grep FONT_NAME /usr/share/zabbix/include/defines.inc.php -n
执行快捷替换:sed -i "s/graphfont/msyh/g"
/usr/share/zabbix/include/defines.inc.php
确认是否替换成功:
#grep FONT_NAME /usr/share/zabbix/include/defines.inc.php -n
【45:define(‘ZBX_GRAPH_FONT_NAME’, ‘msyh’); // font file name】
【93:define(‘ZBX_FONT_NAME’, ‘msyh’);】
字体配置修改成功后,刷新图形界面即可看到图形字体显示正常了。