热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Oracle基础篇数据库启动

2019独角兽企业重金招聘Python工程师标准###1.启动OracleDB实例SyntaxSTARTUPoptions|upgrade_optionsoptionssy

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

###1. 启动Oracle DB 实例

此处输入图片的描述

Syntax
STARTUP options | upgrade_optionsoptions syntax:
[FORCE] [RESTRICT] [PFILE=filename] [QUIET] [ MOUNT [dbname] | [ OPEN [open_options] [dbname] ] | NOMOUNT ]open_options syntax:
READ {ONLY | WRITE [RECOVER]} | RECOVERupgrade_options syntax:
[PFILE=filename] {UPGRADE | DOWNGRADE} [QUIET]

####1.1 NOMOUNT

在创建数据库期间、重新创建控制文件期间,或执行某些备份和恢复方案期间,通常只在NOMOUNT 模式下启动实例。

启动实例过程包括执行以下任务:

  • 按以下顺序搜索$ORACLE_HOME/dbs 中具有特定名称的文件:
  1. 搜索spfile.ora。
  2. 如果未找到spfile.ora,则搜索spfile.ora。
  3. 如果未找到spfile.ora,则搜索init.ora。 这是包含实例初始化参数的文件。使用STARTUP 指定PFILE 参数可覆盖默认行为。
  • 分配SGA。
  • 启动后台进程。
  • 打开alert_.log 文件和跟踪文件。

####1.2 MOUNT

数据库装载过程包括执行以下任务:

  • 将数据库与以前启动的实例关联。
  • 定位并打开参数文件中指定的控制文件。
  • 通过读取控制文件来获取数据文件和联机重做日志文件的名称和状态(但是,此时不会执行检查来验证是否存在数据文件和联机重做日志文件)。

要执行特定的维护操作,请启动实例,然后装载数据库,但不打开该数据库。例如,在执行以下任务期间必须装载数据库,但不得打开数据库:

  • 重命名数据文件(打开数据库时可重命名脱机表空间的数据文件)。
  • 启用和禁用联机重做日志文件归档选项。
  • 执行完整的数据库恢复。

注:即使发出了OPEN 请求,数据库仍可能处于MOUNT 模式下。这是因为可能需要以某种方式恢复数据库。如果在MOUNT 状态下执行恢复,将打开重做日志进行读取,并打开数据文件读取需要恢复的块,以及在恢复期间根据需要写入块。


####1.3 OPEN

打开数据库过程包括执行以下任务:

  • 打开数据文件。
  • 打开联机重做日志文件。

如果尝试打开数据库时任一数据文件或联机重做日志文件不存在,则Oracle 服务器返回错误。 在最后这个阶段,Oracle 服务器会验证是否可以打开所有数据文件和联机重做日志文件,还会检查数据库的一致性。如有必要,系统监视器(SMON) 后台进程将启动实例恢复。

OPEN READ ONLY

Specify OPEN READ ONLY to restrict users to read-only transactions, preventing them from generating redo logs. This setting is the default when you are opening a physical standby database, so that the physical standby database is available for queries even while archive logs are being copied from the primary database site.

SQL> startup mount;
ORACLE instance started.Total System Global Area 6714322944 bytes
Fixed Size 2239192 bytes
Variable Size 6526338344 bytes
Database Buffers 167772160 bytes
Redo Buffers 17973248 bytes
Database mounted.
SQL> alter database open read only;Database altered.[root@hzvscmdb alert]# sqlplus hr/pass@tonytestSQL*Plus: Release 11.2.0.2.0 Production on Tue May 26 05:21:01 2015Copyright (c) 1982, 2010, Oracle. All rights reserved.Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning optionSQL> select count(*) from employees;COUNT(*)
----------109SQL> delete from employees;
delete from employees*
ERROR at line 1:
ORA-16000: database open for read-only access

OPEN READ WRITE Specify OPEN READ WRITE to open the database in read/write mode, allowing users to generate redo logs. This is the default if you are opening a primary database. You cannot specify this clause for a physical standby database.

SQL> startup mount;
ORACLE instance started.Total System Global Area 6714322944 bytes
Fixed Size 2239192 bytes
Variable Size 6526338344 bytes
Database Buffers 167772160 bytes
Redo Buffers 17973248 bytes
Database mounted.
SQL> alter database open read write;Database altered.SQL> delete from table1;10 rows deleted.SQL> commit;Commit complete.


