Fedora 39
Sponsored Link

MariaDB : बैकअप2023/11/20

 
MariaDB डेटा के बैकअप और पुनर्स्थापना के लिए, [mariabackup] के साथ चलना संभव है।
[1] आमतौर पर [mariabackup] टूल निर्भरता के लिए MariaDB सर्वर के साथ इंस्टॉल किया जाता है, लेकिन अगर यह इंस्टॉल नहीं हुआ है, तो पहले इसे इंस्टॉल करें।
[root@www ~]#
dnf -y install mariadb-backup
[2] बैकअप चलाएँ।
उदाहरण के लिए, [/home/mariadb_backup] के अंतर्गत बैकअप प्राप्त करें।
[root@www ~]#
mkdir /home/mariadb_backup

[root@www ~]#
mariabackup --backup --target-dir /home/mariadb_backup -u root

[00] 2023-11-20 09:45:07 Connecting to server host: localhost, user: root, password: not set, port: not set, socket: not set
[00] 2023-11-20 09:45:07 Using server version 10.5.22-MariaDB
mariabackup based on MariaDB server 10.5.22-MariaDB Linux (x86_64)
[00] 2023-11-20 09:45:07 uses posix_fadvise().
[00] 2023-11-20 09:45:07 cd to /var/lib/mysql/
[00] 2023-11-20 09:45:07 open files limit requested 0, set to 1024
[00] 2023-11-20 09:45:07 mariabackup: using the following InnoDB configuration:
[00] 2023-11-20 09:45:07 innodb_data_home_dir =
[00] 2023-11-20 09:45:07 innodb_data_file_path = ibdata1:12M:autoextend
[00] 2023-11-20 09:45:07 innodb_log_group_home_dir = ./
[00] 2023-11-20 09:45:07 InnoDB: Using Linux native AIO
.....
.....
[00] 2023-11-20 09:45:09 Writing backup-my.cnf
[00] 2023-11-20 09:45:09         ...done
[00] 2023-11-20 09:45:09 Writing xtrabackup_info
[00] 2023-11-20 09:45:09         ...done
[00] 2023-11-20 09:45:09 Redo log (from LSN 47577 to 47589) was copied.
[00] 2023-11-20 09:45:09 completed OK!

[root@www ~]#
ll /home/mariadb_backup

total 12336
-rw-r-----. 1 root root    24576 Nov 20 09:45 aria_log.00000001
-rw-r-----. 1 root root       52 Nov 20 09:45 aria_log_control
-rw-r-----. 1 root root      285 Nov 20 09:45 backup-my.cnf
-rw-r-----. 1 root root 12582912 Nov 20 09:45 ibdata1
-rw-r-----. 1 root root     2560 Nov 20 09:45 ib_logfile0
drwx------. 2 root root     4096 Nov 20 09:45 mysql
drwx------. 2 root root       20 Nov 20 09:45 performance_schema
drwx------. 2 root root       64 Nov 20 09:45 test_database
-rw-r-----. 1 root root       73 Nov 20 09:45 xtrabackup_checkpoints
-rw-r-----. 1 root root      432 Nov 20 09:45 xtrabackup_info
[3] किसी अन्य होस्ट पर बैकअप से डेटा पुनर्स्थापित करने के लिए, निम्नानुसार चलाएँ।
पुनर्स्थापित करने से पहले, बैकअप डेटा को [rsync] या [scp] इत्यादि के साथ लक्ष्य होस्ट पर स्थानांतरित करें।
# MariaDB रोकें और मौजूदा डेटा हटा दें

[root@node01 ~]#
systemctl stop mariadb

