CN113868188A - Method, system, equipment and medium for modifying storage position of database file - Google Patents

Method, system, equipment and medium for modifying storage position of database file Download PDF

Info

Publication number
CN113868188A
CN113868188A CN202110984868.XA CN202110984868A CN113868188A CN 113868188 A CN113868188 A CN 113868188A CN 202110984868 A CN202110984868 A CN 202110984868A CN 113868188 A CN113868188 A CN 113868188A
Authority
CN
China
Prior art keywords
data file
database
synchronization
file
target
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110984868.XA
Other languages
Chinese (zh)
Inventor
张洪宾
马国良
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Suzhou Inspur Intelligent Technology Co Ltd
Original Assignee
Suzhou Inspur Intelligent Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Suzhou Inspur Intelligent Technology Co Ltd filed Critical Suzhou Inspur Intelligent Technology Co Ltd
Priority to CN202110984868.XA priority Critical patent/CN113868188A/en
Publication of CN113868188A publication Critical patent/CN113868188A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/11File system administration, e.g. details of archiving or snapshots
    • G06F16/119Details of migration of file systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1448Management of the data involved in backup or backup restore
    • G06F11/1451Management of the data involved in backup or backup restore by selection of backup contents

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Quality & Reliability (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention has proposed a method for revising the file storage location of the database, system, apparatus and medium, said method comprises copying the original data file of the storage space to be changed to the target storage space, and record the database time number when carrying out the copy command; performing incremental synchronization on the data blocks which are larger than the database time number in the original data file to the target data file; after the increment synchronization is completed, the read-write operation of the original data file is switched to the target data file, and the data file modification inside the database is completed to point to the target data file. Based on the method, the invention also provides a system, equipment and a storage medium for modifying the storage position of the database file, which avoids the problem that the business system cannot be used because the storage space of the data file is changed and the database is required to be closed or the tablespace is offline, improves the usability of the database, can simultaneously migrate a plurality of data files and improves the efficiency of changing the storage space of the data files.

Description

Method, system, equipment and medium for modifying storage position of database file
Technical Field
The invention belongs to the technical field of databases, and particularly relates to a method, a system, equipment and a medium for modifying a storage position of a database file.
Background
The Oracle database is composed of a plurality of tablespaces, each tablespace in turn composed of a plurality of data files, each data file stored in a storage space. When a data file storage space is required to be changed, if the data file belongs to a database system tablespace, the database needs to be stopped firstly, if the data file belongs to a service tablespace, the data file or the corresponding tablespace needs to be offline, then the data file is moved to a new storage position, after the data file is moved, a related command for modifying the path of the data file is executed in the database, after the data file is moved, the corresponding tablespace is set to be online or the database is started, and normal access and use of the database are recovered.
According to whether a data file required to be moved is a data file of a system table space, the existing logic moving data file has the following two modes: first, the case where the data file belongs to the system tablespace: 1) shutdown closes the database; 2) the MV moves the data file to a new storage space; 3) after the database is started to MOUNT, executing an alter database rename file 'oldfile1' to 'newfile2' to modify the file position; 4) the alter database open. Secondly, the data file belongs to the business tablespace, and 1) the alter tablespace tbs _ name offset takes the tablespace where the data file is located off-line; 2) the MV moves the data file to a new storage space; 3) executing the alter database rename file 'oldfile1' to 'newfile2' to modify the file position; 4) the alter tablespace tbs _ name online brings the tablespace where the data file is located back online. In both of the above two ways, the database cannot normally provide service to the outside due to the fact that the corresponding data cannot be accessed because the database is closed or the data file table space is offline, and normal use of the service system is affected. Under the condition that the OPEN state of the database is normally served externally, all data files in the database are opened by the database and read-write operation is carried out at any time, at the moment, the data files can not be moved to other storage spaces in modes of mv commands or cutting and the like of an operating system, the normal reading and writing of the database to the data files can be interrupted accidentally through the operation, and the data files can be damaged, even the database is damaged.
Disclosure of Invention
In order to solve the technical problems, the invention provides a method, a system, equipment and a medium for modifying a storage position of a database file, aiming at solving the problem that the access of the database is influenced due to the offline of the data file or the closing of the database when the storage space of the data file is modified by the database, and completing the modification of the storage space of the data file modified by the data file under the condition of not influencing the access of the database.
In order to achieve the purpose, the invention adopts the following technical scheme:
a method of modifying a storage location of a database file, comprising the steps of:
copying an original data file of a storage space to be replaced to a target storage space, and recording a database time number when a copy command is executed;
performing incremental synchronization on the data blocks which are larger than the database time number in the original data file to the target data file;
after the increment synchronization is completed, the read-write operation of the original data file is switched to the target data file, and the data file modification inside the database is completed to point to the target data file.
Further, copying the original data file of the storage space to be replaced to the target storage space, and recording the database time number when the copy command is executed further includes: recording the execution condition of the copy action in the view, and recording the state of the copy action in the view as copying when copying; and after the original data file is copied, recording the state of the copying action in the view as that the copying is finished.
Further, the performing incremental synchronization on the data block larger than the database time number in the original data file to the target data file further includes:
after the increment synchronization is started, the database records the modification process of the original data file, and synchronizes the data blocks in the original data file, which are larger than the time number of the database, to the target data file according to the synchronization frequency specified by the parameters, so as to achieve the consistent synchronization of the target data file and the original data file.
Further, the method further comprises: and after the incremental synchronization is finished, performing incremental synchronization according to the frequency specified by the synchronization frequency parameter.
Further, the incremental synchronization includes:
if the data blocks are newly added, correspondingly adding the data blocks in the target data file;
if the data block is deleted, deleting the data block in the target data file;
and if the data block is the modified data block, replacing the data block at the corresponding position of the target data file.
Further, after the incremental synchronization is completed, the read-write operation on the original data file is switched to the target data file, and the completion of the data file modification inside the database to point to the target data file specifically includes:
after the read-write operation of the original data file is switched to the target data file, the first I/O operation of the original data file is frozen, the increment synchronization is carried out from the original data file to the target data file once so as to achieve the complete consistency of the contents of the two data files, and the second I/O operation of the target data file is recovered after the increment synchronization is completed.
Further, the method further comprises: datafile _ sync _ powerlimit is used to control the rate of data file copying, the frequency of incremental synchronization and the rate of incremental synchronization.
The invention also provides a system for modifying the storage position of the database file, which comprises a copying module, a synchronization module and a switching module;
the copying module is used for copying an original data file of a storage space to be replaced to a target storage space and recording a database time number when a copying command is executed;
the synchronization module is used for performing incremental synchronization on the data blocks which are larger than the database time number in the original data file to the target data file;
and the switching module is used for switching the read-write operation of the original data file to the target data file after the increment synchronization is completed, and finishing the modification of the data file in the database to point to the target data file.
The invention also proposes a device comprising:
a memory for storing a computer program;
a processor for implementing the method steps when executing the computer program.
The invention also proposes a readable storage medium having stored thereon a computer program which, when being executed by a processor, carries out the method steps.
The effect provided in the summary of the invention is only the effect of the embodiment, not all the effects of the invention, and one of the above technical solutions has the following advantages or beneficial effects:
the invention has proposed a method for revising the file storage location of the database, system, apparatus and medium, said method comprises copying the original data file of the storage space to be changed to the target storage space, and record the database time number when carrying out the copy command; performing incremental synchronization on the data blocks which are larger than the database time number in the original data file to the target data file; after the increment synchronization is completed, the read-write operation of the original data file is switched to the target data file, and the data file modification inside the database is completed to point to the target data file. Under the condition that the database is normally opened for external service, all data files in the database are opened by the database and read-write operation is carried out at any time, and at the moment, the data files can not be moved to other storage spaces in modes of mv commands, cutting and the like of an operating system, so that the normal reading and writing of the database to the data files can be interrupted accidentally by the operation, and the data files can be damaged, even the database is damaged. According to the method, an execution command in a database copies a data file to be moved from the database to a target address, the database still normally reads and writes an original data file in the copying process, after the copying is completed, the modification operation of the original data file by the database in the copying process can be automatically synchronized to the target data file, the original data file keeps incremental synchronization with a certain frequency to the target data file so as to keep the consistency of the target data file and the original data file, finally, the execution command in the database switches the data file into the target data file, at the moment, all reading and writing of the database can be executed on the target data file, the original data file is not needed any more, and the data file is replaced to a target storage position on line. The invention avoids the problem that the business system cannot be used due to the fact that the database is closed or the tablespace is offline when the storage space of the data file is changed, improves the usability of the database, can simultaneously migrate a plurality of data files, improves the efficiency of changing the storage space of the data file, and provides a new choice for the migration of the database.
Based on a method for modifying the storage location of the database file, the invention also provides a system, equipment and a storage medium for modifying the storage location of the database file, which also have the above functions and are not described herein again.
Drawings
Fig. 1 is a flowchart of a method for modifying a storage location of a database file according to embodiment 1 of the present invention;
fig. 2 is a schematic diagram of a system for modifying a storage location of a database file according to embodiment 2 of the present invention.
Detailed Description
In order to clearly explain the technical features of the present invention, the following detailed description of the present invention is provided with reference to the accompanying drawings. The following disclosure provides many different embodiments, or examples, for implementing different features of the invention. To simplify the disclosure of the present invention, the components and arrangements of specific examples are described below. Furthermore, the present invention may repeat reference numerals and/or letters in the various examples. This repetition is for the purpose of simplicity and clarity and does not in itself dictate a relationship between the various embodiments and/or configurations discussed. It should be noted that the components illustrated in the figures are not necessarily drawn to scale. Descriptions of well-known components and processing techniques and procedures are omitted so as to not unnecessarily limit the invention.
Example 1
The embodiment 1 of the invention provides a method for modifying a storage position of a database file, which comprises the steps of copying a data file needing to be moved from a database to a target address by executing a command in the database, normally reading and writing an original data file in the copying process, automatically synchronizing the modification operation of the original data file in the copying process to the target data file by the database after the copying is finished, keeping the incremental synchronization of a certain frequency from the original data file to the target data file so as to keep the consistency of the target data file and the original data file, finally switching the data file into the target data file by executing the command in the database, executing all reading and writing of the database on the target data file at the moment, and realizing the online replacement of the data file to the target storage position without the original data file.
Fig. 1 is a flowchart of a method for modifying a storage location of a database file according to embodiment 1 of the present invention;
in step S101, execution of the flow is started;
in step S102, copying an original data file of a storage space to be replaced to a target storage space, and recording a database time number when a copy command is executed;
for a data file requiring storage space replacement, a copy command of the data file is executed in the database, and the copy command records the SCN number of the database (assuming that the SCN number is AAA) when the command is executed. Wherein SCN: the system change number, time number in Oracle. At this time, the execution condition of the copy action starts to be recorded in the relevant view, and the copy state in the view is copying. The database copies the original data file to the target storage space.
Adding a command of the upper database copy datafile '/orabak/oradata/testdb/testdb/tbs101.dbf' to '/u01/app/oracle/oradata/testdb/tbs101. dbf'; instructing the database to copy the data file from/orabak/oradata/testdb/testdb/tbs 101.dbf to the new address/orabak/oradata/testdb/testdb/tbs 101. dbf.
In step S103, performing incremental synchronization on the data blocks in the original data file that are greater than the database time number to the target data file;
a dfcs (database file copy and sync) process is added for data file copying and data file incremental synchronization. After executing the alter database copy command, the dfcs process determines whether the file exists according to the original data file path and the file name, and if the file does not exist, the command line returns error information of 'file does not exist'. And meanwhile, judging whether the data file belongs to the database, and if not, returning error information that the data file does not belong to the database by the command line. If the data file can not be written into the required target directory due to the target directory authority or the incorrect target directory, the command line returns the error information of 'data file can not be created in the target directory'. After the copying is started, the SCN number of the database at the moment is recorded, and the statistical information of the data file copying is saved in the table t _ datafile _ copying and is updated once per second.
After the data file is copied, the action type of the copying action in the t _ datafile _ copying view is changed into done after the data file is copied, then, the incremental synchronization of the original data file change data block to the target data file is started, and the synchronization operation records the t _ datafile _ synchronizing view. And searching data blocks with SCN larger than AAA from the original data file, wherein the data blocks are data blocks which change during the copying of the data file, and correspondingly processing the changed data blocks in the target data file according to the data block types (if the changed data blocks are newly added, the changed data blocks are correspondingly added in the target data file, if the changed data blocks are deleted data blocks, the changed data blocks are deleted in the target data file, and if the changed data blocks are modified, the changed data blocks are substituted for the data blocks at the corresponding positions of the target data file). The operation is the incremental synchronous processing of the changed data blocks from the beginning of copying
After the incremental synchronization is started, the modification of the original data file is recorded by the database, and the modified data block is synchronized to the target data file according to the synchronization frequency specified by the parameters, so that the target data file and the original data file are synchronized in a consistent manner. After each synchronization, incremental synchronization is carried out according to the frequency specified by the synchronization frequency parameter.
To oversee the data file copy and synchronization status and progress, a view is provided for querying and monitoring the copy and incremental synchronization situation when data file copying or incremental synchronization is initiated.
As shown in the table below, the table name t _ datafile _ copying is used for recording the copying condition, and the progress, the consumed time and the approximate completion time of the copying can be known through the view.
Column name Type of field Description of the invention
ID number Sequentially increasing serial numbers, unique identification of each record in the table
source_file varchar2(200) Original data file path and name
dest_file varchar2(200) Target data file path and name
status varchar2(100) Copy state, taking copying and done values
start_time date Copy start time
end_time date End time of copying
all_time number Duration of copy (second unit)
copied_size number Copied file size (Unit M)
last_size number Residual File size (Unit M)
copy_rate number Copy rate (unit M/s)
The table name t _ datafile _ syncing, used to record the incremental synchronization case, is as follows.
Column name Type of field Description of the invention
ID number Serial number, unique identifier of each record in the table
source_file varchar2(200) Original data file path and name
dest_file varchar2(200) Target data file path and name
status varchar2(100) Synchronization status, taking values sync, error
start_time date Synchronizing start times
end_time date End time of synchronization
all_time number Synchronization duration (one second)
synced_size number Synchronized data volume size (Unit M)
sync_rate number Synchronous rate (unit M/s)
In step S104, after the incremental synchronization is completed, the read/write operation on the original data file is switched to the target data file, and the data file modification inside the database is completed to point to the target data file.
The above incremental synchronization is performed at the frequency specified by the parameter until the alter database rename command is executed to switch the data file to the target data file. After the switching command is executed, I/O operation on the original data file is temporarily frozen, and incremental synchronization is performed from the original data file to the target data file once so as to achieve the purpose that the contents of the two data files are completely consistent, the I/O operation is recovered after the incremental synchronization is completed, and the I/O operation is performed on the target data file.
The datafile _ sync _ powerlimit is used to control the I/O rate of the data file copies as well as the frequency and I/O rate of the incremental synchronization. The parameter values are HIGH, NORMAL, LOW, and NORMAL is defaulted. HIGH indicates HIGH frequency and HIGH I/O rate, the priority of copied and synchronized I/O requests is HIGH, I/O consumption is HIGH, and there is some performance impact on normal I/O; NORMAL represents the general frequency and the general I/O rate, and gives consideration to the NORMAL I/O request, copy and synchronization; low indicates LOW frequency and LOW I/O rate, and has little effect on normal I/O.
In step S105, the flow ends.
The invention realizes the change of the storage space of the data file under the condition of not influencing the normal use of the database by the processing method of the online copy of the data file and the incremental synchronization of the original data file to the target data file. The I/O rate of data file copying and incremental synchronization is controlled by parameters, and the progress and condition of copying and incremental synchronization can be monitored by a view. Through the mode, the storage change of the data files is completed on line, the problem that a service system cannot be used due to the fact that the database is required to be closed or the table space is offline when the storage space of the data files is changed is avoided, the usability of the database is improved, a plurality of data files can be migrated simultaneously, the efficiency of changing the storage space of the data files is improved, and a new choice is provided for the migration of the database.
Example 2
Based on the method for modifying the storage location of the database file provided in embodiment 1 of the present invention, embodiment 2 of the present invention provides a system for modifying the storage location of the database file, for example, fig. 2 is a schematic diagram of a system for modifying the storage location of the database file provided in embodiment 2 of the present invention, and the system includes a copy module, a synchronization module, and a switch module;
the copying module is used for copying an original data file of a storage space to be replaced to a target storage space and recording a database time number when a copying command is executed;
the synchronization module is used for performing incremental synchronization on the data blocks which are larger than the database time number in the original data file to the target data file;
and the switching module is used for switching the read-write operation of the original data file to the target data file after the increment synchronization is completed, and finishing the modification of the data file in the database to point to the target data file.
Example 3
The invention also proposes a device comprising:
a memory for storing a computer program;
a processor for implementing the method steps when executing the computer program as follows:
in step S101, execution of the flow is started;
in step S102, copying an original data file of a storage space to be replaced to a target storage space, and recording a database time number when a copy command is executed;
for a data file requiring storage space replacement, a copy command of the data file is executed in the database, and the copy command records the SCN number of the database (assuming that the SCN number is AAA) when the command is executed. Wherein SCN: the system change number, time number in Oracle. At this time, the execution condition of the copy action starts to be recorded in the relevant view, and the copy state in the view is copying. The database copies the original data file to the target storage space.
Adding a command of the upper database copy datafile '/orabak/oradata/testdb/testdb/tbs101.dbf' to '/u01/app/oracle/oradata/testdb/tbs101. dbf'; instructing the database to copy the data file from/orabak/oradata/testdb/testdb/tbs 101.dbf to the new address/orabak/oradata/testdb/testdb/tbs 101. dbf.
In step S103, performing incremental synchronization on the data blocks in the original data file that are greater than the database time number to the target data file;
a dfcs (database file copy and sync) process is added for data file copying and data file incremental synchronization. After executing the alter database copy command, the dfcs process determines whether the file exists according to the original data file path and the file name, and if the file does not exist, the command line returns error information of 'file does not exist'. And meanwhile, judging whether the data file belongs to the database, and if not, returning error information that the data file does not belong to the database by the command line. If the data file can not be written into the required target directory due to the target directory authority or the incorrect target directory, the command line returns the error information of 'data file can not be created in the target directory'. After the copying is started, the SCN number of the database at the moment is recorded, and the statistical information of the data file copying is saved in the table t _ datafile _ copying and is updated once per second.
After the data file is copied, the action type of the copying action in the t _ datafile _ copying view is changed into done after the data file is copied, then, the incremental synchronization of the original data file change data block to the target data file is started, and the synchronization operation records the t _ datafile _ synchronizing view. And searching data blocks with SCN larger than AAA from the original data file, wherein the data blocks are data blocks which change during the copying of the data file, and correspondingly processing the changed data blocks in the target data file according to the data block types (if the changed data blocks are newly added, the changed data blocks are correspondingly added in the target data file, if the changed data blocks are deleted data blocks, the changed data blocks are deleted in the target data file, and if the changed data blocks are modified, the changed data blocks are substituted for the data blocks at the corresponding positions of the target data file). The operation is the incremental synchronous processing of the changed data blocks from the beginning of copying
After the incremental synchronization is started, the modification of the original data file is recorded by the database, and the modified data block is synchronized to the target data file according to the synchronization frequency specified by the parameters, so that the target data file and the original data file are synchronized in a consistent manner. After each synchronization, incremental synchronization is carried out according to the frequency specified by the synchronization frequency parameter.
To oversee the data file copy and synchronization status and progress, a view is provided for querying and monitoring the copy and incremental synchronization situation when data file copying or incremental synchronization is initiated.
As shown in the table below, the table name t _ datafile _ copying is used for recording the copying condition, and the progress, the consumed time and the approximate completion time of the copying can be known through the view.
Column name Type of field Description of the invention
ID number Sequentially increasing serial numbers, unique identification of each record in the table
source_file varchar2(200) Original data file path and name
dest_file varchar2(200) Target data file path and name
status varchar2(100) Copy state, taking copying and done values
start_time date Copy start time
end_time date End time of copying
all_time number Duration of copy (second unit)
copied_size number Copied file size (Unit M)
last_size number Residual File size (Unit M)
copy_rate number Copy rate (unit M/s)
The table name t _ datafile _ syncing, used to record the incremental synchronization case, is as follows.
Column name Type of field Description of the invention
ID number Serial number, unique identifier of each record in the table
source_file varchar2(200) Original data file path and name
dest_file varchar2(200) Target data file path and name
status varchar2(100) Synchronization status, taking values sync, error
start_time date Synchronizing start times
end_time date End time of synchronization
all_time number Synchronization duration (one second)
synced_size number Synchronized data volume size (Unit M)
sync_rate number Synchronous rate (unit M/s)
In step S104, after the incremental synchronization is completed, the read/write operation on the original data file is switched to the target data file, and the data file modification inside the database is completed to point to the target data file.
The above incremental synchronization is performed at the frequency specified by the parameter until the alter database rename command is executed to switch the data file to the target data file. After the switching command is executed, I/O operation on the original data file is temporarily frozen, and incremental synchronization is performed from the original data file to the target data file once so as to achieve the purpose that the contents of the two data files are completely consistent, the I/O operation is recovered after the incremental synchronization is completed, and the I/O operation is performed on the target data file.
The datafile _ sync _ powerlimit is used to control the I/O rate of the data file copies as well as the frequency and I/O rate of the incremental synchronization. The parameter values are HIGH, NORMAL, LOW, and NORMAL is defaulted. HIGH indicates HIGH frequency and HIGH I/O rate, the priority of copied and synchronized I/O requests is HIGH, I/O consumption is HIGH, and there is some performance impact on normal I/O; NORMAL represents the general frequency and the general I/O rate, and gives consideration to the NORMAL I/O request, copy and synchronization; low indicates LOW frequency and LOW I/O rate, and has little effect on normal I/O.
In step S105, the flow ends.
The invention realizes the change of the storage space of the data file under the condition of not influencing the normal use of the database by the processing method of the online copy of the data file and the incremental synchronization of the original data file to the target data file. The I/O rate of data file copying and incremental synchronization is controlled by parameters, and the progress and condition of copying and incremental synchronization can be monitored by a view. Through the mode, the storage change of the data files is completed on line, the problem that a service system cannot be used due to the fact that the database is required to be closed or the table space is offline when the storage space of the data files is changed is avoided, the usability of the database is improved, a plurality of data files can be migrated simultaneously, the efficiency of changing the storage space of the data files is improved, and a new choice is provided for the migration of the database.
Need to explain: the technical solution of the present invention also provides an electronic device, including: the communication interface can carry out information interaction with other equipment such as network equipment and the like; and the processor is connected with the communication interface to realize information interaction with other equipment, and is used for executing a method for modifying the storage position of the database file provided by one or more technical schemes when running a computer program, and the computer program is stored on the memory. Of course, in practice, the various components in an electronic device are coupled together by a bus system. It will be appreciated that a bus system is used to enable communications among the components. The bus system includes a power bus, a control bus, and a status signal bus in addition to a data bus. The memory in the embodiments of the present application is used to store various types of data to support the operation of the electronic device. Examples of such data include: any computer program for operating on an electronic device. It will be appreciated that the memory can be either volatile memory or nonvolatile memory, and can include both volatile and nonvolatile memory. Among them, the nonvolatile Memory may be a Read Only Memory (ROM), a Programmable Read Only Memory (PROM), an Erasable Programmable Read-Only Memory (EPROM), an Electrically Erasable Programmable Read-Only Memory (EEPROM), a magnetic random access Memory (FRAM), a Flash Memory (Flash Memory), a magnetic surface Memory, an optical disk, or a Compact Disc Read-Only Memory (CD-ROM); the magnetic surface storage may be disk storage or tape storage. Volatile memory can be Random Access Memory (RAM), which acts as external cache memory. By way of illustration and not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Synchronous Static Random Access Memory (SSRAM), Dynamic Random Access Memory (DRAM), Synchronous Dynamic Random Access Memory (SDRAM), Double Data Rate Synchronous Dynamic Random Access Memory (DDRSDRAM), Enhanced Synchronous Dynamic Random Access Memory (ESDRAM), Enhanced Synchronous Dynamic Random Access Memory (Enhanced DRAM), Synchronous Dynamic Random Access Memory (SLDRAM), Direct Memory (DRmb Access), and Random Access Memory (DRAM). The memories described in the embodiments of the present application are intended to comprise, without being limited to, these and any other suitable types of memory. The method disclosed in the embodiments of the present application may be applied to a processor, or may be implemented by a processor. The processor may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware in a processor or instructions in the form of software. The processor may be a general purpose processor, a DSP (Digital Signal Processing, i.e., a chip capable of implementing Digital Signal Processing technology), or other programmable logic device, discrete gate or transistor logic device, discrete hardware components, etc. The processor may implement or perform the methods, steps, and logic blocks disclosed in the embodiments of the present application. A general purpose processor may be a microprocessor or any conventional processor or the like. The steps of the method disclosed in the embodiments of the present application may be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor. The software modules may be located in a storage medium located in a memory where a processor reads the programs in the memory and in combination with its hardware performs the steps of the method as previously described. When the processor executes the program, corresponding processes in the methods of the embodiments of the present application are implemented, and for brevity, are not described herein again.
Example 4
The invention also proposes a readable storage medium on which a computer program is stored, which, when executed by a processor, implements the method steps of:
in step S101, execution of the flow is started;
in step S102, copying an original data file of a storage space to be replaced to a target storage space, and recording a database time number when a copy command is executed;
for a data file requiring storage space replacement, a copy command of the data file is executed in the database, and the copy command records the SCN number of the database (assuming that the SCN number is AAA) when the command is executed. Wherein SCN: the system change number, time number in Oracle. At this time, the execution condition of the copy action starts to be recorded in the relevant view, and the copy state in the view is copying. The database copies the original data file to the target storage space.
Adding a command of the upper database copy datafile '/orabak/oradata/testdb/testdb/tbs101.dbf' to '/u01/app/oracle/oradata/testdb/tbs101. dbf'; instructing the database to copy the data file from/orabak/oradata/testdb/testdb/tbs 101.dbf to the new address/orabak/oradata/testdb/testdb/tbs 101. dbf.
In step S103, performing incremental synchronization on the data blocks in the original data file that are greater than the database time number to the target data file;
a dfcs (database file copy and sync) process is added for data file copying and data file incremental synchronization. After executing the alter database copy command, the dfcs process determines whether the file exists according to the original data file path and the file name, and if the file does not exist, the command line returns error information of 'file does not exist'. And meanwhile, judging whether the data file belongs to the database, and if not, returning error information that the data file does not belong to the database by the command line. If the data file can not be written into the required target directory due to the target directory authority or the incorrect target directory, the command line returns the error information of 'data file can not be created in the target directory'. After the copying is started, the SCN number of the database at the moment is recorded, and the statistical information of the data file copying is saved in the table t _ datafile _ copying and is updated once per second.
After the data file is copied, the action type of the copying action in the t _ datafile _ copying view is changed into done after the data file is copied, then, the incremental synchronization of the original data file change data block to the target data file is started, and the synchronization operation records the t _ datafile _ synchronizing view. And searching data blocks with SCN larger than AAA from the original data file, wherein the data blocks are data blocks which change during the copying of the data file, and correspondingly processing the changed data blocks in the target data file according to the data block types (if the changed data blocks are newly added, the changed data blocks are correspondingly added in the target data file, if the changed data blocks are deleted data blocks, the changed data blocks are deleted in the target data file, and if the changed data blocks are modified, the changed data blocks are substituted for the data blocks at the corresponding positions of the target data file). The operation is the incremental synchronous processing of the changed data blocks from the beginning of copying
After the incremental synchronization is started, the modification of the original data file is recorded by the database, and the modified data block is synchronized to the target data file according to the synchronization frequency specified by the parameters, so that the target data file and the original data file are synchronized in a consistent manner. After each synchronization, incremental synchronization is carried out according to the frequency specified by the synchronization frequency parameter.
To oversee the data file copy and synchronization status and progress, a view is provided for querying and monitoring the copy and incremental synchronization situation when data file copying or incremental synchronization is initiated.
As shown in the table below, the table name t _ datafile _ copying is used for recording the copying condition, and the progress, the consumed time and the approximate completion time of the copying can be known through the view.
Column name Type of field Description of the invention
ID number Sequentially increasing serial numbers, unique identification of each record in the table
source_file varchar2(200) Original data file path and name
dest_file varchar2(200) Target data file path and name
status varchar2(100) Copy state, taking copying and done values
start_time date Copy start time
end_time date End time of copying
all_time number Duration of copy (second unit)
copied_size number Copied file size (Unit M)
last_size number Residual File size (Unit M)
copy_rate number Copy rate (unit M/s)
The table name t _ datafile _ syncing, used to record the incremental synchronization case, is as follows.
Column name Type of field Description of the invention
ID number Serial number, unique identifier of each record in the table
source_file varchar2(200) Original data file path and name
dest_file varchar2(200) Target data file path and name
status varchar2(100) Synchronization status, taking values sync, error
start_time date Synchronizing start times
end_time date End time of synchronization
all_time number Synchronization duration (one second)
synced_size number Synchronized data volume size (Unit M)
sync_rate number Synchronous rate (unit M/s)
In step S104, after the incremental synchronization is completed, the read/write operation on the original data file is switched to the target data file, and the data file modification inside the database is completed to point to the target data file.
The above incremental synchronization is performed at the frequency specified by the parameter until the alter database rename command is executed to switch the data file to the target data file. After the switching command is executed, I/O operation on the original data file is temporarily frozen, and incremental synchronization is performed from the original data file to the target data file once so as to achieve the purpose that the contents of the two data files are completely consistent, the I/O operation is recovered after the incremental synchronization is completed, and the I/O operation is performed on the target data file.
The datafile _ sync _ powerlimit is used to control the I/O rate of the data file copies as well as the frequency and I/O rate of the incremental synchronization. The parameter values are HIGH, NORMAL, LOW, and NORMAL is defaulted. HIGH indicates HIGH frequency and HIGH I/O rate, the priority of copied and synchronized I/O requests is HIGH, I/O consumption is HIGH, and there is some performance impact on normal I/O; NORMAL represents the general frequency and the general I/O rate, and gives consideration to the NORMAL I/O request, copy and synchronization; low indicates LOW frequency and LOW I/O rate, and has little effect on normal I/O.
In step S105, the flow ends.
The invention realizes the change of the storage space of the data file under the condition of not influencing the normal use of the database by the processing method of the online copy of the data file and the incremental synchronization of the original data file to the target data file. The I/O rate of data file copying and incremental synchronization is controlled by parameters, and the progress and condition of copying and incremental synchronization can be monitored by a view. Through the mode, the storage change of the data files is completed on line, the problem that a service system cannot be used due to the fact that the database is required to be closed or the table space is offline when the storage space of the data files is changed is avoided, the usability of the database is improved, a plurality of data files can be migrated simultaneously, the efficiency of changing the storage space of the data files is improved, and a new choice is provided for the migration of the database.
Embodiments of the present application further provide a storage medium, that is, a computer storage medium, specifically, a computer-readable storage medium, for example, a memory storing a computer program, where the computer program is executable by a processor to perform the steps of the foregoing method. The computer readable storage medium may be Memory such as FRAM, ROM, PROM, EPROM, EEPROM, Flash Memory, magnetic surface Memory, optical disk, or CD-ROM.
Those of ordinary skill in the art will understand that: all or part of the steps for implementing the method embodiments may be implemented by hardware related to program instructions, and the program may be stored in a computer readable storage medium, and when executed, the program performs the steps including the method embodiments; and the aforementioned storage medium includes: a removable storage device, a ROM, a RAM, a magnetic or optical disk, or various other media that can store program code. Alternatively, the integrated units described above in the present application may be stored in a computer-readable storage medium if they are implemented in the form of software functional modules and sold or used as independent products. Based on such understanding, the technical solutions of the embodiments of the present application may be essentially implemented or portions thereof that contribute to the prior art may be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling an electronic device (which may be a personal computer, a server, or a network device) to execute all or part of the methods described in the embodiments of the present application. And the aforementioned storage medium includes: a removable storage device, a ROM, a RAM, a magnetic or optical disk, or various other media that can store program code.
For a description of a relevant part in the device and the storage medium for modifying the storage location of the database file provided in the embodiment of the present application, reference may be made to a detailed description of a corresponding part in the method for modifying the storage location of the database file provided in embodiment 1 of the present application, and details are not repeated here.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Furthermore, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include elements inherent in the list. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element. In addition, parts of the above technical solutions provided in the embodiments of the present application, which are consistent with the implementation principles of corresponding technical solutions in the prior art, are not described in detail so as to avoid redundant description.
Although the embodiments of the present invention have been described with reference to the accompanying drawings, the scope of the present invention is not limited thereto. Various modifications and alterations will occur to those skilled in the art based on the foregoing description. And are neither required nor exhaustive of all embodiments. On the basis of the technical scheme of the invention, various modifications or changes which can be made by a person skilled in the art without creative efforts are still within the protection scope of the invention.

