这篇文章主要为大家详细介绍了Linux下安装MySQL多实例作为数据备份服务器实现多主到一从多实例的备份,具有一定的参考价值,可以用来参考一下。
感兴趣的小伙伴,下面一起跟随四海网的小编小韵来看看吧!
1、从MYSQL官方下载MYSQL的源码版本【一定要是源码版本】代码如下:
[注] 添加mysql组和用户
#groupadd mysql
#useradd -g mysql mysql
[注] 解包到/usr/local
# tar -xzf mysql-standard-4.1.9-pc-linux-gnu-i686.tar.gz -C /usr/local
[注] 建立软链接,方便操作(此处给此连接命名为mysql001,也可为其它的名字)
#cd /usr/local
#ln -s mysql-standard-5.0.15-linux-i686-glibc23 mysql001
#cd mysql001
#scripts/mysql_install_db
#chown -R root .
#chown -R mysql data
#chgrp -R mysql .
[注] 复制data,以供单版本多实例分配
#cp -a data data_1
#cp -a data data_2
[注] 添加多实例配置文件
#cd /usr/local/mysql001/bin
#cat >my_multi.cnf
[注] 以下是my_multi.cnf的配置信息,可依此复制
[mysqld_multi]
mysqld = /usr/local/mysql001/bin/mysqld_safe
mysqladmin = /usr/local/mysql001/bin/mysqladmin
user = root
password = root
[mysqld1]
socket = /tmp/mysql_001.sock
port = 3301
pid-file = /usr/local/mysql001/data_1/hostname.pid
datadir = /usr/local/mysql001/data_1
log = /usr/local/mysql001/data_1/hostname.log
user = mysql
# slave setting
server-id = 2
master-host = 192.168.1.85
master-port = 3306
master-user = backup
master-password = 123456
replicate-do-db = gs_database
replicate-do-db = gs_log
master-connect-retry=30
[mysqld2]
socket = /tmp/mysql_5_2.sock
port = 3302
pid-file = /usr/local/mysql001/data_2/hostname.pid
datadir = /usr/local/mysql001/data_2
log = /usr/local/mysql001/data_2/hostname.log
user = mysql
# slave setting
server-id = 3
master-host = 192.168.1.69
master-port = 3306
master-user = backup
master-password = 123
replicate-do-db = gs_databaes
replicate-do-db = gs_log
master-connect-retry=30
代码如下:
#vi /etc/profile # 添加系统环境变量。
export MYSQL_HOME=/usr/local/mysql001/bin
export PATH=$PATH:$MYSQL_HOME
代码如下:
vi /etc/rc.local
# 添加
mysqld_multi --defaults-extra-file=/usr/local/src/mysql_dir/bin/my_multi.cnf start 1,2
本文来自:http://www.q1010.com/177/10573-0.html
注:关于Linux下安装MySQL多实例作为数据备份服务器实现多主到一从多实例的备份的内容就先介绍到这里,更多相关文章的可以留意四海网的其他信息。
关键词:MYSQL
四海网收集整理一些常用的php代码,JS代码,数据库mysql等技术文章。