Ubuntu安装zabbix配置教程
Ubuntu镜像下载:https://mirrors.aliyun.com/ubuntu-releases/20.04.6/ubuntu-20.04.6-live-server-amd64.iso
Ubuntu在vm虚拟机安装(如下未提及项均保持默认选项)
1、配置软件源为阿里云, http://mirrors.aliyun.com/ubuntu
2、配置服务器名称和用户名密码
3、安装 ssh 服务,按空格键选择
4、开始安装Ubuntu
5、安装完成后重启
6、登入系统,用ip add查看下系统ip地址
7、用putty工具远程ssh登入
8、修改Ubuntu为静态ip, sudo vim /etc/netplan/00-installer-config.yaml,清空文件所有内容,复制下面内容进去,网关地址在Ubuntu中用routel查看
# This is the network config written by 'subiquity' network: ethernets: ens33: dhcp4: no addresses: [192.168.227.100/24] optional: true gateway4: 192.168.227.2 nameservers: addresses: [192.168.227.2] version: 2
9、修改后应用配置文件,sudo netplan apply
10、用新的ip地址ssh连接上
11、修改时区,sudo cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
12、验证时区,date -R
Wed, 06 Mar 2024 21:23:05 +0800
13、系统优化---修改文件描述和进程数
sudo sed -i '/^# End of file/,$d' /etc/security/limits.conf sudo sh -c "cat >> /etc/security/limits.conf <<EOF # End of file root - nproc 512000 * - nproc 512000 root -nofile 512000 * - nofile 512000 EOF"
14、软件源替换成阿里云
sudo sed -i.bak 's/http:\/\/.*.ubuntu.com/http:\/\/mirrors.aliyun.com/g' /etc/apt/sources.list
15、更新源并重启电脑
sudo apt update && sudo apt upgrade -y
sudo reboot
16、安装mysql8.0
sudo bash -c "cat >/etc/apt/sources.list.d/mysql-community.list" <<EOF deb https://mirrors.tuna.tsinghua.edu.cn/mysql/apt/ubuntu bionic mysql-5.7 mysql-8.0 mysql-tools EOF sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3A79BD29 sudo apt update sudo apt install mysql-server
17、创建zabbix数据库并创建密码为password,创建zabbix用户,赋予所有数据库权限
sudo mysql -u root -p create database zabbix character set utf8mb4 collate utf8mb4_bin; create user zabbix@'localhost' identified WITH mysql_native_password by 'password'; grant all privileges on zabbix.* to zabbix@'localhost'; quit;
18、安装zabbix-web、zabbix-server、zabbix-agent2、zabbix-server-mysql
wget https://mirrors.aliyun.com/zabbix/zabbix/6.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_6.0-1+ubuntu20.04_all.deb sudo dpkg -i zabbix-release_6.0-1+ubuntu20.04_all.deb sudo apt update sudo apt install -y zabbix-server-mysql zabbix-frontend-php zabbix-apache-conf zabbix-sql-scripts zabbix-agent2
19、安装zabbix中文字体
sudo apt -y install language-pack-zh-hans
20、初始化zabbix数据库
zcat /usr/share/doc/zabbix-sql-scripts/mysql/server.sql.gz | mysql -u zabbix -p -h localhost zabbix
如果初始化报错:gzip: /usr/share/doc/zabbix-sql-scripts/mysql/server.sql.gz: No such file or directory
请看这篇文章:https://www.cnblogs.com/xiykj/p/18052030
21、检查zabbix-server、zabbix-agent2、Apache2 进程是否启动,这三个进程状态都必须为running状态,zabbix_server配置文件路径 /etc/zabbix/zabbix_server.conf ,zabbix_server日志文件路径 /var/log/zabbix/zabbix_server.log
sudo systemctl status zabbix-server.service zabbix-agent2.service apache2.service
22、如果zabbix-server状态为running,但是 10051 端口没起来
请移步这篇文章 https://www.cnblogs.com/xiykj/p/18047796
23、配置zabbix-server、Apache服务开机自启并运行
sudo systemctl enable --now zabbix-server apache2
24、检查zabbix-server、zabbix-agent2、Apache2服务端口是否运行起来
ss -lntp | grep -E "80|10050|10051"
25、在浏览器初始化zabbix_server前端页面,http://192.168.227.100/zabbix
26、默认登入用户名 Admin 密码 zabbix