####1.4 FORCE

If the database is open, then FORCE shuts down the database with a SHUTDOWN ABORT statement before re-opening it. If the database is closed, then FORCE opens the database.

#以force 方式 startup数据库
SQL> startup force;
ORACLE instance started.Total System Global Area 6714322944 bytes
Fixed Size 2239192 bytes
Variable Size 6526338344 bytes
Database Buffers 167772160 bytes
Redo Buffers 17973248 bytes
Database mounted.
Database opened.[root@hzvscmdb alert]# pwd
/home/oracle/app/oracle/diag/rdbms/tonytest/tonytest/alert
[root@hzvscmdb alert]# vi log.xml
####################首先shutdown abort#######################
Shutting down instance (abort)

Instance shutdown complete
####################startup normal#######################
Starting ORACLE instance (normal)
ALTER DATABASE MOUNT
ALTER DATABASE OPEN
####################performs recovery automatically#######################
Beginning crash recovery of 1 threads
read 193 KB redo, 84 data blocks need recovery
Recovery of Online Redo Log: Thread 1 Group 2 Seq 2697 Reading mem 0


####1.5 RESTRICT

Only enables Oracle Database users with the RESTRICTED SESSION system privilege to connect to the database. Later, you can use the ALTER SYSTEM command to disable the restricted session feature.

SQL> startup restrict mount ;
ORACLE instance started.Total System Global Area 6714322944 bytes
Fixed Size 2239192 bytes
Variable Size 6526338344 bytes
Database Buffers 167772160 bytes
Redo Buffers 17973248 bytes
Database mounted.SQL> alter database open;Database altered.[root@hzvscmdb alert]# sqlplus hr/pass@tonytestSQL*Plus: Release 11.2.0.2.0 Production on Tue May 26 05:55:42 2015Copyright (c) 1982, 2010, Oracle. All rights reserved.ERROR:
ORA-12526: TNS:listener: all appropriate instances are in restricted modeSQL> alter system disable restricted session;System altered.[root@hzvscmdb alert]# sqlplus hr/pass@tonytestSQL*Plus: Release 11.2.0.2.0 Production on Tue May 26 08:14:38 2015Copyright (c) 1982, 2010, Oracle. All rights reserved.Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning option

####1.6 PFILE

PFILE=filename

  • Specifies the client parameter file to be used while starting the instance. If PFILE is not specified, the server attempts to access a default server parameter file (spfile). If the default spfile isn't found, the server then attempts to access a default pfile. The default files are platform specific. For example, the default file is $ORACLE_HOME/dbs/init$ORACLE_SID.ora on UNIX, and ORACLE_HOME\database\initORCL.ora on Windows.

[oracle@hzvscmdb dbs]$ pwd
/home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs[oracle@hzvscmdb dbs]$ ll *tonytest.ora
-rw-r--r-- 1 oracle oinstall 1128 Aug 5 2014 inittonytest.ora
-rw-r-----. 1 oracle oinstall 3584 May 26 05:47 spfiletonytest.oraSQL> startup pfile = inittonytest.ora;
ORACLE instance started.Total System Global Area 6714322944 bytes
Fixed Size 2239192 bytes
Variable Size 5150606632 bytes
Database Buffers 1543503872 bytes
Redo Buffers 17973248 bytes
Database mounted.
Database opened.


转:https://my.oschina.net/wangbinbin0326/blog/420260



