mysql-5.1.73多实例安装启动

1. 源码包下载:http://download.softagency.net/MySQL/Downloads/MySQL-5.1/

2. 编译安装

groupadd mysql
useradd -r -g mysql mysql
mkdir /data/mysql_multi/mysql_exa1/
cd /data/mysql_multi/mysql_exa1/
mkdir data binlog log

mkdir /data/mysql_multi/mysql_exa2/
cd /data/mysql_multi/mysql_exa2/
mkdir data binlog log

chown -R mysql:mysql /data/mysql_multi/mysql_exa2/ /data/mysql_multi/mysql_exa1/

cd /data/installs/mysql-5.1.73
./configure --prefix=/usr/local/mysql5.1
make
make install 

cd /usr/local/mysql5.1/bin/
./mysql_install_db --user=mysql --basedir=/usr/local/mysql5.1 --datadir=/data/mysql_multi/mysql_exa1/data/
./mysql_install_db --user=mysql --basedir=/usr/local/mysql5.1 --datadir=/data/mysql_multi/mysql_exa2/data/

cp -rp ../share/mysql/mysqld_multi.server /etc/init.d/mysql_multi #复制启动文件
vim /etc/init.d/mysql_multi #修改basedir 和 datadir

3. 配置多实例

[mysqld_multi]
mysqld     = /usr/local/mysql5.1/bin/mysqld_safe
mysqladmin = /usr/local/mysql5.1/bin/mysqladmin
user       = root #管理实例时指定的用户名和密码
password   = 1234

[client]
#port        = 3306
#socket        = /data/mysql_multi/mysql_exa1/mysql.sock

[mysqld3307]
server-id    = 3307
port        = 3307

socket        = /data/mysql_multi/mysql_exa1/mysql.sock
pid-file = /data/mysql_multi/mysql_exa1/mysql.pid
datadir = /data/mysql_multi/mysql_exa1/data
log-error = /data/mysql_multi/mysql_exa1/log/error.log

long_query_time = 1
slow_query_log_file = /data/mysql_multi/mysql_exa1/log/slow-query.log

log-bin = /data/mysql_multi/mysql_exa1/binlog/mysql-bin
log-bin-index = /data/mysql_multi/mysql_exa1/binlog/mysql-bin.index
expire_logs_days = 2
binlog_format=mixed

skip-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

[mysqld3308]
server-id   = 3308
port        = 3308

socket      = /data/mysql_multi/mysql_exa2/mysql.sock
pid-file = /data/mysql_multi/mysql_exa2/mysql.pid
datadir = /data/mysql_multi/mysql_exa2/data
log-error = /data/mysql_multi/mysql_exa2/log/error.log

long_query_time = 1
slow_query_log_file = /data/mysql_multi/mysql_exa2/log/slow-query.log

log-bin = /data/mysql_multi/mysql_exa2/binlog/mysql-bin
log-bin-index = /data/mysql_multi/mysql_exa2/binlog/mysql-bin.index
expire_logs_days = 2
binlog_format=mixed

skip-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

