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] ...
随机推荐
- Mac OS下安装mysqlclient遇到的一些坑
在玩django的同时,必须需要mysqlclient和pillow包,想在本地Mac上装上mysqlclient,但着实遇到不少坑,最终还是在github issue中找到了解决方法,这里记录一下, ...
- pythonl操作数据库
目录 今日内容详细 Navicat软件 提示 练习题 pymysql模块 sql注入 navicat可视化界面操作数据库 数据库查询题目讲解(多表操作) python如何操作MySQL(pymysql ...
- bzoj3892[Usaco2014 Dec]Marathon*
bzoj3892[Usaco2014 Dec]Marathon 题意: 在二维平面上有N个点,从(x1,y1)到(x2,y2)的代价为|x1-x2|+|y1-y2|.求从1号点出发,按从1到N的顺序依 ...
- SQLite数据库多平台应用及常见错误分析
SQLite是一个软件库,实现了自给自足的.无服务器的.零配置的.事务性的SQL数据库引擎.SQLite是世界上最广泛部署的数据库引擎之一.SQLite源代码开放,没有授权限制.正是因为其免费.轻巧. ...
- Ethical Hacking - NETWORK PENETRATION TESTING(2)
ALFA AWUS 1900 RTL8814AU https://www.alfa.com.tw/products_detail/2.htm Follow the guide on aircrac ...
- ztree : checkbox 选中/不选中时动态添加/删除DOM元素
先上代码. var IDMark_Switch = "_switch", IDMark_Icon = "_ico", IDMark_Span = "_ ...
- K8s-Pod健康检查原理与实践
Pod健康检查介绍 默认情况下,kubelet根据容器运行状态作为健康依据,不能监视容器中应用程序状态,例如程序假死.这将会导致无法提供服务,丢失流量.因此重新健康检查机制确保容器健康幸存.Pod通过 ...
- 9.CSMA_CD协议
先听再说,边听边说 载波监听多点接入/碰撞检测CSMA/CD( carrier sense multiple access with collision detection) CD:碰撞检测(冲突检测 ...
- 高效C++:实现
本章主要是解决如下问题: 类的声明和定义在什么时候提出 类与类之间的耦合关系如何降低 类型转换怎么正确使用 尽可能延后变量定义式的出现 变量用到时在定义,不要提前定义,防止变量定义而没有使用的情况,因 ...
- 设计模式:Adapter模式
目的:复用代码和兼容以前的代码 思想:提供一个中间层,做兼容 方法:“继承”的方式,“委托”的方式 继承关系图: 委托方式 继承方式 例子: //原来的打印 class Print { public: ...