In the process of database operation and maintenance, hardware upgrading, host replacement or test environment based on the current production library are often carried out. At this time, it is necessary to form a target library that is the same as the original library. At this time, physical migration is a more convenient method. Its main purpose is to copy the source library related files directly to the target host, modify the configuration file to match the target library, and then register the service in the target host to start the migrated instance. The physical migration operation is relatively simple. The versions of the two libraries are required to be consistent to reduce the migration risk and operation difficulty.
The two host environments are 64 bit centos 7.2, as follows:
[root@dwm Desktop]# uname -a Linux dwm 3.10.0-1160.15.2.el7.x86_64 #1 SMP Wed Feb 3 15:06:38 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux [root@dwm Desktop]# cat /etc/redhat-release CentOS Linux release 7.2.1511 (Core)
The database version to be migrated is 64 bit DM8. The information is as follows:
In order to confirm the details of the file to be copied, query through the dynamic view,
SQL> select tablespace_name, file_name, bytes/1024/1024 as "size(M)" from dba_data_files; LINEID TABLESPACE_NAME FILE_NAME size(M) ---------- --------------- ----------------------------- -------------------- 1 SYSTEM /dm8/data/DAMENG/SYSTEM.DBF 23 2 DMHR /dm8/data/DAMENG/DMHR.DBF 128 3 BOOKSHOP /dm8/data/DAMENG/BOOKSHOP.DBF 150 4 MAIN /dm8/data/DAMENG/MAIN.DBF 128 5 TEMP /dm8/data/DAMENG/TEMP.DBF 10 6 ROLL /dm8/data/DAMENG/ROLL.DBF 128 6 rows got used time: 2.845(ms). Execute id is 7.
Query the path parameters of the configuration file. The target library can modify the path according to the actual storage situation or not according to the location of the original library, as long as the configuration file is consistent with the actual storage location.
SQL> select para_name, para_value from v$dm_ini where para_name like '%PATH%'; LINEID PARA_NAME PARA_VALUE ---------- ----------------- ------------------------ 1 CTL_PATH /dm8/data/DAMENG/dm.ctl 2 CTL_BAK_PATH /dm8/data/DAMENG/ctl_bak 3 SYSTEM_PATH /dm8/data/DAMENG 4 CONFIG_PATH /dm8/data/DAMENG 5 TEMP_PATH /dm8/data/DAMENG 6 BAK_PATH /dm8/data/DAMENG/bak 7 AUD_PATH NULL 8 DFS_PATH $/DAMENG 9 SVR_LOG_FILE_PATH ../log 10 TRACE_PATH /dm8/data/DAMENG/trace 11 DCR_PATH NULL 11 rows got used time: 3.067(ms). Execute id is 10.
To ensure data consistency, close the instance during migration.
The database of the same version of the target database has been installed and has an instance with the service port of 5236. In order to distinguish, we modify the original database instance and the database instance on the corresponding port of 5237 of the target database.
Copy relevant files to the target host. The original directory is / dm8/data/DAMENG, and the target file directory is / dm8/data/DAMENG2:
[dmdba@localhost DAMENG]$ scp *.* dmdba@192.168.56.105:/dm8/data/DAMENG2 The authenticity of host '192.168.56.105 (192.168.56.105)' can't be established. ECDSA key fingerprint is dc:d6:a1:b2:c2:7d:e0:60:c9:ec:3e:19:18:85:2a:e8. Are you sure you want to continue connecting (yes/no)? YES Warning: Permanently added '192.168.56.105' (ECDSA) to the list of known hosts. dmdba@192.168.56.105's password: BOOKSHOP.DBF 100% 150MB 75.0MB/s 00:02 DAMENG01.log 100% 256MB 64.0MB/s 00:04 DAMENG02.log 100% 256MB 64.0MB/s 00:04 dm.ctl 100% 6144 6.0KB/s 00:00 DMHR.DBF 100% 128MB 64.0MB/s 00:02 dm.ini 100% 48KB 48.1KB/s 00:00 dminit20210306001532.log 100% 808 0.8KB/s 00:00 dm_service.prikey 100% 633 0.6KB/s 00:00 MAIN.DBF 100% 128MB 64.0MB/s 00:02 rep_conflict.log 100% 12 0.0KB/s 00:00 ROLL.DBF 100% 128MB 64.0MB/s 00:02 sqllog.ini 100% 479 0.5KB/s 00:00 SYSTEM.DBF 100% 23MB 23.0MB/s 00:00 TEMP.DBF 100% 10MB 10.0MB/s 00:00
Confirm on the target host:
[dmdba@dwm DAMENG2]$ pwd /dm8/data/DAMENG2 [dmdba@dwm DAMENG2]$ ls BOOKSHOP.DBF dm.ctl dminit20210306001532.log rep_conflict.log SYSTEM.DBF DAMENG01.log DMHR.DBF dm_service.prikey ROLL.DBF TEMP.DBF DAMENG02.log dm.ini MAIN.DBF sqllog.ini
To modify a profile:
After the batch modification command is executed, a total of 6 modifications are prompted.
Since the path is modified, the control file must be modified to ensure that the information in it is consistent with the actual situation, otherwise an error will be reported when starting. Dameng database uses dmctlcvt tool to modify the control file.
[dmdba@dwm bin]$ ./dmctlcvt help DMCTLCVT V8 Format: ./dmctlcvt KEYWORD=value Note: ctl file name must be dm.ctl or dmmpp.ctl or dss.ctl Keyword Explanation -------------------------------------------------------------------------------- TYPE 1 convert ctl file(dm.ctl or dmmpp.ctl or dss.ctl) to txt file 2 convert txt file to ctl file(dm.ctl or dmmpp.ctl or dss.ctl) SRC Source file DEST Destination file DCR_INI the path of dmdcr.ini DFS_INI the path of dmdfs.ini HELP Show this help info Example: ./dmctlcvt TYPE=1 SRC=/opt/dmdbms/data/dameng/dm.ctl DEST=/opt/dmdbms/data/dameng/dmctl.txt ./dmctlcvt TYPE=2 SRC=/opt/dmdbms/data/dameng/dmctl.txt DEST=/opt/dmdbms/data/dameng/dm.ctl
Referring to the instructions and example commands provided with the tool, modify the instance control file in the target host, and first generate a text file.
Modify the text file:
After checking and modifying successfully, convert the text file into binary file:
Register the instance with the system service
Start instance
[root@dwm system]# systemctl start DmServiceDM2 Job for DmServiceDM2.service failed because the control process exited with error code. See "systemctl status DmServiceDM2.service" and "journalctl -xe" for details.
Failed to start successfully, please check the details,
[root@dwm system]# systemctl status DmServiceDM2 ● DmServiceDM2.service - Dameng Database Service(DmServiceDM2). Loaded: loaded (/usr/lib/systemd/system/DmServiceDM2.service; enabled; vendor preset: disabled) Active: failed (Result: exit-code) since Thu 2021-05-13 12:41:05 CST; 29s ago Process: 5204 ExecStart=/dm8/bin/DmServiceDM2 start (code=exited, status=1/FAILURE) May 13 12:40:50 dwm systemd[1]: Starting Dameng Database Service(DmServiceD..... May 13 12:41:05 dwm DmServiceDM2[5204]: [38B blob data] May 13 12:41:05 dwm DmServiceDM2[5204]: file dm.key not found, use default l...! May 13 12:41:05 dwm DmServiceDM2[5204]: Read ini error, name:CTL_PATH, value...l May 13 12:41:05 dwm DmServiceDM2[5204]: dmserver startup failed, code = -803...] May 13 12:41:05 dwm DmServiceDM2[5204]: nsvr_ini_file_read failed, [code: -803] May 13 12:41:05 dwm systemd[1]: DmServiceDM2.service: control process exite...=1 May 13 12:41:05 dwm systemd[1]: Failed to start Dameng Database Service(DmS..... May 13 12:41:05 dwm systemd[1]: Unit DmServiceDM2.service entered failed state. May 13 12:41:05 dwm systemd[1]: DmServiceDM2.service failed. Hint: Some lines were ellipsized, use -l to show in full.
Find more accurate information in the log file:
[dmdba@dwm log]$ cat DmServiceDM2.log file dm.key not found, use default license! Read ini error, name:CTL_PATH, value:dm8/data/DAMENG2/dm.ctl dmserver startup failed, code = -803 [Invalid ini config value] nsvr_ini_file_read failed, [code: -803]
After troubleshooting, one / is missing in the process of Path replacement, resulting in path exceptions.
After modifying again, restart the instance.
The startup is normal this time. Connect the instance and check the database status.
After migration, our instance is connected to port 5237.
[dmdba@dwm bin]$ rlwrap ./disql sysdba/dameng123:5237 Server[LOCALHOST:5237]:mode is normal, state is open login used time: 6.018(ms) disql V8 SQL> select * from v$database; LINEID NAME ---------- ------ CREATE_TIME ---------------------------------------------------------------------------------------------------- ARCH_MODE --------- LAST_CKPT_TIME ---------------------------------------------------------------------------------------------------- STATUS$ ROLE$ MAX_SIZE TOTAL_SIZE DSC_NODES ----------- ----------- -------------------- -------------------- ----------- OPEN_COUNT STARTUP_COUNT ----------- -------------------- LAST_STARTUP_TIME ---------------------------------------------------------------------------------------------------- 1 DAMENG 2021-03-06 00:15:34 N NULL 4 0 0 56192 1 12 1 2021-05-13 12:51:26 used time: 3.147(ms). Execute id is 4. SQL> select * from v$instance; LINEID NAME INSTANCE_NAME INSTANCE_NUMBER HOST_NAME SVR_VERSION ---------- -------- ------------- --------------- --------- -------------------------- DB_VERSION ------------------- START_TIME ---------------------------------------------------------------------------------------------------- STATUS$ MODE$ OGUID DSC_SEQNO DSC_ROLE ------- ------ ----------- ----------- -------- 1 DMSERVER DMSERVER 1 dwm DM Database Server x64 V8 DB Version: 0x7000a 2021-05-13 12:51:24 OPEN NORMAL 0 0 NULL used time: 1.461(ms). Execute id is 5. SQL>
Through the above operation steps, the physical migration of the database is completed, the instance runs normally and the status is available. During the migration process, you should pay attention to ensuring the path and DM of the target library Ini and DM The in CTL is exactly the same. In addition, the attributes of the file remain unchanged after copying, that is, the primary group and read-write permission are correct.