[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

4. 启动多实例

[email protected]192.168.100.246:/usr/local/mysql5.1/bin# /etc/init.d/mysqld_multi start 3307
[email protected]192.168.100.246:/usr/local/mysql5.1/bin# /etc/init.d/mysqld_multi start 3308
[email protected]192.168.100.246:/usr/local/mysql5.1/bin# netstat -lntp | grep mysql
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      26218/mysqld
tcp        0      0 0.0.0.0:3307                0.0.0.0:*                   LISTEN      31910/mysqld
tcp        0      0 0.0.0.0:3308                0.0.0.0:*                   LISTEN      32154/mysqld 

5. 关闭多实例

5.1 分别设置密码

[email protected]192.168.100.246:/usr/local/mysql5.1/bin# mysql -uroot -p -S /data/mysql_multi/mysql_exa1/mysql.sock #指定sock文件路径登录
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.73-log Source distribution

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.

mysql> set password=password(‘1234‘);
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

[email protected]192.168.100.246:/usr/local/mysql5.1/bin# mysql -uroot -p -S /data/mysql_multi/mysql_exa2/mysql.sock
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.73-log Source distribution

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.

mysql> set password=password(‘1234‘);
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

5.2 关闭实例

[email protected]192.168.100.246:/usr/local/mysql5.1/bin# /etc/init.d/mysqld_multi stop 3307
[email protected]192.168.100.246:/usr/local/mysql5.1/bin# /etc/init.d/mysqld_multi stop 3308
[email protected]192.168.100.246:/usr/local/mysql5.1/bin# netstat -lntp | grep mysql
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      26218/mysqld  

6. 注意事项

6.1 mysql_multi.log默认路径:/usr/local/mysql5.1/share/mysqld_multi.log

6.2 新加实例时,只需要在配置文件加上实例相关配置,启动实例即可,停止实例也类似

时间: 2024-10-18 07:21:54

mysql-5.1.73多实例安装启动的相关文章

mysql 多实例安装启动

这次安装是建立在上次的mysql3306 安装成功的基础上http://liyingdi.blog.51cto.com/6397405/1879993 Tips:之前我们的一个实例是mysql3306,我们现在再安装一个mysql3307 1.和之前一样,创建需要的目录文件夹 mkdir -p /data/mysql/mysql3307/{data,logs,tmp} 创建完 就给文件授权 chown -R mysql:mysql /data/mysql/mysql3307/ 2.进入mysql

MySQL系列之D-1------MySQL多实例安装安装

注意:请根据自己的实际情况进行相应的更改 D.1   多实例结构 D.2   多实例安装 D.2.1依赖包 # yum install ncurses-devel -y # yum install libaio-devel -y D.2.2通过二进制方法安装mysql     注意:参考"mysql二进制包安装"这一章节     请查考MySQL系列之B------MySQL安装准备.MySQL系列之B------MySQL安装 D.2.3建立mysql账号 # groupadd my

MySQL系列之D------MySQL多实例安装安装

D.1   多实例结构 D.2   多实例安装 D.2.1依赖包 # yum install ncurses-devel -y # yum install libaio-devel -y D.2.2通过二进制方法安装mysql     注意:参考"mysql二进制包安装"这一章节     请查考MySQL系列之B------MySQL安装准备.MySQL系列之B------MySQL安装 D.2.3建立mysql账号 # groupadd mysql # useradd -s /sbi

MYSQL的cmake编译单实例安装

安装相关包:cd /home/oldboy/tools/rz -ytar xf cmake-2.8.8.tar.gzcd cmaake-2.8.8./configuregmakegmake installcd .. 依赖包: yum install ncurses-devel -y 开始安装mysql 创建用户和组 groupadd mysqluseradd mysql -s /sbin/nologin -M -g mysql 解压编译MYSQL tar xf mysql-5.5.32.tar.

MySQL多实例安装

    MySQL数据库(一) 作者:Jack 归档:学习笔记 2017/6/19 目  录 MySQl数据库(一)... 3 第1章概述:... 4 1.1 MySQL介绍:... 4 1.2 MariaDB数据库的诞生背景介绍... 4 1.3 MySQL多实例介绍... 5 1.3.1 什么是MySQL多实例... 5 1.3.2 MySQL多实例的作用与问题... 6 1.4 MySQL多实例的生产应用场景... 7 第2章关系型数据库与非关系型数据库... 8 2.1 关系型数据库..

Mysql多实例 安装以及配置

MySQL多实例 1.什么是MySQL多实例 简单地说,Mysql多实例就是在一台服务器上同时开启多个不同的服务端口(3306.3307),同时运行多个Mysql服务进程,这些服务进程通过不同的socket监听不同的服务端口来提供服务. 这些Mysql多实例公用一套Mysql安装程序,使用不同的my.cnf(也可以相同)配置文件,启动程序(也可以相同)和数据文件.在提供服务时,多实例 Mysql在逻辑上看来是各自独立的,它们根据配置文件的对应设定值,获得服务器相应数量的硬件资源. 打个比方,My

linux下mysql多实例安装(转)

转自:http://www.cnblogs.com/xuchenliang/p/6843990.html 1.MySQL多实例介绍 1.1.什么是MySQL多实例 MySQL多实例就是在一台机器上开启多个不同的服务端口(如:3306,3307),运行多个MySQL服务进程,通过不同的socket监听不同的服务端口来提供各自的服务:: 1.2.MySQL多实例的特点有以下几点 1:有效利用服务器资源,当单个服务器资源有剩余时,可以充分利用剩余的资源提供更多的服务. 2:节约服务器资源 3:资源互相

MySQL多实例安装配置

MySQL多实例安装配置 一.基本概念 MySQL多实例就是,在一台机器上开启多个不同的服务端口(如:3306,3307,3308...),运行多个MySQL服务进程,这些服务进程通过不同的socket监听不同的端口提供服务. MySQL可以共用一套安全程序,使用不同的my.cnf配置文件,启动程序,数据文件. 逻辑上是独立的,但是一个实例过载过高的时候会对其他造成影响. MySQL多实例的作用与问题: 1.有效利用服务器资源 2.节约服务器资源 3.资源互相抢占问题 当某个服务实现并发生很高的

Windows下MySQL多实例安装/主从复制/重置密码

Windows创建MySQL多实例 安装MYSQL和实例1 运行mysql-installer-community-5.7.16.0.msi 选择组件 MySQL Server 5.7.16 – X64 MySQL Utilities 1.6.4 – X64 MySQL Workbench 6.3.7 – X64 执行安装 配置端口3306 Windows Service Name设置为MYSQL 复制实例 将C:\ProgramData\MySQL\MySQL拷贝为MYSQL1和MYSQL2文