04 MySQL多实例部署
软件下载
//下载二进制格式的mysql软件包
[root@localhost ~]# cd /usr/src/
[root@localhost src]# wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.34-linux-glibc2.12-x86_64.tar.gz
--2021-11-07 14:22:15-- https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.34-linux-glibc2.12-x86_64.tar.gz
正在解析主机 downloads.mysql.com (downloads.mysql.com)... 137.254.60.14
正在连接 downloads.mysql.com (downloads.mysql.com)|137.254.60.14|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 302 Found
位置:https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.34-linux-glibc2.12-x86_64.tar.gz [跟随至新的 URL]
--2021-11-07 14:22:18-- https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.34-linux-glibc2.12-x86_64.tar.gz
正在解析主机 cdn.mysql.com (cdn.mysql.com)... 2.18.233.231
正在连接 cdn.mysql.com (cdn.mysql.com)|2.18.233.231|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:665389778 (635M) [application/x-tar-gz]
正在保存至: “mysql-5.7.34-linux-glibc2.12-x86_64.tar.gz”mysql-5.7.34-linux-glibc2 100%[===================================>] 634.56M 704KB/s 用时 14m 16s 2021-11-07 14:36:38 (759 KB/s) - 已保存 “mysql-5.7.34-linux-glibc2.12-x86_64.tar.gz” [665389778/665389778])[root@localhost src]#
配置用户和组并解压二进制程序至/usr/local下
//创建用户和组
[root@localhost src]# groupadd -r mysql
[root@localhost src]# useradd -M -s /sbin/nologin -g mysql mysql//解压软件至/usr/local/
[root@localhost src]# ls
debug kernels mysql-5.7.34-linux-glibc2.12-x86_64.tar.gz
[root@localhost src]# tar xf mysql-5.7.34-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
[root@localhost src]# ls /usr/local/
bin etc games include lib lib64 libexec mysql-5.7.34-linux-glibc2.12-x86_64 sbin share src
[root@localhost src]# cd /usr/local/
[root@localhost local]# ln -s mysql-5.7.34-linux-glibc2.12-x86_64/ mysql
[root@localhost local]# ll
总用量 0
drwxr-xr-x. 2 root root 6 8月 12 2018 bin
drwxr-xr-x. 2 root root 6 8月 12 2018 etc
drwxr-xr-x. 2 root root 6 8月 12 2018 games
drwxr-xr-x. 2 root root 6 8月 12 2018 include
drwxr-xr-x. 2 root root 6 8月 12 2018 lib
drwxr-xr-x. 2 root root 6 8月 12 2018 lib64
drwxr-xr-x. 2 root root 6 8月 12 2018 libexec
lrwxrwxrwx 1 root root 36 11月 7 14:42 mysql -> mysql-5.7.34-linux-glibc2.12-x86_64/
drwxr-xr-x 9 root root 129 11月 7 14:40 mysql-5.7.34-linux-glibc2.12-x86_64
drwxr-xr-x. 2 root root 6 8月 12 2018 sbin
drwxr-xr-x. 5 root root 49 9月 30 09:11 share
drwxr-xr-x. 2 root root 6 8月 12 2018 src
[root@localhost local]#
//修改目录/usr/local/mysql的属主属组
[root@localhost local]# chown -R mysql.mysql /usr/local/mysql
[root@localhost local]# ll /usr/local/mysql
//配置环境变量
[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]# echo $PATH
/usr/local/mysql/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
[root@localhost local]# which mysql
/usr/local/mysql/bin/mysql
[root@localhost local]#
创建各实例数据存放的目录
[root@localhost local]# mkdir -p /opt/data/{3306,3307,3308}
[root@localhost local]# chown mysql.mysql /opt/data/{3306,3307,3308}
[root@localhost local]# cd /opt/data/
[root@localhost data]# ll
总用量 0
drwxr-xr-x 2 mysql mysql 6 11月 7 14:47 3306
drwxr-xr-x 2 mysql mysql 6 11月 7 14:47 3307
drwxr-xr-x 2 mysql mysql 6 11月 7 14:47 3308
[root@localhost data]# cd
初始化各实例
//初始化3306
[root@localhost ~]# /usr/local/mysql/bin/mysqld --initialize --user=mysql --datadir=/opt/data/3306
2021-11-07T06:54:48.103068Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-11-07T06:54:48.211635Z 0 [Warning] InnoDB: New log files created, LSN=45790
2021-11-07T06:54:48.230370Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2021-11-07T06:54:48.235850Z 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: 991228a6-3f97-11ec-9ff0-000c29b91252.
2021-11-07T06:54:48.236353Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2021-11-07T06:54:48.822771Z 0 [Warning] CA certificate ca.pem is self signed.
2021-11-07T06:54:49.222888Z 1 [Note] A temporary password is generated for root@localhost: 2&ie7sfG.aOa
[root@localhost ~]# echo '2&ie7sfG.aOa' > 3306_pass
[root@localhost ~]# cat 3306_pass
2&ie7sfG.aOa//初始化3307
[root@localhost ~]# /usr/local/mysql/bin/mysqld --initialize --user=mysql --datadir=/opt/data/3307
2021-11-07T06:56:11.802336Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-11-07T06:56:12.466590Z 0 [Warning] InnoDB: New log files created, LSN=45790
2021-11-07T06:56:12.655912Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2021-11-07T06:56:12.689396Z 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: cb68bf34-3f97-11ec-a466-000c29b91252.
2021-11-07T06:56:12.690954Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2021-11-07T06:56:13.146813Z 0 [Warning] CA certificate ca.pem is self signed.
2021-11-07T06:56:13.249333Z 1 [Note] A temporary password is generated for root@localhost: QQw_wQeat7wv
[root@localhost ~]# echo 'QQw_wQeat7wv' > 3307_pass
[root@localhost ~]# cat 3307_pass
QQw_wQeat7wv//初始化3308
[root@localhost ~]# /usr/local/mysql/bin/mysqld --initialize --user=mysql --datadir=/opt/data/3308
2021-11-07T06:57:28.136080Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-11-07T06:57:32.910652Z 0 [Warning] InnoDB: New log files created, LSN=45790
2021-11-07T06:57:33.083388Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2021-11-07T06:57:33.171827Z 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: fb616436-3f97-11ec-a742-000c29b91252.
2021-11-07T06:57:33.172679Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2021-11-07T06:57:34.413641Z 0 [Warning] CA certificate ca.pem is self signed.
2021-11-07T06:57:34.779236Z 1 [Note] A temporary password is generated for root@localhost: yhl/Rh2tEPI.
[root@localhost ~]# echo 'yhl/Rh2tEPI.' > 3308_pass
[root@localhost ~]# cat 3308_pass
yhl/Rh2tEPI.
[root@localhost ~]#
//安装perl
[root@localhost ~]# yum -y install perl
//ldd是看某一个程序文件它所依赖的包,如果没有,就不能用,就需要用yum安装,查找哪个包提供的yum whatprovides pkgs_name
[root@localhost ~]# ldd /usr/local/mysql/bin/mysqllinux-vdso.so.1 (0x00007ffdcd95c000)libpthread.so.0 => /lib64/libpthread.so.0 (0x00007ff4c766e000)librt.so.1 => /lib64/librt.so.1 (0x00007ff4c7465000)libdl.so.2 => /lib64/libdl.so.2 (0x00007ff4c7261000)libncurses.so.5 => not foundlibstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007ff4c6ecc000)libm.so.6 => /lib64/libm.so.6 (0x00007ff4c6b4a000)libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007ff4c6932000)libc.so.6 => /lib64/libc.so.6 (0x00007ff4c6570000)/lib64/ld-linux-x86-64.so.2 (0x00007ff4c788e000)libtinfo.so.5 => not found[root@localhost ~]# yum whatprovides libtinfo.so.5
[root@localhost ~]# yum -y install ncurses-compat-libs
//配置配置文件/etc/my.cnf
[root@localhost ~]# vim /etc/my.cnf
[root@localhost ~]# cat /etc/my.cnf
[mysqld_multi]
mysqld = /usr/local/mysql/bin/mysqld_safe
mysqladmin = /usr/local/mysql/bin/mysqladmin[mysqld3306]
datadir = /opt/data/3306
socket = /tmp/mysql3306.sock
port = 3306
pid-file = /opt/data/3306/mysql_3306.pid
log-error = /var/log/3306.log[mysqld3307]
datadir = /opt/data/3307
socket = /tmp/mysql3307.sock
port = 3307
pid-file = /opt/data/3307/mysql_3307.pid
log-error = /var/log/3307.log[mysqld3308]
datadir = /opt/data/3308
socket = /tmp/mysql3308.sock
port = 3308
pid-file = /opt/data/3308/mysql_3308.pid
log-error = /var/log/3308.log[root@localhost ~]#
//启动各实例
[root@localhost ~]# mysqld_multi start
Wide character in print at /usr/local/mysql/bin/mysqld_multi line 678.
[root@localhost ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 80 *:3306 *:*
LISTEN 0 80 *:3307 *:*
LISTEN 0 80 *:3308 *:*
[root@localhost ~]#
//修改临时密码密码
[root@localhost ~]# cat 3306_pass
2&ie7sfG.aOa
[root@localhost ~]# mysql -uroot -p'2&ie7sfG.aOa' -P3306 -h127.0.0.1
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 3
Server version: 5.7.34Copyright (c) 2000, 2021, 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> set password = password('1');
Query OK, 0 rows affected, 1 warning (0.00 sec)mysql> exit
Bye
[root@localhost ~]# cat 3307_pass
QQw_wQeat7wv
[root@localhost ~]# mysql -uroot -p'QQw_wQeat7wv' -P3307 -h127.0.0.1
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 2
Server version: 5.7.34Copyright (c) 2000, 2021, 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> set password = password('1');
Query OK, 0 rows affected, 1 warning (0.00 sec)mysql> exit
Bye
[root@localhost ~]# cat 3308_pass
yhl/Rh2tEPI.
[root@localhost ~]# mysql -uroot -p'yhl/Rh2tEPI.' -P3308 -h127.0.0.1
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 2
Server version: 5.7.34Copyright (c) 2000, 2021, 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> set password = password('1');
Query OK, 0 rows affected, 1 warning (0.00 sec)mysql> exit
Bye
多实例设置服务:
停止MySQL服务用 pkill mysqld , 启动服务用 /usr/local/mysql/support-files/mysqld_multi.server start
1.设置开机自启 :把 /usr/local/mysql/bin/support.files/mysqld_multi.server 文件复制到 /etc/init.d/mysqld.server
[root@localhost ~]# cd /etc/init.d/
[root@localhost init.d]# cp /usr/local/mysql/support-files/mysqld_multi.server ./mysqld.server
[root@localhost init.d]# ls
functions mysqld.server README
[root@localhost init.d]#
2. 在/etc/init.d/mysqld.server 文件中增加环境变量设置 export PATH=/usr/local/mysql/bin: $PATH
[root@localhost init.d]# vim mysqld.server
16 export PATH=/usr/local/mysql/bin/:$PATH //添加环境变量
3. chkconfig --add mysqld.server
[root@localhost init.d]# chkconfig --add mysqld.server
[root@localhost init.d]# chkconfig --list注:该输出结果只显示 SysV 服务,并不包含
原生 systemd 服务。SysV 配置数据
可能被原生 systemd 配置覆盖。 要列出 systemd 服务,请执行 'systemctl list-unit-files'。查看在具体 target 启用的服务请执行'systemctl list-dependencies [target]'。mysqld.server 0:关 1:关 2:开 3:开 4:开 5:开 6:关
[root@localhost init.d]#
04 MySQL多实例部署相关推荐
- mysql 多实例部署、xtrabackup下载与安装
mysql 多实例部署 一. 二进制安装mysql 软件下载 下载网络源 curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyu ...
- MySQL 多实例部署 xtrabackup备份与恢复
MySQL 多实例部署 1.下载安装包 [root@localhost ~]# wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7. ...
- MYSQl 多实例部署
MYSQl 多实例部署和 Xtarbackup 软件下载安装 下载二进制格式的mysql软件包 [root@localhost ~]# cd /usr/src/ [root@localhost ~]# ...
- mysql数据库备份与恢复,mysql多实例部署
mysql数据库备份与恢复,mysql多实例部署 文章目录 mysql数据库备份与恢复,mysql多实例部署 1: 数据库备份 2:冷备份 3:热备份 4:mysql备份工具mysqldump 5:差 ...
- mysql 单实例部署_Mysql 数据库单机多实例部署手记
最近的研发机器需要部署多个环境,包括数据库.为了管理方便考虑将mysql数据库进行隔离,即采用单机多实例部署的方式. 找了会资料发现用的人也不是太多,一般的生产环境为了充分发挥机器性能都是单机单实例运 ...
- mysql多实例部署
二进制文件下载 [root@localhost ~]# cd /usr/src/ [root@localhost src]# wget https://downloads.mysql.com/arch ...
- mysql 单实例部署_MySQL 5.5单实例 编译安装
1.建立MySQL账号 首先以root登录到Linux,然后执行如下命令创建MySQL组及用户[root@loveyu home]# groupadd mysql [root@loveyu home] ...
- mysql差异备份与多实例部署
mysql差异备份与多实例部署 文章目录 差异备份与恢复 mysql多实例部署 差异备份与恢复 差异备份简单来说就是备份自上一次完整备份之后有变化的数据 //开启mysql服务的二进制日志功能 [ro ...
- MySQL单机多实例部署详解之------利用mysqld_multi配置实现
一.mysql多实例的原理 mysql多实例,简单的说,就是在一台服务器上开启多个不同的mysql服务端口(如3306,3307),运行多个mysql服务进程.这些服务进程通过不同的socket监听不 ...
最新文章
- 数字图像处理——第六章 彩色图像处理
- 【译】Monolith first —— Martin Fowler 对于微服务架构的看法
- 为什么阿里巴巴禁止使用存储过程?
- PAT甲级1088 Rational Arithmetic:[C++题解]分数的加减乘除
- Intel Realsense D435 关于深度摄像头获取实际深度坐标时的常见问题及可能的解决方案
- 将不确定变为确定~transactionscope何时提升为分布式事务?
- 软件体系结构设计文档_一个java架构师是如何设计出一个好的架构的
- 洛谷团队月赛题:题解
- 【转】RabbitMQ六种队列模式-2.工作队列模式
- 播放视频中称比例的计算
- vb取消文本框的粘贴功能
- java和python和php_Java、Python和PHP三者的区别
- PAT甲级1009 多项式相乘
- Python脚本访问子目录
- Hadoop组件介绍
- margin与padding的区别
- linux权限管理详解
- 分析报告_问题界定篇
- 【微信小程序】引入Base64 图标库
- 深脑链打地基,人工智能建高楼:DBC和AI的不解之缘
热门文章
- Linux自我学习笔记03
- vue启动报错Module build failed: Error: ENOENT: no such file or directory
- 编译error: no acceptable C compiler found in $PATH
- boss直聘账号异常登不上_五条人XBOSS直聘推出麻将盲盒
- 拖延症:关于如何停止拖延的科学指南
- 失物招领|基于Web的校园失物招领系统的设计与实现
- STM32定时器延时函数
- 虚拟机建立游戏服务器,在虚拟机上创建游戏服务器
- deny后加to do还是doing_为什么英语中有些动词后只能接 doing,而不能接 to do?
- ubuntu 16.04极速安装ROS-Kinetic,以及常见错误处理