如何移動DB2的資料庫建庫目錄
阿新 • • 發佈:2019-02-05
由於目錄變化,需要將資料庫從目錄/home/db2inst1移動到目錄/public/home/guanghong.yu/db2inst1
重新編目資料庫
$db2 uncatalog db oracle
$db2 catalog db oracle
編目成功後會即可看到:
$db2 list db directory
Database alias = ORACLE
Database name = ORACLE
Local database directory = /public/home/guanghong.yu/db2inst1
Database release level = d.00
Comment =
Directory entry type = Indirect
Catalog database partition number = 0
Alternate server hostname =
Alternate server port number =
如上操作做了後仍然不能連線資料庫,需要對錶空間做如下操作:
編輯mvdb.cfg
DB_NAME=ORACLE
DB_PATH=/home/db2inst1,/public/home/guanghong.yu/db2inst1
INSTANCE=db2inst1
NODENUM=0
CONT_PATH=/home/db2inst1/db2inst1/NODE0000/ORACLE/T0000000/C0000000.CAT,/public/home/guanghong.yu/db2inst1/db2inst1/NODE0000/ORACLE/T0000000/C0000000.CAT
STORAGE_PATH=/home/db2inst1/,/public/home/guanghong.yu/db2inst1
執行如下命令:
$db2relocatedb -f mvdb.cfg
[ [email protected] db2]$ db2relocatedb -f mvdb.cfg
Files and control structures were changed successfully.
Database was catalogued successfully.
DBT1000I The tool completed successfully.
執行成功,資料庫可以成功連線啟用啦
[[email protected] db2]$ db2 connect to oracle
Database Connection Information
Database server = DB2/LINUXX8664 9.7.5
SQL authorization ID = DB2INST1
Local database alias = ORACLE
OK,移動後的資料庫可以被使用啦。
重新編目資料庫
$db2 uncatalog db oracle
$db2 catalog db oracle
編目成功後會即可看到:
$db2 list db directory
Database alias = ORACLE
Database name = ORACLE
Local database directory = /public/home/guanghong.yu/db2inst1
Database release level = d.00
Comment =
Directory entry type = Indirect
Catalog database partition number = 0
Alternate server hostname =
Alternate server port number =
如上操作做了後仍然不能連線資料庫,需要對錶空間做如下操作:
編輯mvdb.cfg
DB_NAME=ORACLE
DB_PATH=/home/db2inst1,/public/home/guanghong.yu/db2inst1
INSTANCE=db2inst1
NODENUM=0
CONT_PATH=/home/db2inst1/db2inst1/NODE0000/ORACLE/T0000000/C0000000.CAT,/public/home/guanghong.yu/db2inst1/db2inst1/NODE0000/ORACLE/T0000000/C0000000.CAT
STORAGE_PATH=/home/db2inst1/,/public/home/guanghong.yu/db2inst1
執行如下命令:
$db2relocatedb -f mvdb.cfg
[
Files and control structures were changed successfully.
Database was catalogued successfully.
DBT1000I The tool completed successfully.
執行成功,資料庫可以成功連線啟用啦
[[email protected] db2]$ db2 connect to oracle
Database Connection Information
Database server = DB2/LINUXX8664 9.7.5
SQL authorization ID = DB2INST1
Local database alias = ORACLE
OK,移動後的資料庫可以被使用啦。