Claims (10)

1. A method for modifying a storage location of a database file, comprising the steps of:
copying an original data file of a storage space to be replaced to a target storage space, and recording a database time number when a copy command is executed;
performing incremental synchronization on the data blocks which are larger than the database time number in the original data file to the target data file;
after the increment synchronization is completed, the read-write operation of the original data file is switched to the target data file, and the data file modification inside the database is completed to point to the target data file.
2. The method as claimed in claim 1, wherein copying the original data file of the storage space to be replaced to the target storage space, and recording the database time number when the copy command is executed further comprises: recording the execution condition of the copy action in the view, and recording the state of the copy action in the view as copying when copying; and after the original data file is copied, recording the state of the copying action in the view as that the copying is finished.
3. The method of claim 1, wherein the performing incremental synchronization on the data blocks in the original data file that are larger than the database time number to the target data file further comprises:
after the increment synchronization is started, the database records the modification process of the original data file, and synchronizes the data blocks in the original data file, which are larger than the time number of the database, to the target data file according to the synchronization frequency specified by the parameters, so as to achieve the consistent synchronization of the target data file and the original data file.
4. A method for modifying storage locations of database files as recited in claim 3, further comprising: and after the incremental synchronization is finished, performing incremental synchronization according to the frequency specified by the synchronization frequency parameter.
5. The method of claim 4, wherein the incremental synchronization comprises:
if the data blocks are newly added, correspondingly adding the data blocks in the target data file;
if the data block is deleted, deleting the data block in the target data file;
and if the data block is the modified data block, replacing the data block at the corresponding position of the target data file.
6. The method according to claim 1, wherein after the incremental synchronization is completed, the read/write operation on the original data file is switched to the target data file, and the completion of the data file modification inside the database to point to the target data file specifically includes:
after the read-write operation of the original data file is switched to the target data file, the first I/O operation of the original data file is frozen, the increment synchronization is carried out from the original data file to the target data file once so as to achieve the complete consistency of the contents of the two data files, and the second I/O operation of the target data file is recovered after the increment synchronization is completed.
7. The method of any one of claims 1 to 6, wherein the method further comprises: datafile _ sync _ powerlimit is used to control the rate of data file copying, the frequency of incremental synchronization and the rate of incremental synchronization.
8. A system for modifying storage locations of database files, the system comprising a copy module, a synchronization module, and a switch module;
the copying module is used for copying an original data file of a storage space to be replaced to a target storage space and recording a database time number when a copying command is executed;
the synchronization module is used for performing incremental synchronization on the data blocks which are larger than the database time number in the original data file to the target data file;
and the switching module is used for switching the read-write operation of the original data file to the target data file after the increment synchronization is completed, and finishing the modification of the data file in the database to point to the target data file.
9. An apparatus, comprising:
a memory for storing a computer program;
a processor for implementing the method steps of any one of claims 1 to 7 when executing the computer program.
10. A readable storage medium, characterized in that the readable storage medium has stored thereon a computer program which, when being executed by a processor, carries out the method steps of any one of claims 1 to 7.
CN202110984868.XA 2021-08-25 2021-08-25 Method, system, equipment and medium for modifying storage position of database file Pending CN113868188A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110984868.XA CN113868188A (en) 2021-08-25 2021-08-25 Method, system, equipment and medium for modifying storage position of database file

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110984868.XA CN113868188A (en) 2021-08-25 2021-08-25 Method, system, equipment and medium for modifying storage position of database file

