mysql多实例部署
安装mysql
[root@192 ~]# useradd -r -M -s /sbin/nologin mysql //创建用户
[root@192 ~]# cd /usr/src/
[root@192 src]# tar -xf mysql-5.7.37-linux-glibc2.12-x86_64.tar.gz -C /usr/local/ //解压软件包、
[root@192 src]# cd /usr/local/
[root@192 local]# mv mysql-5.7.37-linux-glibc2.12-x86_64/ mysql
[root@192 local]# chown -R mysql.mysql mysql/ //修改权限
[root@192 local]# echo 'export PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
[root@192 local]# source /etc/profile.d/mysql.sh
[root@192 local]# which mysql
/usr/local/mysql/bin/mysql //配置环境变量
[root@192 mysql]# ln -s /usr/local/mysql/include/ /usr/include/mysql //配置include软连接
[root@192 mysql]# vim /etc/ld.so.conf.d/mysql.conf
[root@192 mysql]# cat /etc/ld.so.conf.d/mysql.conf //配置lib库
/usr/local/mysql/lib
[root@192 mysql]# vim /etc/man_db.conf //添加man文档
MANDATORY_MANPATH /usr/local/mysql/man
#创建数据库目录
[root@192 ~]# mkdir -p /opt/data/{3306,3307,3308}
[root@192 ~]# chown -R mysql.mysql /opt/data/
[root@192 ~]# cd /opt/data/
[root@192 data]# ll
总用量 0
drwxr-xr-x. 2 mysql mysql 6 7月 2 11:37 3306
drwxr-xr-x. 2 mysql mysql 6 7月 2 11:37 3307
drwxr-xr-x. 2 mysql mysql 6 7月 2 11:37 3308
配置多实例部署
3306初始化
[root@192 ~]# mysqld --initialize --user=mysql --datadir=/opt/data/3306
2022-07-02T03:39:07.431121Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-07-02T03:39:07.703358Z 0 [Warning] InnoDB: New log files created, LSN=45790
2022-07-02T03:39:07.831924Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2022-07-02T03:39:07.952119Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 8737c75c-f9b8-11ec-a29d-000c29d84f4a.
2022-07-02T03:39:07.952946Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2022-07-02T03:39:08.607273Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2022-07-02T03:39:08.607289Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2022-07-02T03:39:08.607957Z 0 [Warning] CA certificate ca.pem is self signed.
2022-07-02T03:39:08.937337Z 1 [Note] A temporary password is generated for root@localhost: q/m?Crf5iM#o
[root@192 ~]# echo 'q/m?Crf5iM#o' > 3306 //保存3306的