• 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
    [oracle@test ~]$ . 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:
    [oracle@test ~]$ 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
    [oracle@test ~]$ 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
    [oracle@test ~]$ ps -ef|grep smon
    oracle   12955 12285  0 02:12 pts/2    00:00:00 grep smon
    

      

     
    • 演示2:
    [oracle@test ~]$ . 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@test ~]$ 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
    [oracle@test ~]$ 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
    [oracle@test ~]$ 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
    [oracle@test ~]$ ps -ef|grep smon
    oracle   13550 12285  0 02:14 pts/2    00:00:00 grep smon
     
    

      

     
    • 监听器没有受到快捷启停命令的影响:
    [oracle@test ~]$ 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
     
    

      

     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
  • 相关阅读:
    tomcat 安装时出现 Failed to install Tomcat7 service
    当Tomcat配置安装都成功端口号也没问题时网页输入http://localhost:8080/打不开如何解决
    渣渣HTML外加javascript做的第一个同乡会网页(好多功能都没写,只弄出来一个框架)
    jsp 有9个内置对象
    JavaScript编写的计时器/倒计时也可以改一下参数(用到的图片已经上传)
    当编写Servlet时出现type Status report message HTTP method GET is not supported by this URL description The specified HTTP method is not allowed for the requested resource.
    渣渣用JavaScript开发的消消乐,由于没有按照正规消消乐形式生成,是随机产生图形,所以存在一个算法bug,具体看下面,高手想到可以告诉我
    遇到浏览器设置后电脑上大部分应用打开都是浏览器方式
    Myeclipese建立servelet时出现带有javax.servlet.http.HttpServlet;变成了红色的解决方法
    PreferencesUtils SharedPreferences很好用的工具
  • 原文地址:https://www.cnblogs.com/kingwwz/p/10759817.html
Copyright © 2020-2023  润新知