linux下mysql的实例,linux下Mysql多实例实现

什么是MySQL多实例

MySQL多实例就是在一台机器上开启多个不同的服务端口(如:3306,3307),运行多个MySQL服务进程,通过不同的socket监听不同的服务端口来提供各自的服务:;

Mysql多实例实现的3种方式

mysql 多实例常规来讲,有三种方案可以实现,这三种方案各有利弊,如下:

1、基于多配置文件

通过使用多个配置文件来启动不同的进程,以此来实现多实例。

配置文件:

[client]

port =

socket =/data//mysql.sock

[mysql]

no-auto-rehash

[mysqld]

user = mysql

port =

socket =/data//mysql.sock

basedir =/application/mysql

datadir =/data//data

open_files_limit =

back_log =

max_connections =

max_connect_errors =

table_cache =

external-locking = FALSE

max_allowed_packet =8M

sort_buffer_size =1M

join_buffer_size =1M

thread_cache_size =

thread_concurrency =

query_cache_size =2M

[root@web001 ]# cat my.cnf

[client]

port =

socket =/data//mysql.sock

[mysql]

no-auto-rehash

[mysqld]

user = mysql

port =

socket =/data//mysql.sock

basedir =/application/mysql

datadir =/data//data

open_files_limit =

back_log =

max_connections =

max_connect_errors =

table_cache =

external-locking = FALSE

max_allowed_packet =8M

sort_buffer_size =1M

join_buffer_size =1M

thread_cache_size =

thread_concurrency =

query_cache_size =2M

query_cache_limit =1M

query_cache_min_res_unit =2k

#default_table_type = InnoDB

thread_stack =192K

#transaction_isolation = READ-COMMITTED

tmp_table_size =2M

max_heap_table_size =2M

#long_query_time =

#log_long_format

#log-error = /data//error.log

#log-slow-queries = /data//slow.log

pid-file =/data//mysql.pid

#log-bin = /data//mysql-bin

relay-log =/data//relay-bin

relay-log-info-file =/data//relay-log.info

binlog_cache_size =1M

max_binlog_cache_size =1M

max_binlog_size =2M

expire_logs_days =

key_buffer_size =16M

read_buffer_size =1M

read_rnd_buffer_size =1M

bulk_insert_buffer_size =1M

#myisam_sort_buffer_size = 1M

#myisam_max_sort_file_size = 10G

#myisam_max_extra_sort_file_size = 10G

#myisam_repair_threads =

#myisam_recover

lower_case_table_names =

skip-name-resolve

slave-skip-errors =,

replicate-ignore-db=mysql

server-id =

innodb_additional_mem_pool_size =4M

innodb_buffer_pool_size =32M

innodb_data_file_path = ibdata1:128M:autoextend

innodb_file_io_threads =

innodb_thread_concurrency =

innodb_flush_log_at_trx_commit =

innodb_log_buffer_size =2M

innodb_log_file_size =4M

innodb_log_files_in_group =

innodb_max_dirty_pages_pct =

innodb_lock_wait_timeout =

innodb_file_per_table =

[mysqldump]

quick

max_allowed_packet =2M

[mysqld_safe]

log-error=/data//mysql_oldboy3307.err

pid-file=/data//mysqld.pid

View

优点:逻辑简单,配置简单

缺点:管理起来不方便

mysql启动停止脚本。

#!/bin/sh

#init

port=

mysql_user="root"

mysql_pwd=""

CmdPath="/application/mysql/bin"

mysql_sock="/data/${port}/mysql.sock"

function_start_mysql()

{

if [ ! -e "$mysql_sock" ];then

printf "Starting MySql...\n"

/bin/sh ${CmdPath}/mysqld_safe --defaults-file=/data/${port}/my.cnf >& >/dev/null &

else

printf "Mysql is running...\n"

exit

fi

}

#stop function

function_stop_mysql()

