• MySQL 冷备份 恢复 (兼创建)


    MySQL 冷备份 恢复 (兼创建)

    安装mariaDB 数据库

    数据目录为/mysql/date

    1. 新机器环境为centos 7,会自带安装mariadb,首先卸载mariadb
    [root@localhost ~]# rpm -qa|grep mariadb
    mariadb-libs-5.5.60-1.el7_5.x86_64
    [root@localhost ~]# rpm -e mariadb-libs-5.5.60-1.el7_5.x86_64
    error: Failed dependencies:
            libmysqlclient.so.18()(64bit) is needed by (installed) postfix-2:2.10.1-7.el7.x86_64
            libmysqlclient.so.18(libmysqlclient_18)(64bit) is needed by (installed) postfix-2:2.10.1-7.el7.x86_64
    [root@localhost ~]# rpm -e mariadb-libs-5.5.60-1.el7_5.x86_64 --nodeps
    [root@localhost ~]# rpm -qa|grep mariadb
    
    1. 安装mariadb
      通过yum;或者自行下载RPM 和依赖包安装。

      ***** 将/var/lib/mysql 下的文件,复制到所需的数据文件目录。修改所属用户和组。

      3.编辑MariaDB 配置文件
      编辑/etc/my.cnf.d/server.cnf ,或者/etc/my.cnf 文件

    #
    # These groups are read by MariaDB server.
    # Use it for options that only the server (but not clients) should see
    #
    # See the examples of server my.cnf files in /usr/share/mysql/
    #
    # this is read by the standalone daemon and embedded servers
    
    [client]
    socket=/u01/mysql/data/mysql.sock
    
    [server]
    socket=/u01/mysql/data/mysql.sock
    datadir=/u01/mysql/data
    
    [mysqld]
    [galera]
    [embedded]
    [mariadb]
    [mariadb-10.4]
    
    
    1. 关闭selinux ,启动MariaDB
      setenforce 0

    冷备恢复

    说白了,把源库关闭,传数据文件传过去,之后启动目标端数据库,就跟源库一毛一样的
    源端:rsync -avP /date 888.888.888.888:/data
    传输结束后,目标端(如需修改路径或配置路径位置则修改配置文件)
    systemctl start mariadb
    至此,结束。

    进一步思考冷备。

    将一个数据库中的表(innodb表),冷备恢复目标端,其他的表是否可用。
    传输test 表,和ibdata1 文件至目标端,删除ib_logdata*,打开数据库,查看其他数据库表,不可用,报错为:ERROR 1146 (42S02): Table 'blizzard.t_change_acategory' doesn't exist

  • 相关阅读:
    bzoj 1367
    codeforces 757F
    bzoj 3600
    比赛环境设置
    线段树合并
    BZOJ2105: 增强型LCP
    BZOJ3156: 防御准备
    BZOJ3252: 攻略
    BZOJ2464: 中山市选[2009]小明的游戏
    Beta Round #9 (酱油杯noi考后欢乐赛)乌鸦喝水
  • 原文地址:https://www.cnblogs.com/Leo-Cjh/p/13652797.html
Copyright © 2020-2023  润新知