单机多实例可以使用使用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/