Oracle 用脚本安装第二个数据库
Posted kingwwz
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Oracle 用脚本安装第二个数据库相关的知识,希望对你有一定的参考价值。
-
安装第二个数据库:
登录oracle用户进入家目录,添加配置环境变量:
vi .bash_profier ORACLE_SID=prod2
-
临时环境变量:
$export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1 $export ORACLE_SID=prod2
-
创建第二个数据库文件目录:
$mkdir -p /u01/app/oracle/oradata/prod2
-
创建sys用户密码文件:
$cd /u01/app/oracle/product/11.2.0/db_1/dbs $orapwd file=orapwprod2 password=oracle
-
创建一个可读参数文件:
$vi initprod2.ora 添加: DB_NAME=prod2 sga_target=500M control_files=‘/u01/app/oracle/oradata/prod2/control01.ctl‘
-
打开实例进入nomount模式,创建数据库系统proc,view ……:
SQL> sqlplus / as sysdba SQL> startup nomount; SQL> create spfile from pfile; SQL> shutdown immediate; SQL> startup nomount; SQL> alter system set db_create_file_dest=‘/u01/app/oracle/oradata/prod2‘; SQL> create database character set AL32UTF8 extent management local; SQL> @?/rdbms/admin/catalog.sql; SQL> @?/rdbms/admin/catproc.sql; SQL> alter user system identified by oracle account unlock; SQL> conn system/oracle SQL> @?/sqlplus/admin/pupbld.sql;
-
验证实例:
SQL> show parameter name; NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ db_file_name_convert string db_name string prod2 db_unique_name string prod2 global_names boolean FALSE instance_name string prod2 lock_name_space string log_file_name_convert string service_names string prod2
-
多个数据库切换:. oraenv
[[email protected] ~]$ . oraenv ORACLE_SID = [prod2] ? prod1 The Oracle base for ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1 is /u01/app/oracle
-
当再切入第二的环境变量的时候的,会无法自动识别oracle家目录,需手动输入地址,解决方法如下:
vi /etc/oratab(当用dbca窗口删库时,添加oratab文件后,dbca数据库列表会显示数据库名)
添加到最后一行参数:(Y代表支持dbstart和dbshut启停数据库)
prod2:/u01/app/oracle/product/11.2.0/db_1:Y
# This file is used by ORACLE utilities. It is created by root.sh # and updated by the Database Configuration Assistant when creating # a database. # A colon, ‘:‘, is used as the field terminator. A new line terminates # the entry. Lines beginning with a pound sign, ‘#‘, are comments. # # Entries are of the form: # $ORACLE_SID:$ORACLE_HOME:<N|Y>: # # The first and second fields are the system identifier and home # directory of the database respectively. The third filed indicates # to the dbstart utility that the database should , "Y", or should not, # "N", be brought up at system boot time. # # Multiple entries with the same $ORACLE_SID are not allowed. # # prod1:/u01/app/oracle/product/11.2.0/db_1:Y prod2:/u01/app/oracle/product/11.2.0/db_1:Y
-
演示1:
[[email protected] ~]$ ps -ef|grep smon oracle 11062 1 0 00:25 ? 00:00:00 ora_smon_prod2 oracle 12799 12285 0 02:12 pts/2 00:00:00 grep smon [[email protected] ~]$ dbshut ORACLE_HOME_LISTNER is not SET, unable to auto-stop Oracle Net Listener Usage: /u01/app/oracle/product/11.2.0/db_1/bin/dbshut ORACLE_HOME Processing Database instance "prod1": log file /u01/app/oracle/product/11.2.0/db_1/shutdown.log Processing Database instance "prod2": log file /u01/app/oracle/product/11.2.0/db_1/shutdown.log [[email protected] ~]$ ps -ef|grep smon \oracle 12955 12285 0 02:12 pts/2 00:00:00 grep smon
-
演示2:
[[email protected] ~]$ . oraenv ORACLE_SID = [prod2] ? prod1 The Oracle base for ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1 is /u01/app/oracle [[email protected] ~]$ dbstart ORACLE_HOME_LISTNER is not SET, unable to auto-start Oracle Net Listener Usage: /u01/app/oracle/product/11.2.0/db_1/bin/dbstart ORACLE_HOME Processing Database instance "prod1": log file /u01/app/oracle/product/11.2.0/db_1/startup.log Processing Database instance "prod2": log file /u01/app/oracle/product/11.2.0/db_1/startup.log [[email protected] ~]$ ps -ef|grep smon oracle 13130 1 0 02:13 ? 00:00:00 ora_smon_prod1 oracle 13239 1 0 02:13 ? 00:00:00 ora_smon_prod2 oracle 13390 12285 0 02:14 pts/2 00:00:00 grep smon [[email protected] ~]$ dbshut ORACLE_HOME_LISTNER is not SET, unable to auto-stop Oracle Net Listener Usage: /u01/app/oracle/product/11.2.0/db_1/bin/dbshut ORACLE_HOME Processing Database instance "prod1": log file /u01/app/oracle/product/11.2.0/db_1/shutdown.log Processing Database instance "prod2": log file /u01/app/oracle/product/11.2.0/db_1/shutdown.log [[email protected] ~]$ ps -ef|grep smon oracle 13550 12285 0 02:14 pts/2 00:00:00 grep smon
-
监听器没有受到快捷启停命令的影响:
[[email protected] ~]$ ps -ef|grep lsnr oracle 13609 1 0 02:18 ? 00:00:00 /u01/app/oracle/product/11.2.0/db_1/bin/tnslsnr LISTENER -inherit oracle 13621 12285 0 02:19 pts/2 00:00:00 grep lsnr
以上是关于Oracle 用脚本安装第二个数据库的主要内容,如果未能解决你的问题,请参考以下文章
想要使用 SharePreferences 更新第二个片段中的数据,但第二个片段没有更新