zabbix基础设置(运维笔记)
准备三台主机配置主机名
hostnamectl set-hostname --static zabbixserver.cluster.com
vi /etc/hosts
192.168.126.143 zabbixserver.cluster.com
192.168.126.142 agent1.cluster.com
192.168.126.141 agent2.cluster.com
三台机器同步时间
ntpdate cn.pool.ntp.org
#需要下载ntp
关闭防火墙 selinux
systemctl stop firewalld && systemctl disable firewalld
iptables -F
setenforce 0
所有机器加上zabbix的yum源
vim /etc/yum.repos.d/zabbix.repo
[zabbix]
name=zabbix
baseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/3.4/rhel/7/x86_64/
enabled=1
gpgcheck=0
[zabbix_deps]
name=zabbix_deps
baseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/non-supported/rhel/7/x86_64/
enabled=1
gpgcheck=0
yum clean all && yum makecache
zabbix server配置
yum install zabbix-server-mysql zabbix-web-mysql mariadb-server
mysql(mariadb)建立存放数据的库并授权,然后导入zabbix所需要用的表和数据
[root@zabbixserver ~]# systemctl restart mariadb.service
[root@zabbixserver ~]# systemctl enable mariadb.service
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@zabbixserver ~]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.68-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)]> create database zabbix default charset utf8;
Query OK, 1 row affected (0.01 sec)#创建数据库
MariaDB [(none)]> grant all on zabbix.* to zabbix@'localhost' identified by '123';
Query OK, 0 rows affected (0.00 sec) #授权
MariaDB [(none)]> flush privileges; #刷新权限
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> quit
Bye
[root@zabbixserver ~]# cd /usr/share/doc/zabbix-server-mysql-3.4.15/
[root@zabbixserver zabbix-server-mysql-3.4.15]# ls
AUTHORS ChangeLog COPYING create.sql.gz NEWS README
[root@zabbixserver zabbix-server-mysql-3.4.15]# zcat create.sql.gz | mysql zabbix
[root@zabbixserver zabbix-server-mysql-3.4.15]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 5.5.68-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;
配置zabbix主配置文件,并启动服务,确认端口
[root@zabbixserver ~]# vim /etc/zabbix/zabbix_server.conf
ListenPort=10051 #agent连接的端口
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=123 #数据库设置的密码
DBSocket=/var/lib/mysql/mysql.sock
ListenIP=0.0.0.0
#这里一定要提前关闭防火墙和selinux 否则打不开 这里我安装的是centos7.6最小化带开发工具安装
#有一些命令没有 需要自行安装
[root@zabbixserver ~]# systemctl restart zabbix-server
[root@zabbixserver ~]# 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.
配置zabbix的httpd子配置文件,并启动httpd
#修改时区 20行
[root@zabbixserver ~]# vim /etc/httpd/conf.d/zabbix.conf
20 php_value date.timezone Asia/Shanghai
#启动httpd
systemctl restart httpd && systemctl enable httpd
访问 http://192.168.126.143/zabbix/ (你的服务器地址)根据提示安装
填写数据库用户名密码
填写信息
管理员登录账号admin 密码zabbix
进入后点击右上角小人,语言选 chinese zh-cn , 点 update后换成中文件界面
zabbix监控本机
在监控界面启用
本机安装agent
yum install zabbix-agent
启动服务zabbix-agent
[root@zabbixserver ~]# vim /etc/zabbix/zabbix_agentd.conf
Server=127.0.0.1 --zabbix服务器的IP,这里是本机
ListenPort=10050 --监控服务器连接被监控客户端的端口
[root@zabbixserver ~]# systemctl restart zabbix-agent
[root@zabbixserver ~]# systemctl enable zabbix-agent
[root@zabbixserver ~]# lsof -i:10050
点zabbix server里的图形,任意选一张图后点预览看到,图上有乱码
[root@zabbixserver ~]# ls |grep ttf
ttf-arphic-ukai.tar.gz
下载ttf-arphic-ukai.tar.gz软件包,并做如下修改
tar xf ttf-arphic-ukai.tar.gz -C /usr/share/zabbix/fonts/
mv /usr/share/zabbix/fonts/ukai.ttc /usr/share/zabbix/fonts/ukai.ttf
vim /usr/share/zabbix/include/defines.inc.php
54 define('ZBX_GRAPH_FONT_NAME', 'ukai'); --修改原来的graphfont字体改成ukai
不用重启服务,刷新页面查看文章来源:https://www.toymoban.com/news/detail-424836.html
文章来源地址https://www.toymoban.com/news/detail-424836.html
到了这里,关于zabbix环境准备的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!