方法是先创建现有数据库的模板,然后通过该模板创建新数据库。语句如下:
dbca -silent -createTemplateFromDB -sourceDB rac04:1521:rac04 -sysDBAUserName sys -sysDBAPassword oracle -templateName racdb_template
dbca -silent -createDatabase -templateName racdb_template.dbt -gdbname tempdb -sid tempdb1 -datafileDestination /app/oracle/oradata2 -responseFile NO_VALUE -characterset ZHS16GBK
测试的环境是,源数据库为10.2.0.4,新创建的数据库为11.2.0.3;
步骤一:源数据库10.2.0.4上创建模板
[oracle@rac04 templates]$ dbca -silent -createTemplateFromDB -sourceDB rac04:1521:rac04 -sysDBAUserName sys -sysDBAPassword oracle -templateName racdb_template
Creating a template from the database
10% complete
20% complete
30% complete
40% complete
50% complete
60% complete
70% complete
80% complete
90% complete
100% complete
Look at the log file "/app/oracle/product/10.2.0/db_1/cfgtoollogs/dbca/silent10.log" for further details.
步骤二:将新创建的模板,拷贝到目标服务器db1(192.168.1.20)上
[oracle@rac04 ~]$cd /app/oracle/product/10.2.0/db_1/assistants/dbca/templates/
[oracle@rac04 templates]$ scp racdb_template.dbt 192.168.1.20:/app/oracle/
oracle@192.168.1.20's password:
racdb_template.dbt 100% 20KB 20.2KB/s 00:00
步骤三:设置环境变量
db1服务器上是已经安装了11.2.0.3 rac的数据库节点;需要为新创建的数据库指定环境变量;如果没有安装oracle software则需要配置.bash_profile,然后安装软件;
[oracle@db1 oracle]$ cat ~/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export ORACLE_SID=racdb2
export OMS_HOME=$ORACLE_BASE/oms10g
export AGENT_HOME=$ORACLE_BASE/agent10g
export ORACLE_HOSTNAME=db1
export PATH=.:$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:${PATH}:$HOME/bin
export PATH=${PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin
export PATH=${PATH}:$ORACLE_BASE/common/oracle/bin:$ORACLE_HOME/jdk/bin
export ORACLE_TERM=xterm
export TNS_ADMIN=$ORACLE_HOME/network/admin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/oracm/lib
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib
export CLASSPATH=$ORACLE_HOME/jdk/jre
export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/jlib
export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/rdbms/jlib
export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/network/jlib
export THREADS_FLAG=native
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
export TEMP=/tmp
export TMPDIR=/tmp
export SQLPATH=/u01/app/oracle/login
umask 022
alias sqlplus='rlwrap sqlplus'
alias rman='rlwrap rman'
[oracle@db1 oracle]$
[oracle@db1 oracle]$ export ORACLE_BASE=/app/oracle
[oracle@db1 oracle]$ export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
[oracle@db1 oracle]$ export ORACLE_SID=tempdb1
步骤四:创建新数据库;
[oracle@db1 oracle]$ dbca -silent -createDatabase -templateName /app/oracle/racdb_template.dbt -gdbname tempdb -sid tempdb1 -datafileDestination /app/oracle/oradata -responseFile NO_VALUE -characterset ZHS16GBK
Enter SYS user password:
Enter SYSTEM user password:
Creating and starting Oracle instance
2% complete
3% complete
9% complete
Creating database files
10% complete
11% complete
12% complete
13% complete
14% complete
15% complete
19% complete
Creating data dictionary views
21% complete
24% complete
27% complete
28% complete
29% complete
30% complete
31% complete
32% complete
33% complete
34% complete
35% complete
36% complete
42% complete
45% complete
47% complete
48% complete
50% complete
Adding Oracle Text
51% complete
52% complete
57% complete
60% complete
Adding Enterprise Manager Repository
65% complete
69% complete
Registering database with Oracle Restart
74% complete
Completing Database Creation
77% complete
80% complete
82% complete
91% complete
100% complete
Look at the log file "/app/oracle/cfgtoollogs/dbca/tempdb/tempdb.log" for further details.
成功完成
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/16976507/viewspace-2131251/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/16976507/viewspace-2131251/