zabbix完整部署及部署KVM虚拟机

tech2024-10-09  11

9.3

Zabbix 监控部署 俩台虚拟机 zabbix-server zabbix-agent

1.修改俩台节点IP及主机名

vi /etc/sysconfig/network-scripts/ifcfg-en(Tab)

hostnamectl set-hostname zabbix-server hostnamectl set-hostname zabbix-agent

2.yum配置

zabbix压缩包上传至zabbix-server节点的/opt目录下,挂载

mkdir -p /opt/centos mount CentOS-7-x86_64-DVD-1511.iso centos/

3.将/etc/yum.repo.d目录下的所有文件移动到/media下

mv /etc/yum.repos.d/* /media/

4./etc/yum.repo.d目录下创建local.repo文件

cat /etc/yum.repos.d/local.repo (添加下面内容)

[centos] name=centos baseurl=file:///opt/centos gpgcheck=0 enabled=1 [zabbix] name=zabbix baseurl=file:///opt/zabbix gpgcheck=0 enabled=1

5.配置zabbix-agent节点yum源

首先在zabbix-server节点上安装vsftpd服务。 yum install vsftpd -y 修改vsftpd.conf配置文件,添加anon_root=/opt vi /etc/vsftpd/vsftpd.conf

6.启动vsftpd服务 systemctl start vsftpd systemctl status vsftpd 7.zabbix-agent节点将/etc/yum.repo.d目录下所有文件移动到/media目录下,并新创建local.repo

mv /etc/yum.repos.d/* /media/ vi /etc/yum.repos.d/local.repo

内容: [centos] name=centos baseurl=ftp://192.168.20.10/centos gpgcheck=0 enabled=1 [zabbix] name=zabbix baseurl=ftp://192.168.20.10/zabbix gpgcheck=0 enabled=1

8.安装LAMP+Zabbix服务(在zabbix-server节点上) yum install httpd -y 安装httpd yum install -y mariadb-server mariadb 安装数据库 yum install -y zabbix-server-mysql zabbix-web-mysql zabbix-agent mariadb-server 安装zabbix yum install trousers -y 升级trousers

9.(zabbix-server节点)启动httpd服务 systemctl start httpd 启动httpd服务 systemctl enable httpd 设置开机自启

10.启动并配置数据库服务 systemctl start mariadb systemctl enable mariadb

11.登录数据库、创建zabbix库、授予zabbix用户的访问权限 mysql -uroot -p123123 create database zabbix character set utf8 collate utf8_bin; grant all privileges on zabbix.* to zabbix@’%’ identified by ‘zabbix’; grant all privileges on zabbix.* to zabbix@localhost identified by ‘zabbix’;

12.退出数据库,进入/usr/share/doc/zabbix-server-mysql-3.4.15/目录导入数据 cd /usr/share/doc/zabbix-server-mysql-3.4.15/ zcat create.sql.gz |mysql -uroot zabbix 导入数据

13.设置时区,编辑/etc/php.ini文件,设置如下

vi /etc/php.ini

内容: [Date] ; Defines the default timezone used by the date functions ; http://php.net/date.timezone date.timezone = PRC

14.编辑/etc/httpd/conf.d/zabbix.conf文件修改时区, vi /etc/httpd/conf.d/zabbix.conf 内容:

15.修改/etc/zabbix/zabbix_server.conf配置文件 vi /etc/zabbix/zabbix_server.conf grep -n ‘^’[a-Z] /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=zabbix 132:DBSocket=/var/lib/mysql/mysql.sock 330:SNMPTrapperFile=/var/log/snmptrap/snmptrap.log 447:Timeout=4 489:AlertScriptsPath=/usr/lib/zabbix/alertscripts 499:ExternalScripts=/usr/lib/zabbix/externalscripts 535:LogSlowQueries=3000

16.启动zabbix服务、查看端口号10051是否存在,web界面登录192.168.100.40/zabbix,安装 systemctl start zabbix-server netstat -ntpl 设置密码zabbix ,使用Admin/zabbix登录

17.进入主页,点击头像进行设置,把语言一栏改为Chinexe(zh CN),然后update执行

18.(在zabbix-agent节点)安装zabbix-agent服务 yum install -y zabbix-agent

19.修改/etc/zabbix/zabbix_agentd.conf配置文件 vi /etc/zabbix/zabbix_agentd.conf grep -n ‘^’[a-Z] /etc/zabbix/zabbix_agentd.conf

内容: 13:PidFile=/var/run/zabbix/zabbix_agentd.pid 32:LogFile=/var/log/zabbix/zabbix_agentd.log 43:LogFileSize=0 97:Server=192.168.20.10 138:ServerActive=192.168.20.10 149:Hostname=Zabbix-agent 267:Include=/etc/zabbix/zabbix_agentd.d/*.conf

20.启动zabbix-agent服务,查看端口10050是否存在 systemctl start zabbix-agent netstat -ntpl

21.web界面,配置-主机-创建主机 (1)主机名和可见名称zabbix-agent (2)添加群组linux-server

22.添加监控项,单击“zabbix-agent”名称,然后单击“模板”标签,进行添加,完成后更新 (1)Template os Linux (2)Template App HTTP Service (3)Template DB MYSQL

23.菜单栏“监测中”–图形,群组选择Linux server,主机选择zabbix-agent,图形选择CPU jumps

KVM 俩台虚拟机

1.进行IP配置,重启网卡 vi /etc/sysconfig/network-scripts/ifcfg-en(Tab) systemctl restart network

2.虚拟机处理器勾选三个引擎 3.配置yum源 mv /etc/yum.repos.d/* /media/ vi /etc/yum.repos.d/local.repo 内容: [centos] name=centos baseurl=file:///mnt gpgcheck=0 enabled=1

mount /dev/sr0 /mnt/ 挂载 yum clean all yum repolist

4.临时关闭selinux及防火墙 setenforce 0 getenforce systemctl stop firewalld systemctl disable firewalld

5.安装KVM组件 yum install qemu-kvm openssl libvirt -y 6.启动启动libvirtd服务 systemctl start libvirtd 7.将/usr/libexec/qemu-kvm链接为/usr/bin/qemu-kvm: ln -s /usr/libexec/qemu-kvm /usr/bin/qemu-kvm 8.上传cirros-0.3.3-x86_64-disk.img镜像与qemu-ifup-NAT脚本,并赋予权限 chmod +x qemu-ifup-NAT.txt 9.启动虚拟机,用户名:cirros,密码是:cubswin:) qemu-kvm -m 1024 -drive file=/root/cirros-0.3.3-x86_64-disk.img,if=virtio -net nic,model=virtio -net tap,script=/root/qemu-ifup-NAT.txt -nographic -vnc :1

最新回复(0)