目录
zabbix部署
lamp已构建完成
解压mysql8.0
[root@localhost local]# tar xf mysql-8.0.28-linux-glibc2.12-x86_64.tar.xz
修改所属主和组
[root@localhost local]# chown -R mysql.mysql /usr/local/mysql
[root@localhost local]# ll /usr/local/mysql -d
lrwxrwxrwx. 1 mysql mysql 35 Sep 1 20:45 /usr/local/mysql -> mysql-8.0.28-linux-glibc2.12-x86_64
配置环境变量
[root@localhost local]# echo 'export PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
[root@localhost local]# source /etc/profile.d/mysql.sh
建立数据目录
[root@localhost local]# ll /opt/data/
drwxr-xr-x. 2 mysql mysql 6 Sep 1 20:49 data
创建头文件
[root@localhost mysql]# ln -sv /usr/local/mysql/include/ /usr/include/mysql/
创建库文件
[root@localhost mysql]# echo "/usr/local/mysql/lib/" >/etc/ld.so.conf.d/mysql.conf
导入man帮助文档
[root@localhost mysql]# echo "MANDATORY_MANPATH /usr/local/mysql/man" >> /etc/man_db.conf
初始化服务
[root@localhost opt]# mysqld --initialize --user mysql --datadir /opt/da/
2022-09-01T13:06:41.825959Z 0 [System] [MY-013169] [Server] /usr/local/mysql-8.0.28-linux-glibc2.12-x86_64/bin/mysqld (mysqld 8.0.28) initializing of server in progress as process 26663
2022-09-01T13:06:41.838275Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-09-01T13:06:42.662468Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2022-09-01T13:06:44.008131Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: 7Td+9aFqJFQc
编辑主配置文件
[root@localhost opt]# cat /etc/my.cnf
[mysqld]
basedir = /usr/local/mysql
datadir = /opt/data
socket = /tmp/mysql.sock
port = 3306
pid-file = /opt/data/mysql.pid
user = mysql
skip-name-resolve
然后安装ncurses-compat-libs
[root@localhost opt]# dnf -y install ncurses-compat-libs
Bad id for repo: mariadb, byte = 0
Last metadata expiration check: 1:33:46 ago on Thu 01 Sep 2022 07:36:49 PM CST.
Package ncurses-compat-libs-6.1-9.20180224.el8.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!
配置服务启动脚本
[root@localhost ~]# cp -a /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@localhost ~]# sed -ri 's#^(basedir=).*#\1/usr/local/mysql#g' /etc/init.d/mysqld
[root@localhost ~]# sed -ri 's#^(datadir=).*#\1/opt/data#g' /etc/init.d/mysqld
启动mysql
[root@localhost ~]# /etc/init.d/mysqld start
Starting MySQL.Logging to '/opt/data/localhost.localdomain.err'.
SUCCESS!
[root@localhost opt]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 127.0.0.1:9000 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 70 *:33060 *:*
LISTEN 0 128 *:3306 *:*
LISTEN 0 128 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
修改密码
[root@localhost opt]# mysql -uroot -p
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.28 MySQL Community Server - GPL
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> alter user 'root'@'localhost' identified by 'liuyang123!' ;
Query OK, 0 rows affected (0.01 sec)
解压zabbix压缩包
[root@localhost opt]# tar xf zabbix-6.2.2.tar.gz
配置zabbix数据库
[root@localhost opt]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12
mysql> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected, 2 warnings (0.02 sec)
mysql> create user 'zabbix'@'localhost' identified by 'liuyang123!'
-> ;
Query OK, 0 rows affected (0.03 sec)
mysql> grant all privileges on zabbix.* to 'zabbix'@'localhost';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> SET GLOBAL log_bin_trust_function_creators = 1;
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
导入数据
[root@localhost mysql]# mysql -uzabbix -pliuyang123! zabbix < schema.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@localhost mysql]# mysql -uzabbix -pliuyang123! zabbix < images.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@localhost mysql]# mysql -uzabbix -pliuyang123! zabbix < data.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
配置源代码
[root@localhost zabbix-6.2.2]# cd /opt/zabbix-6.2.2
[root@localhost zabbix-6.2.2]# ./configure --enable-server --enable-agent --with-mysql --with-libcurl --with-libxml2
Enable agent: yes
Agent details:
TLS: no
Modbus: no
Linker flags: -rdynamic
Libraries: -lz -lpthread -lcurl -lm -ldl -lresolv -lpcre
Configuration file: /usr/local/etc/zabbix_agentd.conf
Modules: /usr/local/lib/modules
Enable agent 2: no
Enable web service: no
Enable Java gateway: no
LDAP support: no
IPv6 support: no
***********************************************************
* Now run 'make install' *
* *
* Thank you for using Zabbix! *
* <http://www.zabbix.com> *
***********************************************************
make install
配置zabbix服务端
[root@localhost src]# cd /etc/zabbix/
[root@localhost zabbix]# ls
web zabbix_agentd.conf zabbix_agentd.d zabbix_server.conf
[root@localhost zabbix]# vim zabbix_server.conf
DBPassword=liuyang123!
标签:opt,root,zabbix,mysql,local,localhost
From: https://www.cnblogs.com/TQingS/p/16648362.html