Publications (1)

Publication Number Publication Date
CN113868188A true CN113868188A (en) 2021-12-31

Family

ID=78988389

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110984868.XA Pending CN113868188A (en) 2021-08-25 2021-08-25 Method, system, equipment and medium for modifying storage position of database file

Country Status (1)

Country Link
CN (1) CN113868188A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114443654A (en) * 2022-01-14 2022-05-06 苏州浪潮智能科技有限公司 Method and system for modifying length of spatial data block of database table on line
CN117008924A (en) * 2023-10-07 2023-11-07 海马云(天津)信息技术有限公司 Compiling processing method and device and communication equipment

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105359147A (en) * 2013-07-09 2016-02-24 甲骨文国际公司 Online database migration
US20180137113A1 (en) * 2016-11-16 2018-05-17 Sap Se Minimizing downtime in migrating content of databases systems
CN109299072A (en) * 2018-10-16 2019-02-01 郑州云海信息技术有限公司 A kind of method and device that database migrates online
CN111190883A (en) * 2019-12-03 2020-05-22 腾讯科技(深圳)有限公司 Data migration method and device, computer readable storage medium and computer equipment
CN111291023A (en) * 2020-02-09 2020-06-16 苏州浪潮智能科技有限公司 Data migration method, system, device and medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105359147A (en) * 2013-07-09 2016-02-24 甲骨文国际公司 Online database migration
US20180137113A1 (en) * 2016-11-16 2018-05-17 Sap Se Minimizing downtime in migrating content of databases systems
CN109299072A (en) * 2018-10-16 2019-02-01 郑州云海信息技术有限公司 A kind of method and device that database migrates online
CN111190883A (en) * 2019-12-03 2020-05-22 腾讯科技(深圳)有限公司 Data migration method and device, computer readable storage medium and computer equipment
CN111291023A (en) * 2020-02-09 2020-06-16 苏州浪潮智能科技有限公司 Data migration method, system, device and medium

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114443654A (en) * 2022-01-14 2022-05-06 苏州浪潮智能科技有限公司 Method and system for modifying length of spatial data block of database table on line
CN114443654B (en) * 2022-01-14 2024-01-26 苏州浪潮智能科技有限公司 Method and system for on-line modifying length of database table space data block
CN117008924A (en) * 2023-10-07 2023-11-07 海马云(天津)信息技术有限公司 Compiling processing method and device and communication equipment

