mysqld_multi多实例部署
mysql多实例部署
下载软件
[root@localhost ~]# ls
anaconda-ks.cfg mysql-5.7.29-linux-glibc2.12-x86_64.tar.gz
#安装perl
[root@localhost ~]# yum -y install perl
配置用户和组并解压二进制程序至/usr/local下
#创建用户和组
[root@localhost ~]# groupadd -r mysql
[root@localhost ~]# useradd -r -M -s /sbin/nologin -g mysql mysql
#解压mysql到/usr/local/
[root@localhost ~]# tar xf mysql-5.7.29-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
[root@localhost ~]# ls /usr/local/
bin games lib libexec sbin src
etc include lib64 mysql-5.7.29-linux-glibc2.12-x86_64 share
[root@localhost local]# ln -s mysql-5.7.29-linux-glibc2.12-x86_64/ mysql
[root@localhost local]# ll
total 0
drwxr-xr-x. 2 root root 6 Apr 11 2018 bin
drwxr-xr-x. 2 root root 6 Apr 11 2018 etc
drwxr-xr-x. 2 root root 6 Apr 11 2018 games
drwxr-xr-x. 2 root root 6 Apr 11 2018 include
drwxr-xr-x. 2 root root 6 Apr 11 2018 lib
drwxr-xr-x. 2 root root 6 Apr 11 2018 lib64
drwxr-xr-x. 2 root root 6 Apr 11 2018 libexec
lrwxrwxrwx. 1 root root 36 Jun 18 22:20 mysql -> mysql-5.7.29-linux-glibc2.12-x86_64/
drwxr-xr-x. 9 root root 129 Jun 18 22:20 mysql-5.7.29-linux-glibc2.12-x86_64
drwxr-xr-x. 2 root root 6 Apr 11 2018 sbin
drwxr-xr-x. 5 root root 49 Apr 7 04:48 share
drwxr-xr-x. 2 root root 6 Apr 11 2018 src
#修改目录/usr/local/mysql的属主属组
[root@localhost ~]# chown -R mysql.mysql /usr/local/mysql
[root@localhost ~]# ll -d /usr/local/mysql
lrwxrwxrwx. 1 mysql mysql 36 Jun 18 22:20 /usr/local/mysql -> mysql-5.7.29-linux-glibc2.12-x86_64
#配置环境变量
[root@localhost ~]# echo 'export PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
[root@localhost ~]# . /etc/profile.d/mysql.sh
[root@localhost ~]# echo $PATH
/usr/local/mysql/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
创建实例数据存放的目录
[root@localhost ~]# mkdir -p /opt/data/{3306,3307,3308}
[root@localhost ~]# chown -R mysql.mysql /opt/data/
初始化各实例
[root@localhost ~]# /usr/local/mysql/bin/mysqld --initialize --datadir=/opt/data/3306/ --user=mysql
2020-06-19T02:26:51.119557Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-06-19T02:26:51.289336Z 0 [Warning] InnoDB: New log files created, LSN=45790
2020-06-19T02:26:51.317903Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2020-06-19T02:26:51.373831Z 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: 557e31d8-b1d4-11ea-8616-000c29d7d941.
2020-06-19T02:26:51.374438Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2020-06-19T02:26:51.639794Z 0 [Warning] CA certificate ca.pem is self signed.
2020-06-19T02:26:51.679383Z 1 [Note] A temporary password is generated for root@localhost: rs3+GHrW/qo)
[root@localhost ~]# echo 'rs3+GHrW/qo)' > 3306_pass
[root@localhost ~]# /usr/local/mysql/bin/mysqld --initialize --datadir=/opt/data/3307/ --user=mysql
2020-06-19T02:28:04.740186Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-06-19T02:28:04.905282Z 0 [Warning] InnoDB: New log files created, LSN=45790
2020-06-19T02:28:04.934119Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2020-06-19T02:28:04.988177Z 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: 815eda45-b1d4-11ea-883b-000c29d7d941.
2020-06-19T02:28:04.988744Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2020-06-19T02:28:05.572008Z 0 [Warning] CA certificate ca.pem is self signed.
2020-06-19T02:28:05.629436Z 1 [Note] A temporary password is generated for root@localhost: Zf&stNghV6Kl
[root@localhost ~]# echo 'Zf&stNghV6Kl' > 3307_pass
[root@localhost ~]# /usr/local/mysql/bin/mysqld --initialize --datadir=/opt/data/3308/ --user=mysql
2020-06-19T02:28:50.562599Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-06-19T02:28:50.724362Z 0 [Warning] InnoDB: New log files created, LSN=45790
2020-06-19T02:28:50.751944Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2020-06-19T02:28:50.806578Z 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: 9cae2f9d-b1d4-11ea-8b25-000c29d7d941.
2020-06-19T02:28:50.807144Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2020-06-19T02:28:51.476355Z 0 [Warning] CA certificate ca.pem is self signed.
2020-06-19T02:28:51.808583Z 1 [Note] A temporary password is generated for root@localhost: 5fh/s=!924IX
[root@localhost ~]# echo '5fh/s=!924IX' > 3308_pass
配置配置文件/etc/my.cnf
[root@localhost ~]# vim /etc/my.cnf
[mysqld_multi]
mysqld = /usr/local/mysql/bin/mysqld_safe
mysqladmin = /usr/local/mysql/bin/mysqladmin
user = multi_admin
password = my_password
[mysqld3306]
datadir = /opt/data/3306
port = 3306
socket = /tmp/mysql3306.sock
pid-file = /opt/data/3306/mysql_3306.pid
log-error=/var/log/3306.log
[mysqld3307]
datadir = /opt/data/3307
port = 3307
socket = /tmp/mysql3307.sock
pid-file = /opt/data/3307/mysql_3307.pid
log-error=/var/log/3307.log
[mysqld3308]
datadir = /opt/data/3308
port = 3308
socket = /tmp/mysql3308.sock
pid-file = /opt/data/3308/mysql_3308.pid
log-error=/var/log/3308.log
启动各实例
[root@localhost ~]# /usr/local/mysql/bin/mysqld_multi start 3306
[root@localhost ~]# /usr/local/mysql/bin/mysqld_multi start 3307
[root@localhost ~]# /usr/local/mysql/bin/mysqld_multi start 3308
[root@localhost ~]# /usr/local/mysql/bin/mysqld_multi report
Reporting MySQL servers
MySQL server from group: mysqld3306 is running
MySQL server from group: mysqld3307 is running
MySQL server from group: mysqld3308 is running
[root@localhost ~]# ss -tanl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 100 [::1]:25 [::]:*
LISTEN 0 80 [::]:3306 [::]:*
LISTEN 0 80 [::]:3307 [::]:*
LISTEN 0 80 [::]:3308 [::]:*
LISTEN 0 128 [::]:22 [::]:*
初始化密码
[root@localhost ~]# ls
3306_pass 3307_pass 3308_pass anaconda-ks.cfg mysql-5.7.29-linux-glibc2.12-x86_64.tar.gz
[root@localhost ~]# cat 3306_pass
rs3+GHrW/qo)
[root@localhost ~]# /usr/local/mysql/bin/mysql -uroot -p'rs3+GHrW/qo)' -S /tmp/mysql3306.sock
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.29
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
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>
mysql> quit
Bye
[root@localhost ~]# cat 3307_pass
Zf&stNghV6Kl
[root@localhost ~]# /usr/local/mysql/bin/mysql -uroot -p'Zf&stNghV6Kl' -S /tmp/mysql3307.sock --connect-expired-password -e 'set password=password("qwer!@#$")'
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@localhost ~]# cat 3308_pass
5fh/s=!924IX
[root@localhost ~]# /usr/local/mysql/bin/mysql -uroot -p'5fh/s=!924IX' -S /tmp/mysql3308.sock --connect-expired-password -e 'set password=password("qwer!@#$")'
mysql: [Warning] Using a password on the command line interface can be insecure.
关闭实例
#关闭3307实例
//需要在数据库实例上创建一个账户用来关闭数据库,该账户的用户名和密码和配置文件中[mysqld_multi] 中配置的一样
[root@localhost ~]# mysql -uroot -p'qwer!@#$' -S /tmp/mysql3307.sock
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 11
Server version: 5.7.29 MySQL Community Server (GPL)
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
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> GRANT SHUTDOWN ON *.* TO 'multi_admin'@'localhost' IDENTIFIED BY 'my_password';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
#复制222行注释,在原本的defaults后加上-s
[root@localhost ~]# vim /usr/local/mysql/bin/mysqld_multi
# my $com= join ' ', 'my_print_defaults', @defaults_options, $group;
my $com= join ' ', 'my_print_defaults -s', @defaults_options, $group;
#关闭3307实例
[root@localhost ~]# mysqld_multi stop 3307
[root@localhost ~]# mysqld_multi report
Reporting MySQL servers
MySQL server from group: mysqld3306 is running
MySQL server from group: mysqld3307 is not running
MySQL server from group: mysqld3308 is running
[root@localhost ~]# ss -tanl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 100 [::1]:25 [::]:*
LISTEN 0 80 [::]:3306 [::]:*
LISTEN 0 80 [::]:3308 [::]:*
LISTEN 0 128 [::]:22 [::]:*
#再启用3307实例
[root@localhost ~]# mysqld_multi start 3307
[root@localhost ~]# mysqld_multi report
Reporting MySQL servers
MySQL server from group: mysqld3306 is running
MySQL server from group: mysqld3307 is running
MySQL server from group: mysqld3308 is running
[root@localhost ~]# ss -tanl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 100 [::1]:25 [::]:*
LISTEN 0 80 [::]:3306 [::]:*
LISTEN 0 80 [::]:3307 [::]:*
LISTEN 0 80 [::]:3308 [::]:*
LISTEN 0 128 [::]:22 [::]:*
mysqld_multi多实例部署的更多相关文章
- mysql 5.5多实例部署【图解】
mysql5.5数据库多实例部署,我们可以分以下几个步骤来完成. 1. mysql多实例的原理 2. mysql多实例的特点 3. mysql多实例应用场景 4. mysql5.5多实例部署方法 一. ...
- 烂泥:mysql5.5多实例部署
本文由秀依林枫提供友情赞助,首发于烂泥行天下. mysql5.5数据库多实例部署,我们可以分以下几个步骤来完成. 1. mysql多实例的原理 2. mysql多实例的特点 3. mysql多实例应用 ...
- Mysql 数据库单机多实例部署手记
最近的研发机器需要部署多个环境,包括数据库.为了管理方便考虑将mysql数据库进行隔离,即采用单机多实例部署的方式.找了会资料发现用的人也不是太多,一般的生产环境为了充分发挥机器性能都是单机单 ...
- MySQL5.6多实例部署
原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://suifu.blog.51cto.com/9167728/1850560 无论是迫 ...
- mysql 5.5多实例部署
mysql5.5数据库多实例部署,我们可以分以下几个步骤来完成. 1. mysql多实例的原理 2. mysql多实例的特点 3. mysql多实例应用场景 4. mysql5.5多实例部署方法 一. ...
- MySQL-5.6.36-多实例-部署(编译版)
MySQL多实例_沁贰百科 注:部署双实例前,首先需要部署单实例,单实例部署详情如下: https://www.cnblogs.com/wangqiner/p/9081002.html 1.如已经安装 ...
- Tomcat多实例部署
前言 以前总是采用很Low的方式太同一台服务器上部署多个Web应用,步骤是这样的:Copy Tomcat目录-->更改conf/server.xml三个端口号----->部署war包--- ...
- 性能测试二十:环境部署之Tomcat多实例部署+日志监控
一个tomcat性能有限,所以需要部署等多个tomcat 单实例部署与windows下类似,项目包放到webapp目录下,启动bin目录下的startup.sh即可启动命令:./startup.sh启 ...
- redis安装,修改配置文件,多实例部署 redis-server
redis 安装 解压: [root@Aliyun software]# tar -xvf redis-3.2.11.tar.gz 进入redis根目录: [root@Aliyun software] ...
随机推荐
- SqlLite用SQLiteTransaction快速导入数据
mysql与sql server都有整表导入的类库,但是查遍了资料发现sqlLite没有,除非自己去写个,发现用SQLiteTransaction导入数据也很快,附上代码 /// <summar ...
- 从零开始使用 Webpack 搭建 Vue3 开发环境
从零开始使用 Webpack 搭建 Vue3 开发环境 创建项目 首先需要创建一个空目录,在该目录打开命令行,执行 npm init 命令创建一个项目,这个过程会提示输入一些内容,完成后会自动生成一个 ...
- SpringBoot日志功能
三.SpringBoot日志功能 1.日志框架 市面上的日志框架: JUL.JCL.Jboss-logging.Logback.Log4j.Log4j.SLF4J... 日志门面(日志的抽象层) 日志 ...
- Alink漫谈(十) :线性回归实现 之 数据预处理
Alink漫谈(十) :线性回归实现 之 数据预处理 目录 Alink漫谈(十) :线性回归实现 之 数据预处理 0x00 摘要 0x01 概念 1.1 线性回归 1.2 优化模型 1.3 损失函数& ...
- java 面向对象(十七):单元测试方法
* Java中的JUnit单元测试 * * 步骤: * 1.中当前工程 - 右键择:build path - add libraries - JUnit 4 - 下一步 * 2.创建Java类,进行单 ...
- Python网络编程04 /recv工作原理、展示收发问题、粘包现象
Python网络编程04 /recv工作原理.展示收发问题.粘包现象 目录 Python网络编程04 /recv工作原理.展示收发问题.粘包现象 1. recv工作原理 2. 展示收发问题示例 发多次 ...
- 关于报错,Whoops! Lost connection to ws://XXX.XXX.XXX.XXX:15684/ws
昨天,在玩rabbitMQ时候,用stompJS从web连接ranbbitMQ时,报了标题的错误消息! 我把我这个html页面代码贴上,简单得讲,就是断开后,重新连接即可.
- (2)简单理解和使用webpack-dev-server
webpack-dev-server能做什么? 每次打包都得像之前一样使用webapck 入口文件 -o 出口文件,每次修改都得打包一次过于麻烦,可以使用webpack-dev-server实现自动打 ...
- 没想到 Google 排名第一的编程语言,为什么会这么火?
没想到吧,Python 又拿第一了! 在 Google 公布的编程语言流行指数中,Python 依旧是全球范围内最受欢迎的技术语言! 01 为什么 Python 会这么火? 核心还是因为企业需要用 ...
- Getting Started with Recovery Manager (RMAN) (文档 ID 360416.1)
In this Document Purpose Scope Details Overview of the RMAN EnvironmentDeciding Whether to Use a Fla ...