管理ORACLE实例
admin
2023-05-11 22:02:02
0


初始化参数文件:

-PFILE:Static parameter file,PFILE

-SPFILE:Persistent server parameter file,SPFILE

 

PFILE-- initSID.ora

·Text file

·Modified with an operating system editor

·Modifications made manually

·Changes take effect on the next start up

·Only opened during instance startup

·Default location is $ORACLE_HOME/dbs

 

 

Creating a PFILE

·Created from a sample init.ora  file

-Sample installed by the Oracle Universal Installer(OUI)

-Copy sample using operating system copy command

-Uniquely identified by database SID

$ cp $ORACLE_HOME/dbs/init.ora $ORACLE_HOME/dbs/initexample.ora

·Mofify the initSID.ora

-Edit the parameters

-Specific to database needs

·Example

-Creating a pfile from spfile.

SQL> create pfile from spfile'

 

 

 

SPFILE– spfileSID.ora
·Binary file

·Maintained by the Oracle server

·Always resides on the server side

·Ability to make changes persistent across shutdown and start up

·Can self-tune parameter vallues

·Can have Recovery Manager support backing up to the initialization parameter file

 

 

Creteing an SPFILE

·Created from a PFILE file

  SQL> create spfile='$ORACLE_HOME/dbs/spfileexample.ora’from                         pfile='$ORACLE_HOME/dbs/initexample.ora’

·Can be executed before or after instance start up

 

 

Modify Parameters in SPFILE:

SQL> ALTER system set parameter=value

提示:若命令中不使用scope选项,scope选项缺省为both。

SQL> alter system set fast_start_mttr_target=250 comment='hello world';

$ strings examplespfile.ora

 

DEFERRED(延迟生效)

SQL> select name,issys_modifiable from v$parameter where issys_modifiable='DEFERRED';

 

 

Modify Parameters in SPFILE

·Changing parameter values

SQL> alter system set undo_tablespace=undots02;

·Specifying temporary or persistent changes

SQL> alter system set undo_tablespace=undots02 scope=both;

·Deleting or resetting values

  SQL> alter system reset parameter_name sid='*';

 

 

 

SPFILE vs PFILE:

1.An SPFILE can be backed-up with RMAN(RMAN cannot backupPFILEs).

2.Reduce human errors.The SPFILE is maintained by theserver. Parameters are checked before changes are accepted.

3.Eliminate configuration problems(no need to have a local PFILE if you want to start Oracle from a remote machine).

4.Easy to find stored in a central location($ORACLE_HOME/dbs).

Note: SPFILE is better than PFILE!

 

 

 

STARTUP Command Behavior

·Order of precedence:

-spfileSID.ora

-Default SPFILE → spfile.ora

-initSID.ora

·Specified PFILE can override precedence.

SQL> STARTUP PFILE=$ORACLE_HOME/dbs/initexample.ora

·PFILE can indicate to use SPFILE.

  $ cat $ORACLE_HOME/dbs/initDBA1.ORA

    spfile=$ORACLE_HOME/dbs/spfileDBA1.ora

 

 

 

Who can start the database?

Database startup and shutdown are powerful administrative options and are restricted to users who connect to Oracle Database with administrator privileges. Depending on the operating system, one of the following conditions establishes administrator privileges for a user:

·The users's operating system privileges allow him or her to connect using administrator privileges.

·The user is granted the SYSDBA or SYSOPER privileges and the database users

password files to authenticate database administrators.

When you connect with SYSDBA privileges, you are in the schema owned by SYS. When you connect as SYSOPER, you are in the public schema. SYSOPER privileges are subset of SYSDBA privileges.

 

 

 

Starting Up a Database

参考联机文档:

http://docs.oracle.com/cd/E11882_01/server.112/e40540/startup.htm#CNCPT005

 

 

STARTUP Command

Start up the instance and open the database:

SQL> STARTUP;

SQL> STARTUP PFILE=$ORACLE_HOME/dbs/initdb01.ora;

 

STARTUP [FORCE] [RESTRICT] [NOMOUNT] [MIGRATE] [QUIET][PFILE=]

