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] ...
随机推荐
- 深入Mybatis源码——配置解析
@ 目录 前言 正文 配置解析 1. cacheRefElement/cacheElement 2. resultMapElements 3. sqlElement 4. buildStatement ...
- day58 作业
目录 一.做一个图书管理系统页面 二.做一个主页模版 三.点赞 一.做一个图书管理系统页面 <!DOCTYPE html> <html lang="en"> ...
- JVM(完成度95%,不断更新)
一.HotSpot HotSpot是最新的虚拟机,替代了JIT,提高Java的运行性能.Java原先是将源代码编译为字节码在虚拟机运行,HotSpot将常用的部分代码编译为本地代码. 对象创建过程 类 ...
- 机器学习实战基础(三十五):随机森林 (二)之 RandomForestClassifier 之重要参数
RandomForestClassifier class sklearn.ensemble.RandomForestClassifier (n_estimators=’10’, criterion=’g ...
- redis(十):Redis 列表(List)
Redis 列表(List) Redis列表是简单的字符串列表,按照插入顺序排序.你可以添加一个元素到列表的头部(左边)或者尾部(右边) 一个列表最多可以包含 232 - 1 个元素 (4294967 ...
- 【JVM】或许,这就是二进制Class吧
水稻:看你研究盯着这个文档一天了,什么玩意让人心驰神往 菜瓜:前几天意外得到一本武功秘籍<jvms8>,看起来就情不自禁 水稻:这不是Java虚拟机的说明文档吗<PS:投来惊吓的目光 ...
- bzoj2160拉拉队排练
bzoj2160拉拉队排练 题意: 给一个字符串,求最长的k个回文子串(此处回文子串长度必须为奇数)长度的乘积.字符串长度≤1000000 题解: 先用manacher预处理出第i个字符为中心的最长回 ...
- 计算机网络学习socket--day1
socket编程 socket可以看成是用户进程与内核网络协议栈的编程接口 socket不仅可以用于本机的进程间通信,还可以用于网络上不同主机的进程间通信 socket全双工通信 在异构系统间进行通信 ...
- 性能测试必备知识(5)- 深入理解“CPU 上下文切换”
做性能测试的必备知识系列,可以看下面链接的文章哦 https://www.cnblogs.com/poloyy/category/1806772.html 前言 上一篇文章中,举例了大量进程等待 CP ...
- 【管理员已阻止你运行此应用】windows defender图标打叉,无法打开mmc.exe解决办法
今天开机遇到一个奇怪的问题,发现windows defender图标上面打了个×: 打开按照系统提示需要restart服务,但是无法重启服务,会出现错误,然后尝试手动重启服务,准备打开管理控制台mmc ...