管理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


相关内容

热门资讯

打造AI影像协作实验场 上影节... 上海国际电影节全新单元“AI片场”开机 打造AI影像协作实验场 “我做AI电影已经两年了。”德国AI...
我国首次成功批量克隆超高产奶山... 西北农林科技大学14日向新华社记者独家披露,学校羊遗传改良与生物育种创新团队攻克关键核心技术,6只超...
医学院硕博研究生靠虚开发票冒签... 33岁的柴某系江苏人,案发前系某医院博士后研究人员。一审法院认定,2018年至2023年,柴某在某医...
京东618自营电脑桌椅服务升级... 随着京东心动购物季开启,职场人、居家办公族及电竞爱好者的“久坐刚需”升级需求集中释放,电脑桌椅品类迎...
扎波罗热核电站遭乌军袭击,两名... 当地时间5月14日,扎波罗热核电站官方通报称,乌克兰武装部队的无人机对核电站周边区域发动袭击。在距离...
储殷:“建设性稳定关系”涵盖了... 特朗普率高规格代表团访华,中方也是高规格接待。中美今天的互动总体呈现出什么特点?这次元首外交又将如何...
中科信息称目前没有研发具身机器... 瑞财经 严明会 5月13日,中科信息在路演活动中表示,公司目前没有研发具身机器人,现有机器人主要面向...
按下物理AI加速键!香港成全球... 近日,首届香港具身智能产业峰会暨智元APC2026(香港)召开,标志着具身智能从技术炫技正式转向生产...
内塔尼亚胡称将对《纽约时报》提... 新华社耶路撒冷5月14日电(记者庞昕熠 冯国芮)以色列总理办公室14日发表声明称,由于美国《纽约时报...
黄仁勋最后一刻从“局外人”变“... 黄仁勋在最后一刻登上飞往北京的总统专机,从原本的“局外人”瞬间变成“座上宾”。这段场景的背后到底有哪...