• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
导航菜单
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • windows
  • 服务器硬件
  • 服务器运维
  • 云计算
  • 虚拟化
  • IIS教程
  • Linux
  • Apache
  • Ftp
  • DNS
  • Nginx
您的位置:首页 > 服务器 >windows > mysql dba系统学习(4)mysql的多实例multi启动停止

mysql dba系统学习(4)mysql的多实例multi启动停止

作者:网友 字体:[增加 减小] 来源:互联网

本文主要包含mysql dba系统学习(4)mysql的多实例multi启动停止等服务器相关知识,网友希望可以进行参考

mysql的多实例配置安装

 一,什么情况下我们会考虑一台物理服务器上部署多个实例,大致有以下几种情况:

1,采用了数据伪分布式架构的原因,而项目启动初期又不一定有那多的用户量,为此先一组物理数据库服务器,但部署多个实例,方便后续迁移;

2,为规避mysql对SMP架构不支持的缺陷,使用多实例绑定处理器的办法NUMA处理器必须支持,不过现在大部分处理器都支持的!),把不同的数据库分配到不同的实例上提供数据服务;

3,一台物理数据库服务器支撑多个数据库的数据服务,为提高mysql复制的从机的恢复效率,采用多实例部署;

已经为双主复制的mysql数据库服务器架构,想部分重要业务的数据多一份异地机房的热备份,而mysql复制暂不支持多主的复制模式,且不给用户提供服务,为有效控制成本,会考虑异地机房部署一台性能超好的物理服务器,甚至外加磁盘柜的方式,为此也会部署多实例;

4,传统游戏行业的MMO/MMORPG,以及Web Game,每一个服都对应一个数据库,而可能要做很多数据查询和数据订正的工作,为减少维护而出错的概率,也可能采用多实例部署的方式,按区的概念分配数据库;


 二,mysql的多实例的介绍

         mysqld_multi被设计为了管理实现多个mysqld服务进程  


 三,配置多实例mysqld及初始化

1,创建实例的数据文件目录

[root@test4 ~]# cd /mysql/
[root@test4 mysql]# ls
data
[root@test4 mysql]# mkdir data2/
[root@test4 mysql]# mkdir data3/

2,初始化多实例mysql
[root@test4 mysql]# mysql_install_db   --datadir=/mysql/data2/  --user=mysqlInstalling

MySQL system tables...
OK

[root@test4 mysql]# mysql_install_db   --datadir=/mysql/data3/  --user=mysqlInstalling MySQL

system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/local/mysql/bin/mysqladmin -u root password 'new-password'
/usr/local/mysql/bin/mysqladmin -u root -h test4.wolf.org password 'new-password'
Alternatively you can run:
/usr/local/mysql/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr/local/mysql ; /usr/local/mysql/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /usr/local/mysql/mysql-test ; perl mysql-test-run.pl
Please report any problems with the /usr/local/mysql/bin/mysqlbug script!

3,配置mysqld的多实例my.cnf文件

(1)配置my.cnf文件详解

[root@test4 ~]# cat  /etc/my.cnf
[mysqld_multi]
mysqld =/usr/local/mysql/bin/mysqld_safe
mysqladmin =/usr/local/mysql/bin/mysqladmin
user =test
password =test
[client]
#password       = your_password
port            = 3306
socket          = /tmp/mysql.sock
[mysqld3306]
port            = 3306
socket          = /tmp/mysql3306.sock
skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
log-bin=mysql-bin
binlog_format=mixed
datadir = /mysql/data
server-id       = 1
[mysqld3307]
port            = 3307
socket          = /tmp/mysql3307.sock
skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
log-bin=mysql-bin
binlog_format=mixed
datadir = /mysql/data2
server-id       = 1
[mysqld3308]
port            = 3308
socket          = /tmp/mysql3308.sock
skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
log-bin=mysql-bin
binlog_format=mixed
datadir = /mysql/data3
server-id       = 1
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout

2)启动多实例

[root@test4 ~]# /usr/local/mysql/bin/mysqld_multi  --defaults-file=/etc/my.cnf  start 3308

     [root@test4 ~]# ps aux|grep 3308
root      4887  0.0  0.2 106012  1348 pts/1    S    14:57   0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --port=3308 --socket=/tmp/mysql3308.sock --skip-external-locking --key_buffer_size=16M --max_allowed_packet=1M --table_open_cache=64 --sort_buffer_size=512K --net_buffer_length=8K --read_buffer_size=256K --read_rnd_buffer_size=512K --myisam_sort_buffer_size=8M --log-bin=mysql-bin --binlog_format=mixed --datadir=/mysql/data3 --server-id=1
mysql     5034  0.0  1.3 125304  6668 pts/1    Sl   14:57   0:00 /usr/local/mysql/libexec/mysqld --basedir=/usr/local/mysql --datadir=/mysql/data3 --user=mysql --skip-external-locking --key_buffer_size=16M --max_allowed_packet=1M --table_open_cache=64 --sort_buffer_size=512K --net_buffer_length=8K --read_buffer_size=256K --read_rnd_buffer_size=512K --myisam_sort_buffer_size=8M --log-bin=mysql-bin --binlog_format=mixed --server-id=1 --log-error=/mysql/data3/test4.wolf.org.err --pid-file=/mysql/data3/test4.wolf.org.pid --socket=/tmp/mysql3308.sock --port=3308

3)连接mysql多实例

[root@test4 ~]# mysql  -S  /tmp/mysql3308.sock
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.70-log Source distribution

Copyright (c) 2000, 2013, 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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |

分享到:QQ空间新浪微博腾讯微博微信百度贴吧QQ好友复制网址打印

您可能想查找下面的文章:

相关文章

  • 七、编写每天定时切割Nginx日志的脚本【LNMP安装 】
  • nginx日志
  • Windows 2008 R2 SP1 更新后远程登录RDP 失败
  • liunx服务使用(nfs服务和ftp服务还有samba服务)
  • liunx系统中进程和线程的理解
  • Windows 2003 服务器安全设置图文教程(1/3)
  • nginx+php编译安装
  • WIN中SharePoint Server 2010 入门安装部署详解
  • Apache日志中“指定的网络名不再可用”解决办法
  • srosa.sys插件导致计算机蓝屏故障

文章分类

  • windows
  • 服务器硬件
  • 服务器运维
  • 云计算
  • 虚拟化
  • IIS教程
  • Linux
  • Apache
  • Ftp
  • DNS
  • Nginx

最近更新的内容

    • UltraISO 制作USB系统启动盘图文教程
    • Windows 调试工具的最新功能介绍
    • ubuntu dnsmasq配置
    • 80端口被inetinfo.exe占用解决方法
    • Windows2003:IIS 6.0工作进程隔离模式
    • 音视频功能介绍
    • 解码云时代企业云存储服务
    • apache服务无法启动多种方法总结?
    • Windows下安装MariaDB数据库小结
    • liunx基本命令(适合初学者看)

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有