我的编程空间,编程开发者的网络收藏夹
学习永远不晚

怎么利用mysqld_multi配置单机多实例

短信预约 -IT技能 免费直播动态提醒
省份

北京

  • 北京
  • 上海
  • 天津
  • 重庆
  • 河北
  • 山东
  • 辽宁
  • 黑龙江
  • 吉林
  • 甘肃
  • 青海
  • 河南
  • 江苏
  • 湖北
  • 湖南
  • 江西
  • 浙江
  • 广东
  • 云南
  • 福建
  • 海南
  • 山西
  • 四川
  • 陕西
  • 贵州
  • 安徽
  • 广西
  • 内蒙
  • 西藏
  • 新疆
  • 宁夏
  • 兵团
手机号立即预约

请填写图片验证码后获取短信验证码

看不清楚,换张图片

免费获取短信验证码

怎么利用mysqld_multi配置单机多实例

这篇文章给大家分享的是有关怎么利用mysqld_multi配置单机多实例的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。

环境:redhat6.5+mysql5.6.21
[root@linfytest2 bin]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.5 (Santiago)
[root@linfytest2 bin]# ./mysqld --version
./mysqld  Ver 5.6.21 for Linux on x86_64 (Source distribution)

mysqld_multi的样例:
[root@linfytest2 bin]# ./mysqld_multi --example
# This is an example of a my.cnf file for mysqld_multi.
# Usually this file is located in home dir ~/.my.cnf or /etc/my.cnf
#
# SOME IMPORTANT NOTES FOLLOW:
#
# 1.COMMON USER
#
#   Make sure that the MySQL user, who is stopping the mysqld services, has
#   the same password to all MySQL servers being accessed by mysqld_multi.
#   This user needs to have the 'Shutdown_priv' -privilege, but for security
#   reasons should have no other privileges. It is advised that you create a
#   common 'multi_admin' user for all MySQL servers being controlled by
#   mysqld_multi. Here is an example how to do it:
#
#   GRANT SHUTDOWN ON *.* TO multi_admin@localhost IDENTIFIED BY 'password'
#
#   You will need to apply the above to all MySQL servers that are being
#   controlled by mysqld_multi. 'multi_admin' will shutdown the servers
#   using 'mysqladmin' -binary, when 'mysqld_multi stop' is being called.
#
# 2.PID-FILE
#
#   If you are using mysqld_safe to start mysqld, make sure that every
#   MySQL server has a separate pid-file. In order to use mysqld_safe
#   via mysqld_multi, you need to use two options:
#
#   mysqld=/path/to/mysqld_safe
#   ledir=/path/to/mysqld-binary/
#
#   ledir (library executable directory), is an option that only mysqld_safe
#   accepts, so you will get an error if you try to pass it to mysqld directly.
#   For this reason you might want to use the above options within [mysqld#]
#   group directly.
#
# 3.DATA DIRECTORY
#
#   It is NOT advised to run many MySQL servers within the same data directory.
#   You can do so, but please make sure to understand and deal with the
#   underlying caveats. In short they are:
#   - Speed penalty
#   - Risk of table/data corruption
#   - Data synchronising problems between the running servers
#   - Heavily media (disk) bound
#   - Relies on the system (external) file locking
#   - Is not applicable with all table types. (Such as InnoDB)
#     Trying so will end up with undesirable results.
#
# 4.TCP/IP Port
#
#   Every server requires one and it must be unique.
#
# 5.[mysqld#] Groups
#
#   In the example below the first and the fifth mysqld group was
#   intentionally left out. You may have 'gaps' in the config file. This
#   gives you more flexibility.
#
# 6.MySQL Server User
#
#   You can pass the user=... option inside [mysqld#] groups. This
#   can be very handy in some cases, but then you need to run mysqld_multi
#   as UNIX root.
#
# 7.A Start-up Manage Script for mysqld_multi
#
#   In the recent MySQL distributions you can find a file called
#   mysqld_multi.server.sh. It is a wrapper for mysqld_multi. This can
#   be used to start and stop multiple servers during boot and shutdown.
#
#   You can place the file in /etc/init.d/mysqld_multi.server.sh and
#   make the needed symbolic links to it from various run levels
#   (as per Linux/Unix standard). You may even replace the
#   /etc/init.d/mysql.server script with it.
#
#   Before using, you must create a my.cnf file either in /usr/local/mysql/my.cnf
#   or /root/.my.cnf and add the [mysqld_multi] and [mysqld#] groups.
#
#   The script can be found from support-files/mysqld_multi.server.sh
#   in MySQL distribution. (Verify the script before using)
#


