[MariaDB] MariaDBÀÇ Data À§Ä¡ º¯°æÇϱâ (CentOS 7 ±âÁØ)
CentOS 7¿¡¼ ¼³Ä¡µÇ´Â MariaDB 5.5´Â ±âº»ÀûÀ¸·Î /var/lib/mysql¿¡ DB °¡ ÀúÀåµÈ´Ù.
ÀÌ DB °æ·Î°¡ root ÆÄƼ¼Ç¿¡ ÇØ´çµÇ´Âµ¥, ÀÌ·ÎÀÎÇØ ÆÄƼ¼Ç ¿ë·®ºÎÁ· »óȲÀ» ÃÊ·¡ÇÒ ¼ö Àֱ⿡ dataÀ§Ä¡¸¦ º¯°æÇÒ ÇÊ¿ä°¡ ÀÖ´Ù.
0) MariaDB ÀÇ data À§Ä¡ È®ÀÎ
mysql -u root -p
·Î mariadb¿¡ Á¢¼ÓÇÑ ÈÄ,
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.60-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> select @@datadir;
+-------------------+
| @@datadir |
+-------------------+
| /var/lib/mysql/ |
+-------------------+
1 row in set (0.01 sec)
MariaDB [(none)]>
1) MariaDB ¼ºñ½º Á¤Áö
sudo systemctl stop mariadb
2) »õ·Î¿î Data µð·ºÅ丮 »ý¼º ¹× µ¥ÀÌÅÍ º¹»çÇϱâ
(Data µð·ºÅ丮¸¦ /home/data/mysql ·Î ÇÑ´Ù´Â °¡Á¤ ÇÏ¿¡)
sudo mkdir /home/data/
sudo rsync -av /var/lib/mysql /home/data/
sudo chown -R mysql:mysql /home/data/mysql
3) my.cnf ÆÄÀÏÀ» ¼öÁ¤ÇÏ¿© MariaDBÀÇ data µð·ºÅ丮 °æ·Î º¯°æ
sudo vi /etc/my.cnf
4) SELinux º¸¾È context Ãß°¡ ¹× ¼ºñ½º ½ÃÀÛ
sudo semanage fcontext -a -t mysqld_db_t "/data/mysql(/.*)?"
sudo restorecon -R /data/mysql
sudo systemctl start mysql
5) º¯°æµÈ data µð·ºÅ丮 È®ÀÎÇϱâ
mysql -u root -p
·Î mariadb¿¡ Á¢¼ÓÇÑ ÈÄ,
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.60-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> select @@datadir;
+-------------------+
| @@datadir |
+-------------------+
| /home/data/mysql/ |
+-------------------+
1 row in set (0.01 sec)
MariaDB [(none)]>
6) ±âÁ¸ data µð·ºÅ丮 »èÁ¦Çϱâ
sudo rm -R /var/lib/mysql
»èÁ¦ÇÑ ÈÄ, Çϵåµð½ºÅ©ÀÇ ÀúÀå¿ë·® È®ÀÎÀº df ·Î.
df