设为首页收藏本站
查看: 72|回复: 0

[PHP] Mysql双机热备主从配置_MySQL-mysql教程

[复制链接]

论坛元老

Rank: 6Rank: 6

积分
34274
主题
17031
UID
1347
M币
67
贡献
17176

  • 发表于 2017-5-12 16:11:00 | 显示全部楼层 |阅读模式
    replication on mysql: Master/Slave. Master server is the production MySQL instance. Slave server is the java host (123.57.39.*). First we need to install MySQL server and client on the java host(123.57.39.*). 1.in master execute: CREATE USER 'replica'@'123.57.39.*' IDENTIFIED BY 'replica@123'; GRANT REPLICATION SLAVE ON *.* TO 'replica'@'123.57.39.*'; flush privileges; 2. add the following to [mysqld] segment in /etc/my.cnf of master DB. And make sure mysql user is the owner of log-bin direcotry. Otherwise you will get error when you startup MySQL. server-id=1 log-bin=/var/lib/mysql/binlog/mysql-bin expire_logs_days=7 3. On Slave,add the following to [mysqld] segment in /etc/my.cnf server-id=2 innodb_flush_log_at_trx_commit=2 //this line is not required,just improve innodb performance expire_logs_days=7 4.in master,then copy data to slave mysqldump --master-data=2 --user=root --password=fadfafafaD --single-transaction --all-databases > replica.sql 5.copy the replica.sql to slave server,then import data in slave. mysql --user=root --password=fadfafafaD
    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    在我站开通SVIP可同时获得17个站点VIP资源 立即登录 立即注册
    快速回复 返回顶部 返回列表