MySQL单机多实例方案部署
MySQL单机多实例方案,是指在一台物理服务器上运行多个MySQL数据库实例。
MySQL单机多实例方案,是指在一台物理服务器上运行多个MySQL数据库实例。
MySQL单机多实例的优点:
1、节省成本,减少服务器、IP、机柜的数量,总体运营成本低于单机单实例方案。
2、提升利用率,利用NUMA特性,对MySQL实例进行CPU绑定。
3、提升用户体验,,大幅度提高IO响应时间,有助于提升用户的体验。
MySQL多实例部署的具体实施
1、MySQL多实例目录的规划(数据目录配置文件目录)
实例1
数据路径:
/home/mysql/data
配置文件路径:
/usr/local/mysql5/etc/lyq314.cnf
实例2
数据路径:
/home/mysql/data_log
配置文件路径:
/usr/local/mysql5/etc/lyq314_log.cnf
2、MySQL多实例配置文件的修改
实例1 配置文件修改(可以不用修改)
vim/usr/local/mysql5/etc/lyq314.cnf
18 [client]
19 #password= your_password
20 port= 3306
21 socket= /tmp/mysql.sock
22
23 # Here follows entries for some specific programs
24
25 # The MySQL server
26 [mysqld]
27 port= 3306
28 socket= /tmp/mysql.sock
29 pid-file= mysql.pid
30 skip-external-locking
31 skip-name-resolve
实例2 配置文件修改(修改port和socket)
vim/usr/local/mysql5/etc/lyq314_log.cnf
18 [client]
19 #password= your_password
20 port= 3307
21 socket= /tmp/mysql_log.sock
22
23 # Here follows entries for some specific programs
24
25 # The MySQL server
26 [mysqld]
27 port= 3307
28 socket= /tmp/mysql_log.sock
29 pid-file= mysql.pid
30 skip-external-locking
31 skip-name-resolve
3、MySQL多实例的启动
实例1 启动
[root@lyq314~]#/usr/local/mysql5/bin/mysqld_safe--defaults-file=/usr/local/mysql5/etc/lyq314.cnf --datadir=/home/mysql/data --user=mysql &
[root@lyq314~]# 130715 01:03:11 mysqld_safe Logging to '/home/mysql/data/lyq314.err'.
130715 01:03:11 mysqld_safe Starting mysqld daemon with databases from /home/mysql/data
[root@lyq314~]# netstat -ntlp |grep mysql
tcp 00 0.0.0.0: 3306 0.0.0.0: * LISTEN8353/mysqld
实例2启动
[root@lyq314~]#/usr/local/mysql5/bin/mysqld_safe--defaults-file=/usr/local/mysql5/etc/lyq314_log.cnf --datadir=/home/mysql/data_log --user=mysql &
[root@lyq314~]# 130715 01:08:53 mysqld_safe Logging to '/home/mysql/data_log/lyq314.err'.
130715 01:08:54 mysqld_safe Starting mysqld daemon with databases from /home/mysql/data_log
[root@lyq314 ~]# netstat -nltp |grep mysql
tcp 00 0.0.0.0: 3306 0.0.0.0: * LISTEN8962/mysqld
tcp 00 0.0.0.0: 3307 0.0.0.0: * LISTEN9085/mysqld
4、MySQL多实例的进入
实例1的进入(通过port和socket两中方式)
[root@lyq314 ~]# /usr/local/mysql5/bin/mysql -uroot -p -h127.0.0.1 -P3306
[root@lyq314 ~]# /usr/local/mysql5/bin/mysql -uroot -p -h127.0.0.1 --port=3306
[root@lyq314 ~]# /usr/local/mysql5/bin/mysql -uroot -p -S /tmp/mysql.sock
[root@lyq314 ~]# /usr/local/mysql5/bin/mysql -uroot -p --socket=/tmp/mysql.sock
实例2的进入(通过port和socket两中方式)
[root@lyq314 ~]# /usr/local/mysql5/bin/mysql -uroot -p -h127.0.0.1 -P3307
[root@lyq314 ~]# /usr/local/mysql5/bin/mysql -uroot -p -h127.0.0.1 --port=3307
[root@lyq314 ~]# /usr/local/mysql5/bin/mysql -uroot -p -S /tmp/mysql_log.sock
[root@lyq314 ~]# /usr/local/mysql5/bin/mysql -uroot -p --socket=/tmp/mysql_log.sock
5、MySQL 多实例的关闭
实例1关闭
/usr/local/mysql5/bin/mysqladmin-uroot -p -h127.0.0.1 -P3306 shutdown
/usr/local/mysql5/bin/mysqladmin-uroot -p -h127.0.0.1 -P3306 shutdown
/usr/local/mysql5/bin/mysqladmin-uroot -p -S /tmp/mysql.sockshutdown
/usr/local/mysql5/bin/mysqladmin-uroot -p –socket= /tmp/mysql.sockshutdown
实例2关闭
/usr/local/mysql5/bin/mysqladmin-uroot -p -h127.0.0.1 -P3307 shutdown
/usr/local/mysql5/bin/mysqladmin-uroot -p -h127.0.0.1 -P3307 shutdown
/usr/local/mysql5/bin/mysqladmin-uroot -p -S /tmp/mysql_log.sockshutdown
/usr/local/mysql5/bin/mysqladmin-uroot -p –socket= /tmp/mysql_log.sockshutdown
相关阅读:
生产环境MySQL 5.5.x单机多实例配置实践
上一篇: C#学习日记07---数据类型 之 decimal类型
下一篇: php弹出错误警告函数