[mysqld_multi]
mysqld     = /usr/local/mysql/bin/mysqld_safe
mysqladmin = /usr/local/mysql/bin/mysqladmin
user       = multi_admin
password   = my_password


[mysqld2]
socket     = /tmp/mysql.sock2
port       = 3307
pid-file   = /usr/local/mysql/data2/hostname.pid2
datadir    = /usr/local/mysql/data2
language   = /usr/local/mysql/share/mysql/english
user       = unix_user1


[mysqld3]
mysqld     = /path/to/mysqld_safe
ledir      = /path/to/mysqld-binary/
mysqladmin = /path/to/mysqladmin
socket     = /tmp/mysql.sock3
port       = 3308
pid-file   = /usr/local/mysql/data3/hostname.pid3
datadir    = /usr/local/mysql/data3
language   = /usr/local/mysql/share/mysql/swedish
user       = unix_user2


[mysqld4]
socket     = /tmp/mysql.sock4
port       = 3309
pid-file   = /usr/local/mysql/data4/hostname.pid4
datadir    = /usr/local/mysql/data4
language   = /usr/local/mysql/share/mysql/estonia
user       = unix_user3
 
[mysqld6]
socket     = /tmp/mysql.sock6
port       = 3311
pid-file   = /usr/local/mysql/data6/hostname.pid6
datadir    = /usr/local/mysql/data6
language   = /usr/local/mysql/share/mysql/japanese
user       = unix_user4

1、分别创建端口为3306和3307的数据库
 

2、创建参数文件my_multi.cnf
[mysqld_multi]
mysqld = /usr/local/mysql/bin/mysqld_safe
mysqladmin = /usr/local/mysql/bin/mysqladmin
log = /var/lib/mysql/mysqld_multi.log
user = multi_admin
password = 111111

[mysqld6]
datadir = /var/lib/mysql3306
pid-file = /var/lib/mysql3306/mysqld.pid
socket = /tmp/mysql3306.sock
port = 3306

[mysqld7]
datadir = /var/lib/mysql3307
socket = /tmp/mysql3307.sock
pid-file = /var/lib/mysql3307/mysqld.pid
port = 3307

3、启动
[root@linfytest2 bin]# ./mysqld_multi --defaults-extra-file=/etc/my_multi.cnf report
Reporting MySQL servers
MySQL server from group: mysqld6 is not running
MySQL server from group: mysqld7 is not running

[root@linfytest2 bin]# ./mysqld_multi --defaults-extra-file=/etc/my_multi.cnf start
[root@linfytest2 bin]# ./mysqld_multi --defaults-extra-file=/etc/my_multi.cnf report
Reporting MySQL servers
MySQL server from group: mysqld6 is running
MySQL server from group: mysqld7 is running

[root@linfytest2 bin]# netstat -tunlp|grep mysql
tcp        0      0 :::3306                     :::*                        LISTEN      17982/mysqld        
tcp        0      0 :::3307                     :::*                        LISTEN      17983/mysqld


4、停止
[root@linfytest2 bin]# ./mysqld_multi --defaults-extra-file=/etc/my_multi.cnf stop
[root@linfytest2 bin]# ./mysqld_multi --defaults-extra-file=/etc/my_multi.cnf report
Reporting MySQL servers
MySQL server from group: mysqld6 is not running
MySQL server from group: mysqld7 is not running

