Error[8]: Undefined offset: 3, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

MySQL多实例配置方案

1.1 什么是Mysql多实例?

简单的说,Mysql多实例就是在一台服务器上同时开启多个不同的服务端口(如 : 3306/3307/3308)同时运行多个Mysql服务器,这些服务进程通过不同的socket来监听不同的服务端口来提供服务

这些Mysql多实例共用一套Mysql安装程序,使用不同的my.cnf配置文件,启动程序,和数据文件,在提供服务时,多实例Mysql在逻辑上来看是各自独立的,他们根据配置文件对应设定值,获得服务器相应的资源

1.2 多实例配置思路:

1.      多套独立目录
2.      每个实例有独立的数据(初始化数据)
3.      多个端口
4.      多个socket
5.      多个启动程序
6.      多个日志文件

1.3 多实例配置过程:

1.3.1 创建独立目录:

mkdir -p /data/{3307,3308}
chown –R mysql.mysql /data

1.3.2 编写每个实例的配置文件:

[root@db01 ~]# cat /data/3307/my.cnf
[mysqld]
basedir=/application/mysql
datadir=/data/3307
socket=/data/3307/mysql.sock
log-error=/data/3307/mysql.log
log_bin=/data/3307/mysql-bin
binlog_format=row
skip_name_resolve=1
server_id=3307
port=3307

1.3.3 初始化数据:

./mysql_install_db  --defaults-file=/data/3307/my.cnf --basedir=/application/mysql --datadir=/data/3307 --user=mysql

1.3.4 启动实例:

sh mysqld_safe --defaults-file=/data/3307/my.cnf --pid-file=/data/3307/3307.pid  &

shell脚本管理多实例服务:

#!/bin/bash
 
. /etc/init.d/functions
. /etc/profile
 
Start='/application/mysql/bin/mysqld_safe --defaults-file=/data/3307/my.cnf --pid-file=/data/3307/3307.pid'
Stop='mysqladmin -uroot -S /data/3307/mysql.sock shutdown'
Port=`ss -tunlp|grep 3307|wc -l`
 
function START(){
 if [ $Port -ne 1 ];then
  $Start >/dev/null 2>&1 &
  sleep 3
  if [ $? -eq 0 ];then
   action 'MySQL 3307 Starting' /bin/true
  fi
 else
  action 'MySQL 3307 Already Exists' /bin/true
 fi
}
function STOP(){
 if [ $Port -ne 0 ];then
  $Stop
  if [ $? -eq 0 ];then
   action 'MySQL Stoping Successfuly' /bin/true
  fi
 else
  action 'MySQL already Stoped' /bin/true
 fi
}
function RESTART(){
 STOP
 sleep 1
 START
}
case  in
start)
 START
 ;;
stop)
 STOP
 ;;
restart)
 RESTART
 ;;
*)
 echo "Usage: [+++] {start|stop|restart}"
 ;;
esac

)
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 166, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
MySQL多实例配置方案_mysql_内存溢出

MySQL多实例配置方案

MySQL多实例配置方案,第1张

MySQL多实例配置方案

1.1 什么是Mysql多实例?

简单的说,Mysql多实例就是在一台服务器上同时开启多个不同的服务端口(如 : 3306/3307/3308)同时运行多个Mysql服务器,这些服务进程通过不同的socket来监听不同的服务端口来提供服务

这些Mysql多实例共用一套Mysql安装程序,使用不同的my.cnf配置文件,启动程序,和数据文件,在提供服务时,多实例Mysql在逻辑上来看是各自独立的,他们根据配置文件对应设定值,获得服务器相应的资源

1.2 多实例配置思路:

1.      多套独立目录
2.      每个实例有独立的数据(初始化数据)
3.      多个端口
4.      多个socket
5.      多个启动程序
6.      多个日志文件

1.3 多实例配置过程:

1.3.1 创建独立目录:

mkdir -p /data/{3307,3308}
chown –R mysql.mysql /data

1.3.2 编写每个实例的配置文件:

[root@db01 ~]# cat /data/3307/my.cnf
[mysqld]
basedir=/application/mysql
datadir=/data/3307
socket=/data/3307/mysql.sock
log-error=/data/3307/mysql.log
log_bin=/data/3307/mysql-bin
binlog_format=row
skip_name_resolve=1
server_id=3307
port=3307

1.3.3 初始化数据:

./mysql_install_db  --defaults-file=/data/3307/my.cnf --basedir=/application/mysql --datadir=/data/3307 --user=mysql

1.3.4 启动实例:

sh mysqld_safe --defaults-file=/data/3307/my.cnf --pid-file=/data/3307/3307.pid  &

shell脚本管理多实例服务:

#!/bin/bash
 
. /etc/init.d/functions
. /etc/profile
 
Start='/application/mysql/bin/mysqld_safe --defaults-file=/data/3307/my.cnf --pid-file=/data/3307/3307.pid'
Stop='mysqladmin -uroot -S /data/3307/mysql.sock shutdown'
Port=`ss -tunlp|grep 3307|wc -l`
 
function START(){
 if [ $Port -ne 1 ];then
  $Start >/dev/null 2>&1 &
  sleep 3
  if [ $? -eq 0 ];then
   action 'MySQL 3307 Starting' /bin/true
  fi
 else
  action 'MySQL 3307 Already Exists' /bin/true
 fi
}
function STOP(){
 if [ $Port -ne 0 ];then
  $Stop
  if [ $? -eq 0 ];then
   action 'MySQL Stoping Successfuly' /bin/true
  fi
 else
  action 'MySQL already Stoped' /bin/true
 fi
}
function RESTART(){
 STOP
 sleep 1
 START
}
case  in
start)
 START
 ;;
stop)
 STOP
 ;;
restart)
 RESTART
 ;;
*)
 echo "Usage:  {start|stop|restart}"
 ;;
esac

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/sjk/888835.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-14
下一篇 2022-05-14

发表评论

登录后才能评论

评论列表(0条)

保存