[root@node01 ~]#
rm -rf /var/lib/mysql/*
# बैकअप डेटा स्थानांतरित किया गया

[root@node01 ~]#
ll mariadb_backup.tar.gz

-rw-r--r--. 1 root root 546815 Nov 20 09:47 mariadb_backup.tar.gz
[root@node01 ~]#
tar zxvf mariadb_backup.tar.gz

# कार्य पुनर्स्थापित करने से पहले कार्य तैयार करें चलाएँ (ठीक है यदि [completed OK])

[root@node01 ~]#
mariabackup --prepare --target-dir /root/mariadb_backup

mariabackup based on MariaDB server 10.5.22-MariaDB Linux (x86_64)
[00] 2023-11-20 09:51:51 cd to /root/mariadb_backup/
[00] 2023-11-20 09:51:51 open files limit requested 0, set to 1024
[00] 2023-11-20 09:51:51 This target seems to be not prepared yet.
[00] 2023-11-20 09:51:51 mariabackup: using the following InnoDB configuration for recovery:
[00] 2023-11-20 09:51:51 innodb_data_home_dir = .
[00] 2023-11-20 09:51:51 innodb_data_file_path = ibdata1:12M:autoextend
[00] 2023-11-20 09:51:51 innodb_log_group_home_dir = .
[00] 2023-11-20 09:51:51 InnoDB: Using Linux native AIO
[00] 2023-11-20 09:51:51 Starting InnoDB instance for recovery.
[00] 2023-11-20 09:51:51 mariabackup: Using 104857600 bytes for buffer pool (set by --use-memory parameter)
2023-11-20  9:51:51 0 [Note] InnoDB: Uses event mutexes
2023-11-20  9:51:51 0 [Note] InnoDB: Compressed tables use zlib 1.2.13
2023-11-20  9:51:51 0 [Note] InnoDB: Number of pools: 1
2023-11-20  9:51:51 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
2023-11-20  9:51:51 0 [Note] InnoDB: Using Linux native AIO
2023-11-20  9:51:51 0 [Note] InnoDB: Initializing buffer pool, total size = 104857600, chunk size = 104857600
2023-11-20  9:51:51 0 [Note] InnoDB: Completed initialization of buffer pool
2023-11-20  9:51:51 0 [Note] InnoDB: Starting crash recovery from checkpoint LSN=47577,47577
[00] 2023-11-20 09:51:51 Last binlog file , position 0
[00] 2023-11-20 09:51:51 completed OK!

# पुनर्स्थापना चलाएँ

[root@node01 ~]#
mariabackup --copy-back --target-dir /root/mariadb_backup

mariabackup based on MariaDB server 10.5.22-MariaDB Linux (x86_64)
[01] 2023-11-20 09:52:17 Copying ./aria_log_control to /var/lib/mysql/aria_log_control
[01] 2023-11-20 09:52:17         ...done
[01] 2023-11-20 09:52:17 Copying ./aria_log.00000001 to /var/lib/mysql/aria_log.00000001
[01] 2023-11-20 09:52:17         ...done
[01] 2023-11-20 09:52:17 Copying ibdata1 to /var/lib/mysql/ibdata1
[01] 2023-11-20 09:52:17         ...done
[01] 2023-11-20 09:52:17 Copying ./mysql/innodb_table_stats.ibd to /var/lib/mysql/mysql/innodb_table_stats.ibd
[01] 2023-11-20 09:52:17         ...done
[01] 2023-11-20 09:52:17 Copying ./mysql/innodb_index_stats.ibd to /var/lib/mysql/mysql/innodb_index_stats.ibd
[01] 2023-11-20 09:52:17         ...done
.....
.....
[01] 2023-11-20 09:52:17 Copying ./performance_schema/db.opt to /var/lib/mysql/performance_schema/db.opt
[01] 2023-11-20 09:52:17         ...done
[01] 2023-11-20 09:52:17 Copying ./xtrabackup_info to /var/lib/mysql/xtrabackup_info
[01] 2023-11-20 09:52:17         ...done
[00] 2023-11-20 09:52:17 completed OK!

[root@node01 ~]#
chown -R mysql:mysql /var/lib/mysql

[root@node01 ~]#
systemctl start mariadb

मिलान सामग्री