感谢各位的阅读!关于“怎么利用mysqld_multi配置单机多实例”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

怎么利用mysqld_multi配置单机多实例

下载Word文档到电脑,方便收藏和打印~

下载Word文档

猜你喜欢

shell怎么使用mysqld_multi自动做多实例从库

本篇内容主要讲解“shell怎么使用mysqld_multi自动做多实例从库”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“shell怎么使用mysqld_multi自动做多实例从库”吧!代码如下
2023-06-09

MySQL中怎么实现多实例配置

MySQL中怎么实现多实例配置,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。什么是MySQL多实例?简单地说,MySQL多实例就是在一台服务器上同时开启多个不同的服务端口(如:
2023-06-20

Android中怎么利用OKHTTP实现单例

本篇文章为大家展示了Android中怎么利用OKHTTP实现单例,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。Android OKHTTP的单例和再封装的实例public class OkHttpU
2023-05-30

利用C++单例模式实现高性能配置管理器

这篇文章主要为大家详细介绍了如何利用C++单例模式实现高性能配置管理器,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起了解一下
2023-05-16

怎么在Mac M1中利用Nginx实现多站点配置

本篇文章为大家展示了怎么在Mac M1中利用Nginx实现多站点配置,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。第一步 : 设置 IP 与 域名 映射 (也就是增加 hosts)# 终端vim /
2023-06-14

MySQL多实例的配置应用实例场景是怎样的

本篇文章给大家分享的是有关MySQL多实例的配置应用实例场景是怎样的,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。MySQL多实例多实例概述什么是多实例:在一台服务器上,运行多
2023-06-22

多数据源怎么利用spring boot进行配置

本篇文章给大家分享的是有关多数据源怎么利用spring boot进行配置,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。多数据源配置创建一个Spring配置类,定义两个DataS
2023-05-31

利用Hibernate怎么实现一个多对一单项关联

这期内容当中小编将会给大家带来有关利用Hibernate怎么实现一个多对一单项关联,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。概念 基本映射是对一个实体进行映射,关联映射就是处理多个实体之间
2023-05-31

多媒体云主机租用怎么选择配置

选择多媒体云主机的配置需要考虑以下几个因素:1. 处理器(CPU):多媒体任务通常需要较高的计算能力,因此选择具有较高核心数和较高主频的CPU可以提高处理效能。2. 内存(RAM):多媒体任务对内存消耗较大,因此选择较大的内存容量可以提高处
2023-09-20

Java单例模式怎么利用HashMap实现缓存数据

本文小编为大家详细介绍“Java单例模式怎么利用HashMap实现缓存数据”,内容详细,步骤清晰,细节处理妥当,希望这篇“Java单例模式怎么利用HashMap实现缓存数据”文章能帮助大家解决疑惑,下面跟着小编的思路慢慢深入,一起来学习新知
2023-06-30

怎么在django中利用admin实现动态多选框表单

这期内容当中小编将会给大家带来有关怎么在django中利用admin实现动态多选框表单,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。model.py一个tag(标签类),一个book(书本类)book携带
2023-06-15

Java中静态内部类怎么利用单例模式实现

本篇文章为大家展示了Java中静态内部类怎么利用单例模式实现,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。Singleton是众多设计模式中最容易理解的一种,也是众多设计模式中较为重要的一种设计模式
2023-05-31

PHP中怎么利用正则表达式实现多行匹配

本篇文章给大家分享的是有关PHP中怎么利用正则表达式实现多行匹配,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。例如,对整个文件(尤其是多行文本)进行匹配查找。使用ereg()对
2023-06-17

springcloud中怎么使用profile实现多环境配置

这篇文章主要介绍“springcloud中怎么使用profile实现多环境配置”,在日常操作中,相信很多人在springcloud中怎么使用profile实现多环境配置问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家
2023-06-29

编程热搜

目录