推荐阅读
  • 本文介绍了Oracle数据库中tnsnames.ora文件的作用和配置方法。tnsnames.ora文件在数据库启动过程中会被读取,用于解析LOCAL_LISTENER,并且与侦听无关。文章还提供了配置LOCAL_LISTENER和1522端口的示例,并展示了listener.ora文件的内容。 ... [详细]
  • 使用Ubuntu中的Python获取浏览器历史记录原文: ... [详细]
  • 本文讨论了在数据库打开和关闭状态下,重新命名或移动数据文件和日志文件的情况。针对性能和维护原因,需要将数据库文件移动到不同的磁盘上或重新分配到新的磁盘上的情况,以及在操作系统级别移动或重命名数据文件但未在数据库层进行重命名导致报错的情况。通过三个方面进行讨论。 ... [详细]
  • mysql-cluster集群sql节点高可用keepalived的故障处理过程
    本文描述了mysql-cluster集群sql节点高可用keepalived的故障处理过程,包括故障发生时间、故障描述、故障分析等内容。根据keepalived的日志分析,发现bogus VRRP packet received on eth0 !!!等错误信息,进而导致vip地址失效,使得mysql-cluster的api无法访问。针对这个问题,本文提供了相应的解决方案。 ... [详细]
  • Windows7 64位系统安装PLSQL Developer的步骤和注意事项
    本文介绍了在Windows7 64位系统上安装PLSQL Developer的步骤和注意事项。首先下载并安装PLSQL Developer,注意不要安装在默认目录下。然后下载Windows 32位的oracle instant client,并解压到指定路径。最后,按照自己的喜好对解压后的文件进行命名和压缩。 ... [详细]
  • 如何实现织梦DedeCms全站伪静态
    本文介绍了如何通过修改织梦DedeCms源代码来实现全站伪静态,以提高管理和SEO效果。全站伪静态可以避免重复URL的问题,同时通过使用mod_rewrite伪静态模块和.htaccess正则表达式,可以更好地适应搜索引擎的需求。文章还提到了一些相关的技术和工具,如Ubuntu、qt编程、tomcat端口、爬虫、php request根目录等。 ... [详细]
  • 基于PgpoolII的PostgreSQL集群安装与配置教程
    本文介绍了基于PgpoolII的PostgreSQL集群的安装与配置教程。Pgpool-II是一个位于PostgreSQL服务器和PostgreSQL数据库客户端之间的中间件,提供了连接池、复制、负载均衡、缓存、看门狗、限制链接等功能,可以用于搭建高可用的PostgreSQL集群。文章详细介绍了通过yum安装Pgpool-II的步骤,并提供了相关的官方参考地址。 ... [详细]
  • 本文详细介绍了SQL日志收缩的方法,包括截断日志和删除不需要的旧日志记录。通过备份日志和使用DBCC SHRINKFILE命令可以实现日志的收缩。同时,还介绍了截断日志的原理和注意事项,包括不能截断事务日志的活动部分和MinLSN的确定方法。通过本文的方法,可以有效减小逻辑日志的大小,提高数据库的性能。 ... [详细]
  • 本文介绍了如何使用php限制数据库插入的条数并显示每次插入数据库之间的数据数目,以及避免重复提交的方法。同时还介绍了如何限制某一个数据库用户的并发连接数,以及设置数据库的连接数和连接超时时间的方法。最后提供了一些关于浏览器在线用户数和数据库连接数量比例的参考值。 ... [详细]
  • 本文详细介绍了MysqlDump和mysqldump进行全库备份的相关知识,包括备份命令的使用方法、my.cnf配置文件的设置、binlog日志的位置指定、增量恢复的方式以及适用于innodb引擎和myisam引擎的备份方法。对于需要进行数据库备份的用户来说,本文提供了一些有价值的参考内容。 ... [详细]
  • 关于我们EMQ是一家全球领先的开源物联网基础设施软件供应商,服务新产业周期的IoT&5G、边缘计算与云计算市场,交付全球领先的开源物联网消息服务器和流处理数据 ... [详细]
  • 图解redis的持久化存储机制RDB和AOF的原理和优缺点
    本文通过图解的方式介绍了redis的持久化存储机制RDB和AOF的原理和优缺点。RDB是将redis内存中的数据保存为快照文件,恢复速度较快但不支持拉链式快照。AOF是将操作日志保存到磁盘,实时存储数据但恢复速度较慢。文章详细分析了两种机制的优缺点,帮助读者更好地理解redis的持久化存储策略。 ... [详细]
  • MyBatis错题分析解析及注意事项
    本文对MyBatis的错题进行了分析和解析,同时介绍了使用MyBatis时需要注意的一些事项,如resultMap的使用、SqlSession和SqlSessionFactory的获取方式、动态SQL中的else元素和when元素的使用、resource属性和url属性的配置方式、typeAliases的使用方法等。同时还指出了在属性名与查询字段名不一致时需要使用resultMap进行结果映射,而不能使用resultType。 ... [详细]
  • r2dbc配置多数据源
    R2dbc配置多数据源问题根据官网配置r2dbc连接mysql多数据源所遇到的问题pom配置可以参考官网,不过我这样配置会报错我并没有这样配置将以下内容添加到pom.xml文件d ... [详细]
  • WhenIusepythontoapplythepymysqlmoduletoaddafieldtoatableinthemysqldatabase,itdo ... [详细]
author-avatar
zmhua123_681
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有