程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> MYSQL數據庫 >> MySQL綜合教程 >> mysql的物理備份和增量備份

mysql的物理備份和增量備份

編輯:MySQL綜合教程

物理備份:
mysql
               SHOW VARIABLES LIKE'datadir';
                use hellodb;
                SHOW TABLE STATUS;
                mysql
             FLUSH LOGS WITH READ LOCK;
             \q
             lvcreate -L 50M -n mysnap -s /dev/myvg/mydata
             mysql     
             UNLOCK TABLES;
               \q
              mount /dev/myvg/mysnap /mnt
             cd /mnt
             cd data/
             ls
             tar -jcf /root/mysql.tar.bz2   hellodb ibdata1 ib_logfile* mysql-bin* 
            ls
            cd
             umount /mnt
              lvremove --force /dev/myvg/mysnap
             service mysqld start
              ls /mydata/data
             rm -rf  /mydata/data/*
              cd /usr/local/mysql
                 chown -R mysql:mysql data/ 
              scripts/          --datadir=/mydata/data --user=mysql
              killall mysqld
              service mysqld start
              service mysqld stop
                cd /mydata
                  cd data
                   ls
                   tar xf /root/mysql.tar.bz2 -C ./
                     ls
              service mysqld start
              mysql
              SHOW DATABASES;
增量備份:
            SHOW MASTER STATUS
             lvcreate -L 50M -n mysnap -s /dev/myvg/mydata
              mysql     
             UNLOCK TABLES;
              tar -jcf /root/mysql.tar.bz2   hellodb ibdata1 ib_logfile* mysql-bin* 
             mysql
             use hellodb;
                 INSERT INTO t2 values('huhu')
              SHOW MASTER STATUS;
               mysqlbinlog --start-position  201 mysql-bin.000004 >/root/mysql2.incr.sql
            cd
              serviece mysqld stop
              rm -rf /mydata/data/*
             cd /usr/local/mysql
                 chown -R mysql:mysql data/ 
              scripts/          --datadir=/mydata/data --user=mysql 
               service mysqld start
               serviece mysqld stop
                cd /mydata/data/
                tar xf /root/mysql.tar.bz2 -C ./    
                 service mysqld start
                 mysql
                 use hellodb;
                 SELECT * FROM t2;
                 #mysql <root/mysql2.incr.sql
                 mysql
                 use hellodb;
                 SELECT * FROM t2;
作者“linux”

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved