MySQL-5.6.36-多实例-部署(编译版)

Posted wangqiner

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MySQL-5.6.36-多实例-部署(编译版)相关的知识,希望对你有一定的参考价值。

mysql多实例_沁贰百科

 

注:部署双实例前,首先需要部署单实例,单实例部署详情如下:

https://www.cnblogs.com/wangqiner/p/9081002.html

1、如已经安装完成单实例,需要先停止单实例运行,接下来进行多实例部署

/etc/init.d/mysqld stop
chkconfig mysqld off

2、已经制作好多实例配置文件及启动文件,以下为下载地址:

 

3、上传data.tar.gz到根目录,然后tar解压

[[email protected] /]# tar xf data.tar.gz
[[email protected] /]# tree /data
data
├── 3306
│   ├── my.cnf
│   └── mysql
└── 3307
├── my.cnf
└── mysql

4、授权所有者、所属组及文件权限并查看

chown -R mysql.mysql /data/

 [[email protected] /]# find /data -name mysql|xargs ls -l
 -rw-r--r-- 1 root root 1345 Apr 26 2017 /home/data/3306/mysql
 -rw-r--r-- 1 root root 1345 Apr 26 2017 /home/data/3307/mysql

 [[email protected] home]# find /home/data -name mysql|xargs chmod 700
 [[email protected] home]# find /home/data -name mysql|xargs ls -l
 -rwx------ 1 root root 1345 Apr 26 2017 /home/data/3306/mysql
 -rwx------ 1 root root 1345 Apr 26 2017 /home/data/3307/mysql
 [[email protected] home]#

5、进入MySQL初始化文件目录

cd /application/mysql/scripts

6、初始化3306,3307 两个实例(为了生成MySQL data下数据关联及文件)

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

------------分别执行--------------

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

7、环境变量设置,如已经配置,可跳过

echo export PATH=/application/mysql/bin:$PATH >>/etc/profile
source  /etc/profile

8、启动前为保证没有错误文件的报错,提前创建错误日志文件及授权所有者及所属组

touch /data/3306/oldboy_3306.err
touch /data/3307/oldboy_3307.err
chown mysql.mysql /data/3306/oldboy_3306.err
chown mysql.mysql /data/3307/oldboy_3307.err

9、启动MySQL多实例

---命令---
/data/3306/mysql start /data/3307/mysql start

---展示---

 [[email protected] data]# /data/3306/mysql start
 Starting MySQL...
 [[email protected] data]# /data/3307/mysql start
 Starting MySQL...

10、查看MySQL端口是否正常启动

[[email protected] data]# ss -lntup
Netid  State      Recv-Q Send-Q   Local Address:Port     Peer Address:Port 
tcp    LISTEN     0      600                 :::3306               :::*      users:(("mysqld",36610,11))
tcp    LISTEN     0      600                 :::3307               :::*      users:(("mysqld",37337,11))

11、分别登录进入MySQL多实例

---进入命令---

 mysql -S /data/3306/mysql.sock
 mysql -S /data/3307/mysql.sock

----展示-----

[[email protected] data]# mysql -S /data/3306/mysql.sock Welcome to the MySQL monitor. Commands end with ; or \\g. Your MySQL connection id is 1 Server version: 5.6.36 Source distribution Copyright (c) 2000, 2017, 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 | | mysql | | performance_schema | | test | +--------------------+ 4 rows in set (0.00 sec) mysql> exit Bye [[email protected] data]# mysql -S /data/3307/mysql.sock Welcome to the MySQL monitor. Commands end with ; or \\g. Your MySQL connection id is 1 Server version: 5.6.36 Source distribution Copyright (c) 2000, 2017, 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 | | mysql | | performance_schema | | test | +--------------------+ 4 rows in set (0.01 sec) mysql> exit Bye

完成以上操作,MySQL多实例就已经部署完成!

以下是增加一台实例思路

1、复制根目录下/data/3306 改名为 /data/3308

2、进行对比多实例MySQL实例下的my.cnf 和mysql 启动文件,

   唯一的区别在于实例名称的不同(如3306,3307,3308),以及server id 的不同(任意数不相同即可)

3、使用sed -i "s#3306#3308#g" /data/3308/my*   命令进行替换,如果不太明白,可以打开复制后的3308目录中的配置文件及启动文件,一一修改为3308 即可;

4、修改完成后初始化实例3308 ,可根据上述初始化命令将其他实例名称改为3308即可;

5、创建错误日志文件到实例3308下;

6、授权实例3308 ,更改所有者、所属组及权限;

7、启动多实例3308 /data/3308/mysql start;

8、查看端口是否启动。

 
























以上是关于MySQL-5.6.36-多实例-部署(编译版)的主要内容,如果未能解决你的问题,请参考以下文章

Mysql 5.6多实例标准化安装与配置

MySQL-5.6.36编译安装教程,新手必看!

centos6.9编译安装mysql-5.6.36

数据库的编译安装

centos7--MySQL-5.6.36 Install Manual

解压版mysql安装步骤