Similar Documents

Publication Publication Date Title
CN101903866B (en) Method and system for storage of data in non-volatile media
KR100644602B1 (en) Method for driving remapping for flash memory and flash memory architecture thereto
JP3808007B2 (en) Caching method and system for storage device
CN113868188A (en) Method, system, equipment and medium for modifying storage position of database file
US20040221103A1 (en) Storage system and method of configuring the storage system
JP4825433B2 (en) Computing device with relatively limited storage space and operating system / file system thereof
WO1999056212A1 (en) Method and apparatus for reclaiming and defragmenting a flash memory device
US20110055297A1 (en) Access module, information recording module, controller, and information recording system
JP2008015769A (en) Storage system and writing distribution method
JPH04233639A (en) File controlling method and system
CN104050056A (en) File system backup of multi-storage-medium device
CN112035294B (en) Security log file system and implementation method and medium thereof
CN104881418A (en) Method and device for quickly reclaiming rollback space in MySQL
CN102096561A (en) Hierarchical data storage processing method, device and storage equipment
CN111722807A (en) Solid state disk garbage recycling method and device, computer equipment and storage medium
CN113608701A (en) Data management method in storage system and solid state disk
CN102508782B (en) Data read-write method, data read-write device, memory bank and network equipment
US20090030954A1 (en) Management of multiple virtual data copies
US20070162707A1 (en) Information recording medium data processing apparatus and data recording method
CN116578246B (en) Storage device and control method thereof
JP2008090378A (en) Hybrid file system, operating system, cache control method, and recording medium
CN115469815B (en) Cache management method, device, equipment and storage medium for improving reliability of flash memory
CN110658981A (en) Method for prolonging service life of Flash
CN101794254B (en) NAND-FLASH data processing method
CN111414271B (en) Storage method based on self-adaptive storage redundancy strategy

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination