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

Erroneous deletion and recovery of DM7 data files in Dameng database

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

In DM7, there are two features related to data file recovery.

Data file failure check

The value of the parameter FIL_CHECK_INTERVAL in DM.ini specifies the time interval for which the dm7 system checks the data file, and a setting of 0 means no check.

Manual checking can also be done through the system process SP_FILE_SYS_CHECK ().

Data file failure recovery

For deleted files in the Linux system, the file handle has not been closed without restarting, and the corresponding copy of the file can be found in / proc/ / fd.

Using this method, combined with the os command, you can call the system procedure SP_TABLESPACE_PREPARE_RECOVER in DM7.

And SP_TABLESPACE_RECOVER to recover the mistakenly deleted data files.

1. Prepare the test environment

SQL > create tablespace cc datafile'/dmdata/data/DM01/cc01.dbf' size 100data size size 100

The operation has been performed

SQL > select tablespace_name, file_name, status from dba_data_files order by 1

Line number TABLESPACE_NAME FILE_NAME STATUS

-

1 BOOKSHOP / dmdata/data/DM01/BOOKSHOP.DBF AVAILABLE

2 CC / dmdata/data/DM01/cc02.dbf AVAILABLE

3 CC / dmdata/data/DM01/cc01.dbf AVAILABLE

4 DMHR / dmdata/data/DM01/DMHR.DBF AVAILABLE

5 MAIN / dmdata/data/DM01/MAIN.DBF AVAILABLE

6 ROLL / dmdata/data/DM01/ROLL.DBF AVAILABLE

7 SYSTEM / dmdata/data/DM01/SYSTEM.DBF AVAILABLE

8 TEMP / dmdata/data/DM01/TEMP.DBF AVAILABLE

8 rows got

SQL > create tablespace cc datafile'/dmdata/data/DM01/cc01.dbf' size 100data size size 100

The operation has been performed

Elapsed time: 24.231 milliseconds. Execution number: 6.

SQL > create user test identified by dameng123 default tablespace cc

The operation has been performed

Elapsed time: 10.973 milliseconds. Execution number: 7.

SQL > grant dba,resource to test

The operation has been performed

Elapsed time: 7.763 milliseconds. Execution number: 8.

SQL > conn test/dameng123

SQL > create table T1 as select * from dba_data_files

The operation has been performed

Elapsed time: 19.126 milliseconds. Execution number: 9.

SQL > select count (*) from T1

Line number COUNT (*)

--

1 8

2. Simulated deletion of files

[dmdba@localhost ~] $rm-rf / dmdata/data/DM01/cc01.dbf

SQL > select count (*) from T1

Line number COUNT (*)

--

1 8

Elapsed time: 0.553 milliseconds. Execution number: 12.

Perform failure check system process

SQL > call SP_FILE_SYS_CHECK ()

The DMSQL process has completed successfully

Elapsed time: 1.458 milliseconds. Execution number: 13.

SQL > select count (*) from T1

Select count (*) from T1

[- 3430]: the file [/ dmdata/data/DM01/cc01.dbf] in the table space [CC] has been deleted.

Elapsed time: 0.230 milliseconds. Execution number: 0

3. Restore data files

Perform the preparation recovery process

SQL > call sp_tablespace_prepare_recover ('CC')

The DMSQL process has completed successfully

Elapsed time: 0.351 milliseconds. Execution number: 15.

View DM7 process ID

[dmdba@localhost ~] $ps-ef | grep dmserver

Dmdba 2304 1 0 08:25? 00:00:02 / dm7/bin/dmserver / dmdata/data/DM01/dm.ini-noconsole

Dmdba 2885 2817 0 08:35 pts/0 00:00:00 grep dmserver

To view the deleted file, the following shows that the corresponding file number is 14

[dmdba@localhost ~] $ls / proc/2304/fd-l

Total dosage 0

Lr-x- 1 dmdba dinstall 64 November 16 08:36 0-> / dev/null

Lmurwx-1 dmdba dinstall 64 November 16 08:36 1-> / dm7/log/S98DmServiceTEST01.log

Lrwx- 1 dmdba dinstall 64 November 16 08:36 10-> / dmdata/data/DM01/BOOKSHOP.DBF

Lrwx- 1 dmdba dinstall 64 November 16 08:36 11-> / dmdata/data/DM01/DMHR.DBF

Lrwx- 1 dmdba dinstall 64 November 16 08:36 12-> / dmdata/data/DM01/ROLL.DBF

Lrwx- 1 dmdba dinstall 64 November 16 08:36 13-> / dmdata/data/DM01/MAIN.DBF

Lrwx- 1 dmdba dinstall 64 November 16 08:36 14-> / dmdata/data/DM01/cc01.dbf (deleted)

Lrwx- 1 dmdba dinstall 64 November 1608: 36 15-> / dmdata/arch/ARCHIVE_LOCAL1_20191116082533913_0.log

. The following are omitted

Copy the file to the original location

[dmdba@localhost ~] $cp / proc/2304/fd/14 / dmdata/data/DM01/cc01.dbf

Perform the recovery process

SQL > call sp_tablespace_recover ('CC')

The DMSQL process has completed successfully

Elapsed time: 9.973 milliseconds. Execution number: 16.

Execute the failure check system process again to verify the recovery and no error is reported.

SQL > call SP_FILE_SYS_CHECK ()

The DMSQL process has completed successfully

Elapsed time: 0.182 milliseconds. Execution number: 19.

SQL > select count (*) from T1

Line number COUNT (*)

--

1 8

Elapsed time: 0.150 milliseconds. Execution number: 17.

SQL > select tablespace_name, file_name, status from dba_data_files order by 1

Line number TABLESPACE_NAME FILE_NAME STATUS

-

1 BOOKSHOP / dmdata/data/DM01/BOOKSHOP.DBF AVAILABLE

2 CC / dmdata/data/DM01/cc02.dbf AVAILABLE

3 CC / dmdata/data/DM01/cc01.dbf AVAILABLE

4 DMHR / dmdata/data/DM01/DMHR.DBF AVAILABLE

5 MAIN / dmdata/data/DM01/MAIN.DBF AVAILABLE

6 ROLL / dmdata/data/DM01/ROLL.DBF AVAILABLE

7 SYSTEM / dmdata/data/DM01/SYSTEM.DBF AVAILABLE

8 TEMP / dmdata/data/DM01/TEMP.DBF AVAILABLE

8 rows got

Elapsed time: 47.629 milliseconds. Execution number: 18.

Erroneous deletion of data file recovery completed.

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