一、mysql安装
1、虚拟机网络设置成NAT模式
2、sudo apt install mysql-server
3、sudo mysql -u root -p(直接回车进入mysql)
4、创建用户和密码
CREATE USER 'root'@'%' IDENTIFIED BY 'newmysql';
5、权限赋给root用户,所有ip都能连接
GRANT ALL ON *.* TO 'root'@'%' WITH GRANT OPTION;
6、更新root密码否则,远程登录会报错
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'newmysql';
7、再次刷新
FLUSH PRIVILEGES;
8、sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf
找到bind-address = 127.0.0.1 将其注释
esc
:wq(保存退出)
9、sudo ufw allow 3306
10、关掉mysql服务:sudo /etc/init.d/mysql stop
11、启动mysql服务:sudo /etc/init.d/mysql start
12、查看服务状态
sudo service mysql status
13、停止服务
sudo service mysql stop
14、启动服务
sudo service mysql start
15、重启服务
sudo service mysql restart
16、登录MySQL数据库
mysql -u root -p
17、卸载命令
需要完全清理MySQL时,可以完全卸载。
sudo apt purge mysql-*
sudo rm -rf /etc/mysql/ /var/lib/mysql
sudo apt autoremove
sudo apt autoclean
二、安装Zabbix5.4
1,安装语言包
sudo apt install language-pack-zh-hans
2,设置 locale
sudo vi /etc/locale.gen
找到 zh_CN.UTF-8 UTF-8 并取消注释,然后保存并退出
3,编译语言
sudo locale-gen
4,设置默认语言为中文
sudo vi /etc/default/locale
将内容修改为
LANG=zh_CN.UTF-8
5,安装mysql
6,按照下面的网址进行安装和配置
https://www.zabbix.com/cn/download?zabbix=5.2&os_distribution=ubuntu&os_version=20.04_focal&db=mysql&ws=apache
下载并安装
wget https://repo.zabbix.com/zabbix/5.4/ubuntu/pool/main/z/zabbix-release/zabbix-release_5.4-1+ubuntu20.04_all.deb
dpkg -i zabbix-release_5.4-1+ubuntu20.04_all.deb
apt update
安装
apt install zabbix-server-mysql zabbix-frontend-php zabbix-nginx-conf zabbix-sql-scripts zabbix-agent
设置账号密码
mysql -uroot -p
create database zabbix character set utf8 collate utf8_bin;
create user zabbix@localhost identified by 'newmysql';
grant all privileges on zabbix.* to zabbix@localhost;
quit;
zcat /usr/share/doc/zabbix-sql-scripts/mysql/create.sql.gz | mysql -uzabbix -p zabbix
输入mysql密码
为Zabbix server配置数据库
vim /etc/zabbix/zabbix_server.conf
DBPassword=newmysql
DBHost=localhost
DBName=zabbix
DBUser=zabbix
为Zabbix前端配置PHP
vim /etc/zabbix/nginx.conf
去掉前面的#号
listen 80;
server_name 你的IP;
Nginx机器启动相关服务,并配置开机自动启动
systemctl restart zabbix-server zabbix-agent nginx php-fpm
systemctl enable zabbix-server zabbix-agent nginx php-fpm
7,安装配置后进行访问:http://IP/setup.php,登录时,默认用户名是:Admin,密码是zabbix