微商城网站策划,seo排名工具提升流量,个人网站建设 优帮云,来宾住房和建设局网站源库为ORCL中的orclpdb1#xff0c;目标库为ORCL2。版本均为19c。
我们将利用19c中dbca新支持的-createFromRemotePDB选项来从远端克隆PDB。
确认源库中有业务数据#xff1a;
SQL connect hrorclpdb1
Enter password:
Connected.
SQL select count(*) from hr.em…源库为ORCL中的orclpdb1目标库为ORCL2。版本均为19c。
我们将利用19c中dbca新支持的-createFromRemotePDB选项来从远端克隆PDB。
确认源库中有业务数据
SQL connect hrorclpdb1
Enter password:
Connected.
SQL select count(*) from hr.employees;COUNT(*)
----------107在源库中创建common user。后续dbca会用这个用户来连接源库。
SQL connect system
Enter password:
Connected.
SQL show con_nameCON_NAME
------------------------------
CDB$ROOT
SQL CREATE USER c##remote_user IDENTIFIED BY Welcome1 CONTAINERALL;User created.SQL GRANT create session, create pluggable database TO c##remote_user CONTAINERALL;Grant succeeded.SQL exit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.20.0.0.0在目标库所在数据库服务器上静默方式执行dbca命令克隆远端pdb
dbca -silent -createPluggableDatabase -createFromRemotePDB \
-remotePDBName orclpdb1 \
-remoteDBConnString ORCL \
-remoteDBSYSDBAUserName sys -remoteDBSYSDBAUserPassword Welcome1 \
-sysDBAUserName sys -sysDBAPassword Welcome1 \
-dbLinkUsername c##remote_user -dbLinkUserPassword Welcome1 -sourceDB ORCL2 -pdbName pdbclone输出如下
Prepare for db operation
50% complete
Create pluggable database using remote clone operation
100% complete
Pluggable database pdbclone plugged successfully.
Look at the log file /u01/app/oracle/cfgtoollogs/dbca/ORCLCDB2/pdbclone/ORCLCDB2.log for further details.日志如下
$cat /u01/app/oracle/cfgtoollogs/dbca/ORCLCDB2/pdbclone/ORCLCDB2.log
[ 2023-10-20 07:47:55.920 GMT ] Prepare for db operation
DBCA_PROGRESS : 50%
[ 2023-10-20 07:47:55.982 GMT ] Create pluggable database using remote clone operation
DBCA_PROGRESS : 100%
[ 2023-10-20 07:48:23.910 GMT ] Pluggable database pdbclone plugged successfully.验证注意PDBCLONE被自动open了
SQL show pdbsCON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------2 PDB$SEED READ ONLY NO3 PDBCLONE READ WRITE NO
SQL alter session set containerpdbclone;Session altered.SQL select count(*) from hr.employees;COUNT(*)
----------107清理
alter pluggable database pdbclone close;
drop pluggable database pdbclone including datafiles;在clone的过程中dbca会自动创建database link名称固定为PDBCLONE_CLONE_LINK完成后会自动删除
SQL select * from all_db_links;
OWNER DB_LINK USERNAME HOST CREATED HID SHA VAL INT
---------- ------------------------------ ---------------- ---------------- --------- --- --- --- ---
SYS SYS_HUB SEEDDATA 17-APR-19 NO NO YES NO
SYS PDBCLONE_CLONE_LINK C##REMOTE_USER ORCL 20-OCT-23 NO NO YES NO
...
SQL /OWNER DB_LINK USERNAME HOST CREATED HID SHA VAL INT
---------- ------------------------------ ---------------- ---------------- --------- --- --- --- ---
SYS SYS_HUB SEEDDATA 17-APR-19 NO NO YES NOdbca创建database link的SQL类似于
CREATE DATABASE LINK PDBCLONE_CLONE_LINK CONNECT TO c##remote_user IDENTIFIED BY Welcome1 USING ORCL;
drop database link PDBCLONE_CLONE_LINK;当然你不能主动创建否则后续dbca克隆时会报错
[FATAL] [DBT-19405] Database link (PDBCLONE_CLONE_LINK) is already exists.错误
这里遇到一个非常奇怪的错误就是当把-remoteDBConnString参数ORCL改为小写orcl时居然会报错
[FATAL] [DBT-08101] The selected PDB (orclpdb1) is not open.CAUSE: PDB has to be open in READ WRITE mode to perform the configuration.这个错误和这个帖子类似。
也和我创建ORCL2的语句有关
dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbname ORCLCDB2 -sid ORCL2 -responseFile NO_VALUE -characterSet AL32UTF8 -sysPassword Welcome1 -systemPassword Welcome1 -createAsContainerDatabase true -pdbName ORCLPDB1 -numberOfPDBs 1 -pdbAdminPassword Welcome1估计全部用小写就没事了。
果然删除时如果指定数据库为orcl2会报错
[WARNING] [DBT-11503] The instance (orcl2) is not running on the local node. This may result in partial delete of Oracle database.CAUSE: A locally running instance is required for complete deletion of Oracle database instance and database files.ACTION: Specify a locally running database, or execute DBCA on a node where the database instance is running.改成ORCL2就成功了
dbca -silent -deleteDatabase -sourceDB ORCL2
Enter SYS user password:[WARNING] [DBT-19202] The Database Configuration Assistant will delete the Oracle instances and datafiles for your database. All information in the database will be destroyed.
Prepare for db operation
32% complete
Connecting to database
35% complete
39% complete
42% complete
45% complete
48% complete
52% complete
65% complete
Updating network configuration files
68% complete
Deleting instance and datafiles
84% complete
100% complete
Database deletion completed.重建这回全部用小写
dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbname ORCL2 -sid ORCL2 -responseFile NO_VALUE -characterSet AL32UTF8 -sysPassword Welcome1 -systemPassword Welcome1 -createAsContainerDatabase true -pdbName orclpdb2 -numberOfPDBs 1 -pdbAdminPassword Welcome1另外-remoteDBConnString还是建议指向CDB。虽然在这篇博客中有成功的例证但我没有成功。
以下是-remoteDBConnString分别指定为orclpdb1和localhost:1521/ORCLPDB1时的报错
orcl2 $dbca -silent -createPluggableDatabase -createFromRemotePDB -remotePDBName ORCLPDB1 -remoteDBConnString orclpdb1 -remoteDBSYSDBAUserName sys -remoteDBSYSDBAUserPassword Welcome1 -sysDBAUserName sys -sysDBAPassword Welcome1 -dbLinkUsername c##remote_user -dbLinkUserPassword Welcome1 -sourceDB ORCL2 -pdbName pdbclone
[FATAL] [DBT-08101] The selected PDB (ORCLPDB1) is not open.CAUSE: PDB has to be open in READ WRITE mode to perform the configuration.orcl2 $dbca -silent -createPluggableDatabase -createFromRemotePDB -remotePDBName ORCLPDB1 -remoteDBConnString localhost:1521/ORCLPDB1 -remoteDBSYSDBAUserName sys -remoteDBSYSDBAUserPassword Welcome1 -sysDBAUserName sys -sysDBAPassword Welcome1 -dbLinkUsername c##remote_user -dbLinkUserPassword Welcome1 -sourceDB ORCL2 -pdbName pdbclone
[FATAL] [DBT-19407] Database option (SAMPLE_SCHEMA) is not installed in Local CDB (ORCL2).CAUSE: The database options installed on the Remote CDB(ORCLPDB1) must be the same as the database options installed on the Local CDB(ORCL2).参考
Oracle By Example: Clone PDBs using DBCA in Silent ModeMultitenant : DBCA PDB Remote Clone in Oracle Database 19cCloning a Remote PDB Using DBCA: ExampleDBCA createPluggableDatabase命令行帮助DBCA 错误