MySQL5.6多实例部署
无论是迫于预算,亦或者是领导要求,多实例的安装也是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
|
[root@HE1 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
|
[root@HE1 ~] #mkdir -p /data/mysql_3306 [root@HE1 ~] #mkdir -p /data/mysql_3308 [root@HE1 ~] #echo "export PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/lib" >>/etc/profile |
进入到mysql的scripts文件夹下对数据库进行初始化,这里我们对3306端口数据库进行初始化
1
|
[root@HE1 scripts] #./mysql_install_db --basedir=/usr/local/mysql --datadir=/data/mysql_3306 --defaults-file=/etc/my.cnf --user=mysql |
这里我们对3308端口数据库进行初始化
1
2
|
[root@HE1 scripts] # ./mysql_install_db --basedir=/usr/local/mysql --datadir=/data/mysql_3308 --defaults-file=/etc/my.cnf --user=mysql |
初始化完成后,我们便可以启停数据库了,和单实例不同,多实例采用mysqld_multi来启停数据库
[root@HE1 bin]# ./mysqld_multi --defaults-file=/etc/my.cnf --user=root --password=MANAGER start 3306,3308
可以利用mysqld_multi的report命令来检测多实例的运行状况
1
2
3
4
5
|
[root@HE1 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
|
[root@HE1 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
|
[root@HE1 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
|
[root@HE1 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
|
[root@HE1 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
MySQL5.6多实例部署的更多相关文章
- 烂泥:mysql5.5多实例部署
本文由秀依林枫提供友情赞助,首发于烂泥行天下. mysql5.5数据库多实例部署,我们可以分以下几个步骤来完成. 1. mysql多实例的原理 2. mysql多实例的特点 3. mysql多实例应用 ...
- MySQL-5.6.36-多实例-部署(编译版)
MySQL多实例_沁贰百科 注:部署双实例前,首先需要部署单实例,单实例部署详情如下: https://www.cnblogs.com/wangqiner/p/9081002.html 1.如已经安装 ...
- mysql 5.5多实例部署【图解】
mysql5.5数据库多实例部署,我们可以分以下几个步骤来完成. 1. mysql多实例的原理 2. mysql多实例的特点 3. mysql多实例应用场景 4. mysql5.5多实例部署方法 一. ...
- mysql 5.5多实例部署
mysql5.5数据库多实例部署,我们可以分以下几个步骤来完成. 1. mysql多实例的原理 2. mysql多实例的特点 3. mysql多实例应用场景 4. mysql5.5多实例部署方法 一. ...
- mysql二进制安装,升级,多实例部署
目标 理解线上部署考虑的因素 学会编译安装以及二进制安装mysql 学会升级mysql 学会多实例部署mysql数据库 学会合理部署mysql线上库 考虑因素: 版本选择,5.1,5.5还是5.6 ...
- Tomcat 单(多)实例部署使用
一.前言 (一).概述 Tomcat 是由 Apache 开发的一个 Servlet 容器,实现了对 Servlet 和 JSP 的支持,并提供了作为Web服务器的一些特有功能,如Tomcat管理和控 ...
- mysqld_multi多实例部署
mysql多实例部署 目录 mysql多实例部署 下载软件 配置用户和组并解压二进制程序至/usr/local下 创建实例数据存放的目录 初始化各实例 配置配置文件/etc/my.cnf 启动各实例 ...
- Mysql 数据库单机多实例部署手记
最近的研发机器需要部署多个环境,包括数据库.为了管理方便考虑将mysql数据库进行隔离,即采用单机多实例部署的方式.找了会资料发现用的人也不是太多,一般的生产环境为了充分发挥机器性能都是单机单 ...
- Tomcat多实例部署
前言 以前总是采用很Low的方式太同一台服务器上部署多个Web应用,步骤是这样的:Copy Tomcat目录-->更改conf/server.xml三个端口号----->部署war包--- ...
随机推荐
- 关于数据结构的10个面试题(c语言实现)
关于数据结构的10个面试题(c语言实现) 2010-04-21 22:17 5702人阅读 评论(0) 收藏 举报 数据结构面试c语言bttree 1. 输入一个链表的头结点,从尾到头 ...
- backtrack种子
下载链接:(种子文件) BT5R3-GNOME-64.torrent (md5: 8cd98b693ce542b671edecaed48ab06d) BT5R3-GNOME-32.torrent (m ...
- HDU 1114 Piggy-Bank(判断是否恰好装满的背包)
其实这道题在寒假自学训练赛的时候就做过,不过感觉现在的理解跟当时真的不一样,大一半年过去了,变了这么多,我们都在进步,一回头便走出了这么远... 好了,题目很简单,一个背包,装不满做一个标记就行了 # ...
- OCR图片识别引擎
OCR引擎 OCR(Optical Character Recognition)是指使用扫描仪或数码相机对文本资料进行扫描成图像文件,然后对图像文件进行分析处理,自动识别获取文字信息及版面信息的软件. ...
- Python之路: 面向对象
Python是一门面向对象的语言,所以在Python中创建一个类和对象是很容易的.接下来了解一下面像对象的一些基本特征. 面向对象技术简介 类(class):描述具有相同的属性和方法的对象的集合.定义 ...
- GtkImageMenuItem
做了个工具条,每次点arrow出来的菜单都没图标,郁闷;查来查去,看源码,看css,最后知道GtkAction缺省就是对应GtkImageMenuItem,再一试,跟toolbar无关,换menu也不 ...
- Bridge 设计模式
原文:http://www.linkedkeeper.com/detail/blog.action?bid=26 You are here: 架构&实践 - 设计模式 Frank 2 ...
- PAT (Advanced Level) 1003. Emergency (25)
最短路+dfs 先找出可能在最短路上的边,这些边会构成一个DAG,然后在这个DAG上dfs一次就可以得到两个答案了. 也可以对DAG进行拓扑排序,然后DP求解. #include<iostrea ...
- hdu-oj 1874 畅通工程续
最短路基础 这个题目hdu-oj 1874可以用来练习最短路的一些算法. Dijkstra 无优化版本 #include<cstdio> #include<iostream> ...
- Mac下eclipse导入其他工程中文注释出现乱码解决方案
因为用的是mac版的eclipse,导入其他工程注释出现乱码的情况,找了网上的很多方法,大部分都是说的workspace,在这里修改,但是我修改之后还是乱码,最后发现这样一个方法,才得以解决. 点击 ...