Linux下MySQL配置单机多实例

单机多实例可以使用使用mysqld_safe指定配置文件启动,但是需要记住很多指定的配置文件,推荐使用
mysqld_multi来管理多个实例,下面详细介绍mysqld_multi的用法。

首先需要安装MySQL

具体安装过程不介绍了。

配置mysqld_multi的参数文件

mysqld_multi有默认的模板,按照自己的实际环境修改,与单个实例配置参数文件基本相同。
文件主要包含以下内容:

  • 指定通用用户,用来关闭mysql,确保该用户有Shutdown_priv权限,为安全起见,所有实例都创建同一用户名称密码指定shutdown权限。使用mysqld_multi其实就是调用mysqladmin来关闭mysql实例。
GRANT SHUTDOWN ON *.* TO multi_admin@localhost IDENTIFIED BY '123qwe'
  • 指定每个实例mysqld、pid-file、数据文件路径、TCP/IP端口及其他mysql特定参数。
查看自带模板
shell> mysqld_multi --example
shell> mysqld_multi --example > /etc/my.cnf   
shell> vi /etc/my.cnf  
==============================================
[mysqld_multi]
user       = multi_admin
password   = 123@qwe

[mysqld2]
mysqld     = /db/mysql/mysql_55/bin/mysqld_safe
mysqladmin = /db/mysql/mysql_55/bin/mysqladmin
socket     = /tmp/mysql_3306.sock
port       = 3306
pid-file   = /db/mysql/mysql_55/svoid-a.pid
datadir    = /db/mysql/mysql_55/data
innodb_file_per_table=1
log-bin=mysql_info
server-id=100
user       = mysql

[mysqld3]
mysqld     = /db/mysql/mysql_56/bin/mysqld_safe
mysqladmin = /db/mysql/mysql_56/bin/mysqladmin
socket     = /tmp/mysql_3307.sock
port       = 3307
pid-file   = /db/mysql/mysql_56/svoid-a.pid
datadir    = /db/mysql/mysql_56/data
innodb_file_per_table=1
log-bin=mysql_info
server-id=200
user       = mysql

[mysqld4]
mysqld     = /db/mysql/mysql_57/bin/mysqld_safe
mysqladmin = /db/mysql/mysql_57/bin/mysqladmin
socket     = /tmp/mysql_3308.sock
port       = 3308
pid-file   = /db/mysql/mysql_57/svoid-a.pid
datadir    = /db/mysql/mysql_57/data
innodb_file_per_table=1
log-bin=mysql_info
server-id=300
user       = mysql

mysqld_multi使用方法

显示mysql启动状态
shell> mysqld_multi report
Reporting MySQL servers
MySQL server from group: mysqld2 is not running
MySQL server from group: mysqld3 is not running
MySQL server from group: mysqld4 is not running

启动MySQL实例
shell> mysqld_multi start 2-4
shell> mysqld_multi report
Reporting MySQL servers
MySQL server from group: mysqld2 is running
MySQL server from group: mysqld3 is running
MySQL server from group: mysqld4 is running

停止MySQL实例
shell> mysqld_multi stop 4
shell> mysqld_multi report
Reporting MySQL servers
MySQL server from group: mysqld2 is running
MySQL server from group: mysqld3 is running
MySQL server from group: mysqld4 is not running


mysqld_multi具体使用方法
shell> mysqld_multi --help

整理自网络

Svoid
2015-05-02

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29733787/viewspace-1223056/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/29733787/viewspace-1223056/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值