{

if [ ! -e "$mysql_sock" ];then

printf "MySql is stopped...\n"

exit

else

printf "Stoping MySQL...\n"

${CmdPath}/mysqladmin -u ${mysql_user} -p${mysql_pwd} -S /data/${port}/mysql.sock shutdown

fi

}

#restart function

function_restart_mysql()

{

printf "Restarting Mysql...\n"

function_stop_mysql

sleep

function_start_mysql

}

case $ in

start)

function_start_mysql

;;

stop)

function_stop_mysql

;;

restart)

function_restart_mysql

;;

*)

printf "Usage /data/${port}/mysql {start|stop|restart}\n"

;;

esac

2、基于mysqld_multi

通过官方自带的 mysqld_multi 工具,使用单独配置文件来实现多实例

优点: 便于集中管理管理

缺点: 不方便针对每个实例配置进行定制

3、基于IM

使用 MySQL 实例管理器(MYSQLMANAGER),这个方法好像比较好不过也有点复杂

优点:便于集中管理

缺点:耦合度高。IM一挂,实例全挂

不方便针对每个实例配置进行定制

linux下mysql多实例安装

1.MySQL多实例介绍 1.1.什么是MySQL多实例 MySQL多实例就是在一台机器上开启多个不同的服务端口(如:3306,3307),运行多个MySQL服务进程,通过不同的socket监听不同的 ...

linux下mysql多实例安装(转)

转自:http://www.cnblogs.com/xuchenliang/p/6843990.html   1.MySQL多实例介绍 1.1.什么是MySQL多实例 MySQL多实例就是在一台机器上 ...

linux 下mysql多实例安装

1.软件下载 https://dev.mysql.com/downloads/file/?id=479096 免编译二进制包 mysql-5.6.21-linux-glibc2.5-x86_64.ta ...

Linux下mysql 多实例安装配置

首先我们要清楚什么是多实例?所谓多实例就是用多个配置文件来启动多个不同端口的进程,以不同的端口的形式为外提供服务.明白了多实例 我们下面的操作和配置就一目了然了首先我们要安装一套基础的应用程序,也就是 ...

【MySQL】Linux下MySQL 5.5、5.6和5.7的RPM、二进制和源码安装

[MySQL]Linux下MySQL 5.5.5.6和5.7的RPM.二进制和源码安装 1.1  BLOG文档结构图 1.2  前言部分 1.2.1  导读和注意事项 各位技术爱好者,看完本文后, ...

Linux下MySql变量修改遇到的问题记录

一.问题记录: 项目上需要使用mysql的过程来自动化构建一批数据,但是调用的时候总是报找不到表或者过程 二.排查过程: (1)首先终端连接mysql后发现,无论表还是过程在数据库中都是存在的,排除了 ...

Linux下MySQL忘记密码

系统:CentOS6.6 64位 参考文档(截图请看原网址): Linux下MySQL忘记root密码怎么办_百度经验 http://jingyan.baidu.com/article/1709ad8 ...

linux 下mysql的启动 、调试、排错

Linux 下 MySQL 启动与关闭 说明 一.启动 1.1  MySQL 进程 可以用ps 命令查看进程: [root@rac2 ~]# ps -ef|grep mysql root     21 ...

linux下mysql远程访问

// */ // ]]>   linux下mysql远程访问 Mysql默认root用户只能本地访问,不能远程连接管理mysql数据库,但项目中必须要远程导 入导出数据,所以研究了一下. Tab ...

随机推荐

ubuntu 14.04LTS 环境下搭建tftp服务器

花费我一整天的时间在 ubuntu 14.04LTS 环境下搭建tftp服务器,网上好多资料参差不齐,简单来说,TFTP(Trivial File Transfer Protocol),是一个基于UD ...

Oracle常见名词解析

创建用户 概述:在oracle中要创建一个新的用户使用create user语句,一般是具有dba(数据库管理员)的权限才能使用. create user 用户名 identified by 密码; ...

使用安卓中的TextToSpeech控件实现朗读文字

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值