一、构建zabbix监控:初始系统设置:
### --- zabbix实验专题<——
### --- 初始系统设置:
### --- 操作系统:HA-server1:centos7.x-1810:网卡一:仅主机模式;网卡二:net模式
### --- 关闭防火墙
[root@server11 ~]# systemctl stop firewalld.service
[root@server11 ~]# systemctl disable firewalld.service
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
### --- 关闭selinux
[root@server11 ~]# setenforce 0
[root@server11 ~]# vi /etc/sysconfig/selinux
SELINUX=disabled
### --- 配置网卡:一块仅主机模式,一块net模式
[root@server11 ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens33
BOOTPROTO=static
ONBOOT=yes
IPADDR=10.10.10.11
NETMASK=255.255.255.0
[root@server11 ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens34
BOOTPROTO=dhcp
ONBOOT=yes
[root@server11 ~]# systemctl restart network.service
[root@server11 ~]# ip addr
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
inet 10.10.10.11/24 brd 10.10.10.255 scope global noprefixroute ens33
3: ens34: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
inet 192.168.120.128/24 brd 192.168.120.255 scope global noprefixroute dynamic ens34
### --- 安装基础软件包
[root@server11 ~]# yum install -y net-tools // 安装基础软件包
[root@server11 ~]# yum install lrzsz vim gcc gcc-c++
### --- 更换yum源
[root@server11 ~]# wget http://mirros.163.com/./help/CentOS7-Base-163.repo
[root@server11 ~]# mkdir /etc/yum.repos.d/back
[root@server11 ~]# mv /etc/yum.repos.d/* /etc/yum.repos.d/back/
[root@server11 ~]# mkdir /etc/yum.repos.d/back
[root@server11 ~]# mv /etc/yum.repos.d/* /etc/yum.repos.d/back/
[root@server11 ~]# yum clean all
[root@server11 ~]# yum makecache
二、安装LAMP环境
### --- 安装LAMP环境
### --- 部署完整的LAMP环境
### --- mysql和mariadb不同点是mysql会自己进行初始化,而mariadb则不会,需要我们手动初始化。
[root@server11 ~]# yum install -y mariadb mariadb-server httpd php php-mysql
[root@server11 ~]# systemctl start httpd.service
[root@server11 ~]# systemctl start mariadb.service
[root@server11 ~]# systemctl enable httpd.service
[root@server11 ~]# systemctl enable mariadb.service
### --- 初始化mariadb
[root@server11 ~]# mysql_secure_installation
Set root password? [Y/n] y
New password: 123456
Re-enter new password: 123456
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
Reload privilege tables now? [Y/n] y
[root@server11 ~]# mysql -uroot -p
Enter password: 123456
MariaDB [(none)]> exit
三、安装zabbix程序
### --- 安装zabbix-server
[root@server11 ~]# rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
[root@server11 ~]# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX // 导入rpm包的秘钥
[root@server11 ~]# yum install -y zabbix-server-mysql zabbix-web-mysql zabbix-agent //zabbix-server-mysql:连接数据方案 zabbix-web-mysql:提供web界面
~~~输出参数
Install 3 Packages (+27 Dependent packages)
Total download size: 13 M
Installed size: 60 M
Installed:
zabbix-agent.x86_64 0:3.2.11-1.el7 zabbix-server-mysql.x86_64 0:3.2.11-1.el7 zabbix-web-mysql.noarch 0:3.2.11-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
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-1.el7 gnutls.x86_64 0:3.3.29-9.el7_6 iksemel.x86_64 0:1.4-2.el7.centos
libX11.x86_64 0:1.6.7-3.el7_9 libX11-common.noarch 0:1.6.7-3.el7_9 libXau.x86_64 0:1.0.8-2.1.el7
libXpm.x86_64 0:3.5.12-1.el7 libjpeg-turbo.x86_64 0:1.2.90-8.el7 libpng.x86_64 2:1.5.13-8.el7
libxcb.x86_64 0:1.13-1.el7 net-snmp-libs.x86_64 1:5.7.2-49.el7_9.1 nettle.x86_64 0:2.7.1-8.el7
php-bcmath.x86_64 0:5.4.16-48.el7 php-gd.x86_64 0:5.4.16-48.el7 php-ldap.x86_64 0:5.4.16-48.el7
php-mbstring.x86_64 0:5.4.16-48.el7 php-xml.x86_64 0:5.4.16-48.el7 t1lib.x86_64 0:5.1.2-14.el7
trousers.x86_64 0:0.3.14-2.el7 unixODBC.x86_64 0:2.3.1-14.el7 zabbix-web.noarch 0:3.2.11-1.el7
Complete!
### --- 初始化数据库:
[root@server11 ~]# mysql -u root -p
Enter password: 123456
MariaDB [(none)]> CREATE DATABASE zabbix DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
Query OK, 0 rows affected (0.00 sec)
### --- 读入数据库
[root@server11 ~]# ls /usr/share/doc/zabbix-server-mysql-3.2.11/create.sql.gz
/usr/share/doc/zabbix-server-mysql-3.2.11/create.sql.gz // 数据库的模板文件
[root@server11 ~]# cd /usr/share/doc/zabbix-server-mysql-3.2.11/
[root@server11 zabbix-server-mysql-3.2.11]# zcat create.sql.gz | mysql -uroot -p zabbix //zcat:解压并查看,相当于先解压再通过cat命令将其打开;把它交给mysql -uroot -p zabbix:用户
Enter password: 123456
[root@server11 zabbix-server-mysql-3.2.11]# mysql -uroot -p // 查看是否还原成功
Enter password: 123456
MariaDB [(none)]> use zabbix
MariaDB [zabbix]> show tables; // 数据表显示
### --- 启动zabbix服务
[root@server11 ~]# vim /etc/zabbix/zabbix_server.conf
DBHost=localhost // 数据库连接授权方案,默认情况下是本地ip,所以写localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
[root@server11 ~]# systemctl start zabbix-server
[root@server11 ~]# systemctl enable zabbix-server
### --- 编辑zabbix前端PHP配置
[root@server11 ~]# vim /etc/httpd/conf.d/zabbix.conf // 安装zabbix-server-web软件包时导入的软件包
php_value max_execution_time 300
php_value memory_limit 128M
php_value post_max_size 16M
php_value upload_max_filesize 2M
php_value max_input_time 300
php_value always_populate_raw_post_data -1
php_value date.timezone Asia/Shanghai // 时区设置为亚洲上海,其他的默认
### --- 重启Apache服务生效
[root@server11 ~]# systemctl restart httpd
### --- 调整时间同步
[root@server11 ~]# yum install -y ntpdate
[root@server11 ~]# date -s 07:37:00
### --- 访问网页:默认是http://10.10.10.11/zabbix;
### --- 若是不嵌入zabbix这个字段,可以修改一下Apache
[root@server11 ~]# vim /etc/httpd/conf/httpd.conf
DocumentRoot "/usr/share/zabbix/"
[root@server11 ~]# systemctl restart httpd.service
### --- 访问http://10.10.10.11 // 不需要加载zabbix字段就可以直接访问了。
四、修改中文乱码问题
### --- 修改中文乱码问题
### --- wind+R > fonts > 拷贝微软雅黑字体改名为msyh.ttf > /usr/share/zabbix/fonts
### --- 默认的书写格式是:ttf
[root@server11 ~]# mv mysh.ttf /usr/share/zabbix/fonts/
[root@server11 ~]# chmod a+x /usr/share/zabbix/fonts/mysh.ttf
### --- 修改zabbix php 页面配置,将'graohfont'修改为msyh
[root@server11 ~]# vim /usr/share/zabbix/include/defines.inc.php
define('ZBX_GRAPH_FONT_NAME', 'mysh'); // font file name
### --- 解释性语言,保存生效,不需要重启。
一、初始化配置:
1、zabbix-web配置安装:访问http://10.10.10.11 默认初始页:Next step
2、检测PHP的相关依赖,都是OK,Next step
3、数据库名称密码:zabbix:zabbix,Next step
4、输出的默认信息;Next step
5、输出信息;Next step
6、恭喜你安装部署成功;Finish
7、默认的用户名密码:Admin:zabbix
8、更改默认字体为中文:
### --- 更改默认字体为中文:
~~~ Administration——>Users——>Admin——>Language——>Chinese(zh_CN)
~~~ ——>Update——刷新——>中文显示——>END