oracle用脚本安装第二个数据库

kingwwz kingwwz     2022-11-30     414

关键词:

  • 安装第二个数据库:
登录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第二个数据库实例,用plsql不能连接

...了一个实例,orcl,用plsql能够正常连接,之后又建立一个数据库实例,orcl10g,结果orcl10g不能用plsql正常连接,但是可以用sqlplus正常连接。下面是tnsnames.ora的代码片段:ORCL=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=15... 查看详情

在第二个脚本函数中传递来自第一个 python 脚本主函数的数据

】在第二个脚本函数中传递来自第一个python脚本主函数的数据【英文标题】:Passingthedatafromafirstpythonscriptsmainfunctioninasecondscriptsfunction【发布时间】:2020-05-0604:39:57【问题描述】:我需要在第二个脚本的函数中使用第一个脚本中... 查看详情

第二章oracle自动化部署脚本介绍

...中国DBA联盟(ACDU)成员。目前从事OracleDBA工作,曾从事Oracle数据库开发工作,主要服务于生产制造,汽车金融等行业。现拥有OracleOCP,OceanBaseOBCA认证,擅长Oracle数据库运维开发,备份恢复,安装迁移,Linux自动化运维脚本编写等。... 查看详情

unity5.3怎么用脚本切换场景

、假定你的第一个flash的文件名为A、以第一个文件为基础。2。3,都复制到第一个文件的场景中,衔接的方法,第二个文件为B,将第二个文件的所有图层.fla。衔接的方法是:在第一个文件的某图层的最后一帧,与第二的文件的... 查看详情

当第一个脚本运行第二个脚本方法时,第二个脚本无法识别第一个脚本的变量

】当第一个脚本运行第二个脚本方法时,第二个脚本无法识别第一个脚本的变量【英文标题】:Secondscriptdoesnotrecognizevariablesoffirstscriptwhenfirstscriptrunssecondscriptmethod【发布时间】:2021-01-1523:33:52【问题描述】:我有这个脚本MainGUI.p... 查看详情

使用脚本中的参数调用第二个脚本

】使用脚本中的参数调用第二个脚本【英文标题】:Invokeasecondscriptwithargumentsfromascript【发布时间】:2012-10-0218:18:12【问题描述】:我有一个脚本,它读取一个配置文件,该文件生成一组名称值对,我想将它们作为参数传递给第... 查看详情

脚本不适用于引用组件的第二个实例

】脚本不适用于引用组件的第二个实例【英文标题】:Scriptnotworkingforsecondinstanceofreferencedcomponent【发布时间】:2012-09-2822:22:12【问题描述】:我有一个脚本用来旋转无序列表(LI)中的图像。如果页面上只有一个引用类的实例,则... 查看详情

用 MVC3 创建的第二个数据库,如何防止?

】用MVC3创建的第二个数据库,如何防止?【英文标题】:SeconddatabasecreatedwithMVC3,howtoprevent?【发布时间】:2012-08-2811:16:42【问题描述】:我对MVC3非常陌生,但我在使用CodeFirst方法时遇到了问题。我创建了2个模型、一个上下文、... 查看详情

oracle怎样导出单张表

...(只能在服务端),exp(客户端服务端皆可)(3)写一脚本,导出为xls文件第一个脚本,main.sqlsetlinesize200settermoffverifyofffeedbackoffpagesize999setmarkuphtmlonentmapONspoolonpreformatoffspooltables.xls@get_tables.sqlspooloffexit第二个脚本,get_tables.sql里... 查看详情

Oracle - 使用第二个表中的行更新第一个表中的数据

】Oracle-使用第二个表中的行更新第一个表中的数据【英文标题】:Oracle-updatedatainfirsttablewithrowsfromsecondtable【发布时间】:2020-09-0410:40:04【问题描述】:在20/07/20时如何使用\'modfied\'(t2)更新\'date_from\'(t1)。所以在这种情况下,在t1... 查看详情

无法使用 Hibernate 和 Oracle 11g 数据库读取 Spring Boot 应用程序中的第二个 Refcursor

】无法使用Hibernate和Oracle11g数据库读取SpringBoot应用程序中的第二个Refcursor【英文标题】:UnabletoRead2ndRefcursorinaSpringBootapplicationwithHibernateandOracle11gDatabase【发布时间】:2020-06-1718:14:28【问题描述】:问题详情我们正在开发一个Sprin... 查看详情

第二个脚本语句(代码片段)

#!/bin/bashNAME=tomUSERID=id-u$NAMEif[$USERID-eq0];thenecho"Admin"elseecho"commonuser."fi对比USERID值是不是等于0,等于0是管理员,不等于0是普通用户 查看详情

rose应用服务资源名称不一致

Q:安装sybase数据库,两台服务器的数据库服务名称不一致,如下图所示:服务器主机名: server1,server2.产生的原因是安装数据库的时候,默认识别的是主机名称,这个地方应该统一名称,才可以做集群。sybase的服务名不一致第... 查看详情

将第二个参数从 shell 脚本传递到 Java [重复]

】将第二个参数从shell脚本传递到Java[重复]【英文标题】:PassingsecondargumentonwardsfromashellscripttoJava[duplicate]【发布时间】:2011-04-2901:07:30【问题描述】:如果我将任意数量的参数传递给在内部调用Java程序的shell脚本,我如何才能将... 查看详情

如果需要第一个函数,如何在脚本中执行第二个函数?

】如果需要第一个函数,如何在脚本中执行第二个函数?【英文标题】:Howdoyouexecutethesecondfunctioninascriptifitneedsthefirstfunction?【发布时间】:2017-07-2018:19:42【问题描述】:我认为这是基本的,我已经看到了我所问问题的多个版本... 查看详情

使用 QPushbutton 将变量传递到第二个脚本并执行它

】使用QPushbutton将变量传递到第二个脚本并执行它【英文标题】:UsingQPushbuttontopassvariablesintoasecondscriptandexecuteit【发布时间】:2021-08-2519:02:14【问题描述】:我正在尝试使用PyQt5gui的输入值来运行第二个python脚本。我正在猜测的... 查看详情

创建第二个 Toplevel 小部件时,线程 Tkinter 脚本崩溃

】创建第二个Toplevel小部件时,线程Tkinter脚本崩溃【英文标题】:ThreadedTkinterscriptcrasheswhencreatingthesecondToplevelwidget【发布时间】:2011-04-0319:02:02【问题描述】:我有一个Python脚本,它使用Tkinter作为GUI。我的小脚本应该每X秒创建... 查看详情

如何从单独的 php 脚本执行 php 脚本而不会丢失第二个脚本的输出?

】如何从单独的php脚本执行php脚本而不会丢失第二个脚本的输出?【英文标题】:Howtoexecuteaphpscriptfromaseparatephpscriptwithoutlosingoutputofsecondscript?【发布时间】:2016-10-0210:44:03【问题描述】:我目前正在开发一个项目,该项目使用HTM... 查看详情