Heim >Datenbank >MySQL-Tutorial >mysql的物理备份和增量备份_MySQL

mysql的物理备份和增量备份_MySQL

WBOY
WBOYOriginal
2016-06-01 13:45:121142Durchsuche

bitsCN.com

物理备份:
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                  mysql
                 use hellodb;
                 SELECT * FROM t2;
作者“linux”

bitsCN.com
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn