关键词:
无论是迫于预算,亦或者是领导要求,多实例的安装也是DBA必须掌握的技术,他的启停和登录方式和单实例安装数据库略有不同,本文记录下如何完成MySQL5.6多实例部署。
首先我们看一下my.cnf和单实例的区分:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
[[email protected] scripts] # cat /etc/my .cnf [client] #port = 3306 #socket = /tmp/mysql.sock #default-character-set = utf8 [mysql] #default-character-set = utf8 [mysqld3306] port = 3306 basedir = /usr/local/mysql datadir = /data/mysql_3306 socket = /tmp/mysql_3306 .sock slow_query_log_file = /data/mysql_3306/slow .log log-error = /data/mysql_3306/error .log log-bin = /data/mysql_3306/mysql-bin sync_binlog = 1 binlog_format = row transaction_isolation = REPEATABLE-READ innodb_buffer_pool_size = 100m [mysqld3308] port = 3308 basedir = /usr/local/mysql datadir = /data/mysql_3308 socket = /tmp/mysql_3308 .sock slow_query_log = 1 slow_query_log_file = /data/mysql_3308/slow .log log-error = /data/mysql_3308/error .log long_query_time = 1 log-bin = /data/mysql_3308/mysql-bin sync_binlog = 1 binlog_cache_size = 4M default-storage-engine = InnoDB binlog_format = row transaction_isolation = REPEATABLE-READ innodb_buffer_pool_size = 100m [mysqld_multi] mysqld= /usr/local/mysql/bin/mysqld_safe mysqladmin= /usr/local/mysql/bin/mysqladmin [mysqldump] quick max_allowed_packet = 32M |
可以看出,多实例的my.cnf实际上就是如上所示,本文为了演示实验环境,innodb_buffer_pool_size仅仅开了100m,真实的生产库中多实例部署该参数要开大些,两个实例该参数的值达到内存的50%-80%都可以。
下面开始初始化我们的数据库
首先创建我们的数据目录
1
2
3
|
[[email protected] ~] #mkdir -p /data/mysql_3306 [[email protected] ~] #mkdir -p /data/mysql_3308 [[email protected] ~] #echo "export PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/lib" >>/etc/profile |
进入到mysql的scripts文件夹下对数据库进行初始化,这里我们对3306端口数据库进行初始化
1
|
[[email protected] scripts] #./mysql_install_db --basedir=/usr/local/mysql --datadir=/data/mysql_3306 --defaults-file=/etc/my.cnf --user=mysql |
这里我们对3308端口数据库进行初始化
1
2
|
scripts] # ./mysql_install_db --basedir=/usr/local/mysql --datadir=/data/mysql_3308 --defaults-file=/etc/my.cnf --user=mysql |
初始化完成后,我们便可以启停数据库了,和单实例不同,多实例采用mysqld_multi来启停数据库
[[email protected] bin]# ./mysqld_multi --defaults-file=/etc/my.cnf --user=root --password=MANAGER start 3306,3308
可以利用mysqld_multi的report命令来检测多实例的运行状况
1
2
3
4
5
|
[[email protected] bin] # . /mysqld_multi report Reporting MySQL servers MySQL server from group: mysqld3306 is running MySQL server from group: mysqld3308 is running |
登录方式和单实例大体相同,不过由于多实例的存在,我们需要指定不同的端口号
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
[[email protected] bin]# mysql -uroot -p -P3306 -h 192.168.1.48 Enter password : Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 6 Server version: 5.6.16-log MySQL Community Server (GPL) Copyright (c) 2000, 2014, 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 | | 3306db | | mysql | | performance_schema | | test | + --------------------+ 5 rows in set (0.00 sec) |
当然,利用socket文件登录也是可以的
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
[[email protected] bin]#mysql -uroot -p -S /data/mysql_3306/mysql_3306.sock Enter password : Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 7 Server version: 5.6.16-log MySQL Community Server (GPL) Copyright (c) 2000, 2014, 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 | | 3306db | | mysql | | performance_schema | | test | + --------------------+ 5 rows in set (0.00 sec) |
这里是登录3308端口数据库
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
[[email protected] bin]#mysql -uroot -p -P3308 -h 192.168.1.48 Enter password : Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 8 Server version: 5.6.16-log MySQL Community Server (GPL) Copyright (c) 2000, 2014, 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. Type ‘help;‘ or ‘h‘ for help. Type ‘c‘ to clear the current input statement. mysql> show databases; + --------------------+ | Database | + --------------------+ | information_schema | | 3308db | | mysql | | performance_schema | | test | + --------------------+ 5 rows in set (0.00sec) mysql> quit Bye |
利用3308端口的socket文件登录数据库
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
[[email protected] bin]#mysql -uroot -p -S /data/mysql_3308/mysql_3308.sock Enter password : Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 9 Server version: 5.6.16-log MySQL Community Server (GPL) Copyright (c) 2000, 2014, 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 | | 3308db | | mysql | | performance_schema | | test | + --------------------+ 5 rows in set (0.00sec) |
至此,MySQL5.6多实例部署完成。
本文出自 “岁伏” 博客,请务必保留此出处http://suifu.blog.51cto.com/9167728/1850560
centos6.5安装mysql5.6多实例(多配置文件)
*********************************************************************安装说明:使用镜像: CentOS-6.5-x86_64-minimal.iso系统: CentOSrelease6.5(Final) 查看详情
linux安装mysql5.6
目录准备工作运行环境确认你的安装版本下载MySQL安装MySQL准备安装环境编译和安装配置MySQL单实例配置单实例配置方法添加防火墙启动MySQL重启MySQL多实例配置什么是多实例多实例配置方法创建启动文件初始化数据库配置防火墙... 查看详情
centos6.5安装mysql5.6单实例和多实例(单配置文件)
安装mysql 创建mysql用户useraddmysql //已经有的不需要创建 卸载原来的mysql rpm包rpm-qa|grepmysql //查询是否有相关包yum-yremove*mysql* & 查看详情
centos7下mysql5.6.30配置单机多实例主从半同步复制
1.在master主服务器上执行:mysql>INSTALLPLUGINrpl_semi_sync_masterSONAME‘semisync_master.so‘; QueryOK,0rowsaffected(0.30sec)mysql>SETGLOBALrpl_semi_sync_master_enabled=1; QueryOK,0rowsaffected(0 查看详情
mysql5.6生产库自动化安装部署
原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://suifu.blog.51cto.com/9167728/1846671 自动化运维是一个DBA应该掌握的技术,其中,自动化安装数据库是... 查看详情
mysql5.6生产库自动化安装部署
自动化运维是一个DBA应该掌握的技术,其中,自动化安装数据库是一项基本的技能,本文中的安装脚本已通过测试,作为生产库来说没有问题,鉴于每个公司存储规划要求不同,可以按需自行修改脚本。脚本中已经注释说明一些... 查看详情
mysql5.6好还是mysql5.7好
1.下载5.7.30的zip包并解压到新的目录。2.安装VisualC++2012/2013(或更多版本)。3.停应用,停止5.6实例(可以通过停服务来操作,停止服务前建议记录一下GTID或binlogfile和position位置),删除服务。4.备份一份5.6实例的datadir,包括binlo... 查看详情
linux下安装部署jdk7+tomcat7+mysql5.6+redis3.07
配置jdk环境变量 1.解压:tar-zxvfjdk-8u121-linux-x64.tar.gz生成新文件夹2.通过命令[[email protected]/]#vietc/profile3.在末尾添加:unsetiunset-fpathmunge exportJAVA_HOME=/usr/java/jdk8exportPATH=$JAVA_HOME/bin:$PA 查看详情
mysql5.6.21数据迁移到mysql5.7.16方法
参考技术A1.下载5.7.30的zip包并解压到新的目录。2.安装VisualC++2012/2013(或更多版本)。3.停应用,停止5.6实例(可以通过停服务来操作,停止服务前建议记录一下GTID或binlogfile和position位置),删除服务。4.备份一份5.6实例的datadir... 查看详情
mysql5.6.29和mysql5.7.11哪个版本比较稳定??
1.下载5.7.30的zip包并解压到新的目录。2.安装VisualC++2012/2013(或更多版本)。3.停应用,停止5.6实例(可以通过停服务来操作,停止服务前建议记录一下GTID或binlogfile和position位置),删除服务。4.备份一份5.6实例的datadir,包括binlo... 查看详情
mysql5.7与mysql5.6啥区别
MySQL各产品线更新.5.6.15/5.5.35开发版5.7.32013-12-03之前版本2013-09-20的5.6.14/5.5.34,主要是Bug修正。5.1还是5.1.72.主要是PerformanceSchema增强,Cmake时增加了WITH_ASAN以及一些Bug修正。完全改进:http://dev.mysql.com/doc/relnotes/mysql/5.6/en/news-5-6-15.ht... 查看详情
mysql多实例部署(代码片段)
Centos7.6部署3个Mariadb实例[[email protected]~]#yuminstallmariadb-server-y#创建对应的目录文件[[email protected]~]#mkdir/mysql/3306,3307,3308/data,etc,socket,log,bin,pid-pchown-Rmysql.mysql/mysql#初始化数据 查看详情
mysql多实例部署(代码片段)
Centos7.6部署3个Mariadb实例[[email protected]~]#yuminstallmariadb-server-y#创建对应的目录文件[[email protected]~]#mkdir/mysql/3306,3307,3308/data,etc,socket,log,bin,pid-pchown-Rmysql.mysql/mysql#初始化数据 查看详情
mysql5.6和5.7哪个好
都差不多但是建议用低版本的因为低版本的兼容性比较好高版本可能会出现一些bug参考技术A1.下载5.7.30的zip包并解压到新的目录。2.安装VisualC++2012/2013(或更多版本)。3.停应用,停止5.6实例(可以通过停服务来操作,停止服务... 查看详情
mysql多实例部署
mysql的多实例有两种方式可以实现,两种方式各有利弊。第一种是使用多个配置文件启动不同的进程来实现多实例,这种方式的优势逻辑简单,配置简单,缺点是管理起来不太方便。第二种是通过官方自带的mysqld_m... 查看详情
如何升级mysql5.6到5.7forwindows
1.下载5.7.30的zip包并解压到新的目录。2.安装VisualC++2012/2013(或更多版本)。3.停应用,停止5.6实例(可以通过停服务来操作,停止服务前建议记录一下GTID或binlogfile和position位置),删除服务。4.备份一份5.6实例的datadir,包括binlo... 查看详情
mysql-5.6.36单/多实例部署
mysql多实例部署实验环境mysql-1:10.0.0.101?mysql-2:10.0.0.102?centos6.9 mysql的源码安装[root@mysql-13306]#cat/etc/redhat-releaseCentOSrelease6.9(Final)关闭iptables和selinux安装mysql-5.6.36##安装前期准备#1、创建安装目录及软件包 查看详情
tomcat多实例的部署
解压部署tomcat程序创建2个实例的工作目录mkdir-p/usr/local/tomcat8_instance/tomcat1mkdir-p/usr/local/tomcat8_instance/tomcat2拷贝tomcat程序目录下的conf分别放入2个实例目录中cp-R/usr/local/tomcat8/conf/usr/local/tomcat8_instance/tomcat1cp 查看详情