MySQL5.6.35数据库多实例二进制安装
时间:2022-03-15 01:26
一、软件包
wget -q
二、解压移动
tar xf mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz
mkdir -p /application/mysql
mv mysql-5.6.35-linux-glibc2.5-x86_64 /application/mysql/mysql-5.6.35
useradd -s /sbin/nologin -M mysql
chown -R mysql.mysql /application/mysql/
cd /application/mysql/mysql-5.6.35/
三、系统设置
3.1关闭iptables
临时关闭:service iptables stop
永久关闭:chkconfig iptables off
3.2关闭selinux
vi /etc/sysconfig/selinux
将SELINUX修改为DISABLED,即SELINUX=DISABLED
3.3环境变量
echo ‘ exportPATH=/application/mysql/mysql-5.6.35/bin:$PATH
‘ >> /etc/profile
source /etc/profile
tail -1/etc/profile
exportPATH=/application/mysql/mysql-5.6.35/bin:$PATH
四、配置mysql
4.1创建相关目录
mkdir -p/data/{3306,3307}
mkdir -p/data/3306/ {data,log,tmp}
mkdir -p/data/3307/ {data,log,tmp}
4.2更改目录权限
chown -Rmysql:mysql /data/
chown -Rmysql:mysql /application/mysql/
4.3复制my.cnf文件到etc目录
cp /application/mysql/mysql-5.6.35/support-files/my-default.cnf/etc/my.cnf
4.4修改my.cnf(在一个文件中修改即可)
cat /etc/my.cnf
[client]
port=3306
socket=/tmp/mysql.sock
[mysqld_multi]
mysqld =/application/mysql/mysql-5.6.35/bin/mysqld_safe
mysqladmin =/application/mysql/mysql-5.6.35/bin/mysqladmin
log =/data/mysqld_multi.log
[mysqld]
user=mysql
basedir =/application/mysql/mysql-5.6.35
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[mysqld3306]
mysqld=mysqld
mysqladmin=mysqladmin
datadir=/data/3306/data
port=3306
server_id=3306
socket=/tmp/mysql_3306.sock
log-output=file
slow_query_log =1
long_query_time= 1
slow_query_log_file= /data/3306/log/slow.log
log-error =/data/3306/log/error.log
binlog_format =mixed
log-bin =/data/3306/log/mysql3306_bin
[mysqld3307]
mysqld=mysqld
mysqladmin=mysqladmin
datadir=/data/3307/data
port=3307
server_id=3307
socket=/tmp/mysql_3307.sock
log-output=file
slow_query_log =1
long_query_time= 1
slow_query_log_file= /data/3307/log/slow.log
log-error =/data/3307/log/error.log
binlog_format =mixed
log-bin =/data/3307/log/mysql3307_bin
4.5初始化数据库
初始化3306数据库
/application/mysql/mysql-5.6.35/scripts/mysql_install_db --basedir=/usr/local/mysql/ --datadir=/data/3306/data--defaults-file=/etc/my.cnf
初始化3307数据库
/application/mysql/mysql-5.6.35/scripts/mysql_install_db --basedir=/usr/local/mysql/ --datadir=/data/3307/data--defaults-file=/etc/my.cnf
检查数据库是否初始化成功
出现两个”OK”
4.6查看数据库是否初始化成功
查看3306数据库
ls /data/mysql/mysql_3306/data
auto.cnf ibdata1 ib_logfile0 ib_logfile1 mysql mysql.pid performance_schema test
查看3307数据库
Ls /data/mysql/mysql_3307/data
auto.cnf ibdata1 ib_logfile0 ib_logfile1 mysql mysql.pid performance_schema test
4.7设置启动文件
cp /application/mysql/mysql-5.6.35/support-files/mysql.server/etc/init.d/mysql
五、启动维护
5.1启动全部实例
/application/mysql/mysql-5.6.35/bin/mysqld_multi start
/application/mysql/mysql-5.6.35/bin/mysqld_multi report
具体可参考文章