[MOUNT [EXCLUSIVE] x |

OPEN

 

 

 

ALTER DATABASE Command

·Change the state of the database from NOMOUNT to MOUNT:

  SQL> ALTER DATABASE MOUNT;

·Open the database as a read-only database:

  SQL> ALTER DATABASE OPEN READ ONLY;

 

 

 

Restricted Mode:

·Use the STARTUP command to restrict access to a database;

SQL> STARTUP RESTRICT;

·Use the ALTER SYSTEM command to place an instance in restricted mode:

SQL> alter system enable restricted session;

SQL> alter system disable restricted session;

 

杀掉某一进程会话:

SQL> select sid,serial#,username from v$session;

SQL> alter system kill session '40,9';  ## 40,9表示SID,SERIAL。

 

 

 

Read-OnlyMode

·Opening a database in read-only mode:

SQL> startup mount;

SQL> alter database open read only;

·Can be used to:

  -Execute queries

  -Execute disk sorts using locally managed tablespaces

  -Take data files offline and online, but not tablespaces

  -Perform recovery of offline data files and tablespaces

 

 

 

ShuttingDown the Database


Database Behavior

ABORT

IMMEDIATE

TRANSACTIONAL

NORMAL

Permits new user connections

No

No

No

No

Waits until current sessions end

No

No

No

Yes

Waits until current transactions end

No

No

Yes

Yes

Performs a checkpoint  and closes open files

No

Yes

Yes

Yes

 

SQL> shutdown abort;

SQL> shutdown immediate;

SQL> shutdown transactional;

SQL> shutdown normal;

 

 

 

DiagnosticFiles

·Diagnostic files

  - Contain information about significant events

  - Used to resolve problems

  - Used to better manage the database on a day-to-day basis

·Several types exist:

  - alertSID.log file

  - Background tracefiles

  - User trace files

 

Alert Log File

·alertSID.log file:

  - Records the commands

  - Records results of major events

  - Used for day-to-day operational information

  - Used for diagnosingd atabase errors

·Each entry has a time stamp associated with it

·Must be managed by DBA

·Location defined by BACKGROUND_DUMP_DEST

SQL> show parameter background_dump_dest;

 

 

 

Enable/DisabledUser Tracing

·Session level:

-Using the ALTERSESSION command:

SQL> alter session set sql_trace = true

·Instance level:

-Setting the initialization parameter:

SQL_TRACE = TRUE


相关内容

热门资讯

以军士兵集体丢掉武器抗命,大喊... 据凤凰卫视报道,以色列国防军一军事基地7月30日发生士兵抗命事件,约120名士兵抗议指挥官做法,将武...
蒋成华任商务部副部长 国务院任免国家工作人员。任命蒋成华为商务部副部长。免去蒋成华的商务部国际贸易谈判副代表职务。
伊朗驻华大使:在军事威胁下,不... 新华社北京7月31日电(记者刁慧琳) 伊朗驻华大使法兹里7月28日表示,伊美回到谈判桌的前提是美国必...
伊朗革命卫队在霍尔木兹海峡击中... 当地时间31日,伊朗伊斯兰革命卫队发布声明称,革命卫队海军当天在霍尔木兹海峡击中并扣留了两艘违反禁令...
美媒:特朗普,遇到了一个更强硬... 据《纽约时报》7月29日报道,就在特朗普总统看似放弃战事升级计划几天后,美国再次与伊朗交火。上周末,...
女子做气管镜时不幸身亡,丈夫称... 7月29日,西安刘先生反映妻子在当地医院做支气管镜检查时死亡,看监控时发现医生疑有违规操作。刘先生表...
全网“帮卖西瓜”,然后呢? 近日,河南部分地区西瓜滞销的消息在网上热度很高。很多地方也伸出援手:有景区收购千斤西瓜、免费赠予游客...
美媒:乌克兰袭击伊朗船只,险引... 据《纽约时报》7月28日报道,据伊朗和西方官员称,伊朗曾考虑攻击乌克兰的一个港口,以报复乌克兰对一艘...
20年里,他只画美女,用东方风... 迈进KIM在上海的工作室,迎面是一整墙的美女们。她们像是刚从一场时髦的沙龙里退场,或倚或立,眉宇间是...
Google在港推出AI代理G... 观点网讯:7月29日,Google在香港推出AI代理Gemini Spark,该代理可全天候在后台运...