Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to transfer Partition of Database data File

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

Database data files how to partition transfer, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.

Since my colleagues did not plan the disk partition before, we can see that the data and the system are in the same partition, there is no separate data partition for the database, and a partition of 640G is not used. The following is a brief introduction to the transfer process of mysql database data files.

1. Create a new data partition

Space is needed, let's keep it simple.

# fdisk / dev/sdb n-> p-> 1-> Enter- > Enter- > w # create physical volume # pvcreate / dev/sdb1 # create logical volume # vgcreate datavg/ dev/sdb1 # lvcreate-n lv_data-L + 200g datavg # format disk # mkfs.ext4 / dev/datavg/lv_data # mount # vim / etc/fstab / dev/datavg/lv_data / tmsdata ext4 defaults 00 # mount-a

2. Data transfer in mysql database

The previous data files and logs are in the / data directory, and now need to be transferred to the new data directory / tmsdata

(1) stop the database service

Systemctl stop mysqld systemctl status mysqld # write the cache to the data file, do it a few more times, you can't go wrong with sync sync

(2) transfer data files and logs

Cp-rf / data/* / tmsdata/ chmod-R 755 / tmsdata chown-R mysql:mysql / tmsdata/

(3) modify my.cnf configuration

# vim / etc/my.cnf [mysqld] datadir=/tmsdata/datafile log-error=/tmsdata/log/mysqld.log # Note that the binary log should also be changed to log-bin = / tmsdata/log/mysql-bin.log log-bin-index = / tmsdata/log/binlog.index

3. Start the mysql service and verify

If there is a master-slave service, it is best to set the database read-only when stopping the database service, and then enable read and write after opening the slave library.

# vim / etc/my.cnf [mysqld] datadir=/tmsdata/datafile log-error=/tmsdata/log/mysqld.log # Note that the binary log should also be changed to log-bin = / tmsdata/log/mysql-bin.log log-bin-index = / tmsdata/log/binlog.index

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report