.1.1 网站可用性
在软件系统的高可靠性(也称为可用性,英文描述为HA,High Available)里有个衡量其可靠性的标准——X个9,这个X是代表数字3~5。X个9表示在软件系统1年时间的使用过程中,系统可以正常使用时间与总时间(1年)之比,我们通过下面的计算来感受下X个9在不同级别的可靠性差异。
1个9:(1-90%)*365=36.5天,表示该软件系统在连续运行1年时间里最多可能的业务中断时间是36.5天
2个9:(1-99%)*365=3.65天 , 表示该软件系统在连续运行1年时间里最多可能的业务中断时间是3.65天
3个9:(1-99.9%)*365*24=8.76小时,表示该软件系统在连续运行1年时间里最多可能的业务中断时间是8.76小时。
4个9:(1-99.99%)*365*24=0.876小时=52.6分钟,表示该软件系统在连续运行1年时间里最多可能的业务中断时间是52.6分钟。
5个9:(1-99.999%)*365*24*60=5.26分钟,表示该软件系统在连续运行1年时间里最多可能的业务中断时间是5.26分钟。
6个9:(1-99.9999%)*365*24*60*60=31秒, 示该软件系统在连续运行1年时间里最多可能的业务中断时间是31秒
1.3.2 监控硬件
查看硬件的温度/风扇转速,电脑有鲁大师,服务器就有ipmitool。
使用ipmitool实现对服务器的命令行远程管理
1.3.3 查看cpu相关
lscpu、uptime、top、htop vmstat mpstat
其中htop需要安装,安装依赖与epel源。
1.3.4 内存够不够可以用
free
1.3.6 监控网络
iftop nethogs
1.3.6 监控网络
iftop nethogs
第2章 安装zabbix
2.1 环境检查
[root@m01 ~]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
[root@m01 ~]# uname -r
3.10.0-693.el7.x86_64
[root@m01 ~]# getenforce
Disabled
[root@m01 ~]# systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:firewalld(1)
2.2.2 服务端快速安装脚本
#!/bin/bash #clsn #设置解析 注意:网络条件较好时,可以不用自建yum源 # echo '10.0.0.1 mirrors.aliyuncs.com mirrors.aliyun.com repo.zabbix.com' >> /etc/hosts #安装zabbix源、aliyun YUM源 curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm #安装zabbix yum install -y zabbix-server-mysql zabbix-web-mysql #安装启动 mariadb数据库 yum install -y mariadb-server systemctl start mariadb.service #创建数据库 mysql -e 'create database zabbix character set utf8 collate utf8_bin;' mysql -e 'grant all privileges on zabbix.* to zabbix@localhost identified by "zabbix";' #导入数据 zcat /usr/share/doc/zabbix-server-mysql-3.0.13/create.sql.gz|mysql -uzabbix -pzabbix zabbix #配置zabbixserver连接mysql sed -i.ori '115a DBPassword=zabbix' /etc/zabbix/zabbix_server.conf #添加时区 sed -i.ori '18a php_value date.timezone Asia/Shanghai' /etc/httpd/conf.d/zabbix.conf #解决中文乱码 yum -y install wqy-microhei-fonts \cp /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /usr/share/fonts/dejavu/DejaVuSans.ttf #启动服务 systemctl start zabbix-server systemctl start httpd #写入开机自启动 chmod +x /etc/rc.d/rc.local cat >>/etc/rc.d/rc.local<<EOF systemctl start mariadb.service systemctl start httpd systemctl start zabbix-server EOF #输出信息 echo "浏览器访问 http://`hostname -I|awk '{print $1}'`/zabbix"
2.2.3 客户端快速部署脚本
#!/bin/bash
#clsn
#设置解析
echo '10.0.0.1 mirrors.aliyuncs.com mirrors.aliyun.com repo.zabbix.com' >> /etc/hosts
#安装zabbix源、aliyu nYUM源
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
#安装zabbix客户端
yum install zabbix-agent -y
sed -i.ori 's#Server=127.0.0.1#Server=172.16.1.61#' /etc/zabbix/zabbix_agentd.conf
systemctl start zabbix-agent.service
#写入开机自启动
chmod +x /etc/rc.d/rc.local
cat >>/etc/rc.d/rc.local<<EOF
systemctl start zabbix-agent.service
EOF
2.3.1 服务端安装zabbix-get检测工具
zabbix_get -s 172.16.1.61 -p 10050 -k "system.cpu.load[all,avg1]" zabbix_get -s 172.16.1.21 -p 10050 -k "system.cpu.load[all,avg1]"
[root@m01 ~]# zabbix_get -s 172.16.1.61 -p 10050 -k "system.cpu.load[all,avg1]" 0.000000 [root@m01 ~]# zabbix_get -s 172.16.1.21 -p 10050 -k "system.cpu.load[all,avg1]" 0.000000