grid 常用命令和基礎概念 (Oracle RAC Administration)

yewushang發表於2014-03-02
新增redo
ALTER DATABASE ADD LOGFILE THREAD 2 GROUP 4;
ALTER DATABASE ADD LOGFILE THREAD 2 GROUP 5;
ALTER DATABASE ENABLE THREAD 2;


指定undo
ALTER SYSTEM SET UNDO_TABLESPACE=undotbs3 SID='RAC01';
Automatic Undo Management in RAC
The Oracle database automatically manages undo segments within a specific undo tablespace
that is assigned to an instance. Under normal circumstances, only the instance assigned to the
undo tablespace can modify the contents of that tablespace. However, all instances can always
read all undo blocks for consistent-read purposes. Also, any instance can update any undo
tablespace during transaction recovery, as long as that undo tablespace is not currently used by
another instance for undo generation or transaction recovery.
You assign undo tablespaces in your RAC database by specifying a different value for the
UNDO_TABLESPACE parameter for each instance in your SPFILE or individual PFILEs. If you do
not set the UNDO_TABLESPACE parameter, each instance uses the first available undo tablespace.
For policy-managed databases, Oracle automatically allocates the undo tablespace when the
instance starts if you have OMF enabled.
You can dynamically switch undo tablespace assignments by executing the ALTER SYSTEM
SET UNDO_TABLESPACE statement. You can run this command from any instance. In the
example above, the previously used undo tablespace assigned to the RAC01 instance remains
assigned to it until RAC01’s last active transaction commits. The pending offline tablespace
may be unavailable for other instances until all transactions against that tablespace are
committed. You cannot simultaneously use Automatic Undo Management (AUM) and manual
undo management in a RAC database. It is highly recommended that you use the AUM mode.


啟動和關閉rac database方法 
Starting and Stopping RAC Instances
? Multiple instances can open the same database
simultaneously.
? Shutting down one instance does not interfere with other
running instances.
? SHUTDOWN TRANSACTIONAL LOCAL does not wait for
other instances’ transactions to finish.
? RAC instances can be started and stopped by using:
– Enterprise Manager
– The Server Control (srvctl) utility
– SQL*Plus
? Shutting down a RAC database means shutting down all
instances accessing the database.


sqlplus依次關閉
[host01] $ echo $ORACLE_SID
orcl1
sqlplus / as sysdba
SQL> startup
SQL> shutdown
[host02] $ echo $ORACLE_SID
orcl2
sqlplus / as sysdba
SQL> startup
SQL> shutdown


用srvctl工具
Starting and Stopping
RAC Instances with srvctl
? start/stop syntax:
? Examples:
srvctl start|stop instance -d -i
[-o open|mount|nomount|normal|transactional|immediate|abort>]
[-c | -q]
$ srvctl start instance -d orcl -i orcl1,orcl2
$ srvctl stop instance -d orcl -i orcl1,orcl2
srvctl start|stop database -d
[-o open|mount|nomount|normal|transactional|immediate|abort>]
[-c | -q]
$ srvctl start database -d orcl -o open


配置database 
Switch Between the Automatic
and Manual Policies
srvctl modify database -d orcl -y MANUAL;
$ srvctl config database -d orcl -a
Database unique name: orcl
Database name: orcl
Oracle home: /u01/app/oracle/product/11.2.0/dbhome_1
Oracle user: oracle
Spfile: +DATA/orcl/spfileorcl.ora
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools: orcl
Database instances: orcl1,orcl2
Disk Groups: DATA, FRA
Services:
Database is enabled
Database is administrator managed




srvctl modify database -d orcl -y MANUAL;


引數檔案
RAC Initialization Parameter Files
? An SPFILE is created if you use the DBCA.
? The SPFILE must be created on a shared volume or
shared raw device.
? All instances use the same SPFILE.
? If the database is created manually, create an SPFILE
from a PFILE.


如何修改引數檔案內容
SPFILE Parameter Values and RAC
? You can change parameter settings using the ALTER
SYSTEM SET command from any instance:  --常用
? SPFILE entries such as:
– *. apply to all instances
. apply only to
. takes precedence over *.
? Use current or future *. settings for :
? Remove an entry from your SPFILE:
ALTER SYSTEM RESET SCOPE=SPFILE sid='';
ALTER SYSTEM RESET SCOPE=MEMORY sid='';




RAC Initialization Parameters
CLUSTER_DATABASE: Enables a database to be started in cluster mode. Set this to TRUE.
CLUSTER_DATABASE_INSTANCES: Sets the number of instances in your RAC
environment. A proper setting for this parameter can improve memory use.
CLUSTER_INTERCONNECTS: Specifies the cluster interconnect when there is more than one
interconnect. Refer to your Oracle platform–specific documentation for the use of this
parameter, its syntax, and its behavior. You typically do not need to set the
CLUSTER_INTERCONNECTS parameter. For example, do not set this parameter for the
following common configurations:
? If you have only one cluster interconnect
? If the default cluster interconnect meets the bandwidth requirements of your RAC
database, which is typically the case
? If NIC bonding is being used for the interconnect
? When OIFCFG’s global configuration can specify the right cluster interconnects. It only
needs to be specified as an override for OIFCFG.
DB_NAME: If you set a value for DB_NAME in instance-specific parameter files, the setting
must be identical for all instances.
DISPATCHERS: Set this parameter to enable a shared-server configuration, that is, a server
that is configured to allow many user processes to share very few server processes.




With shared-server configurations, many user processes connect to a dispatcher. The
DISPATCHERS parameter may contain many attributes. Oracle recommends that you
configure at least the PROTOCOL and LISTENER attributes.
PROTOCOL specifies the network protocol for which the dispatcher process generates a
listening end point. LISTENER specifies an alias name for the Oracle Net Services listeners.
Set the alias to a name that is resolved through a naming method, such as a tnsnames.ora
file.
THREAD: If specified, this parameter must have unique values on all instances. The THREAD
parameter specifies the number of the redo thread to be used by an instance. You can specify
any available redo thread number as long as that thread number is enabled and is not used.
Other parameters that can affect RAC database configurations include:
? ASM_PREFERRED_READ_FAILURE_GROUPS: Specifies a set of disks to be the preferred
disks from which to read mirror data copies. The values that you set for this parameter
are instance specific and need not be the same on all instances.
? GCS_SERVER_PROCESSES: This static parameter specifies the initial number of server
processes for an Oracle RAC instance’s Global Cache Service (GCS). The GCS
processes manage the routing of interinstance traffic among Oracle RAC instances. The
default number of GCS server processes is calculated based on system resources. For
systems with one to three CPUs, there are two GCS server processes (LMSn). For
systems with four to fifteen CPUs, there are two GCS server processes (LMSn). For
systems with sixteen more CPUs, the number of GCS server processes equals (the
number of CPUs divided by 32) + 2, dropping any fractions. You can set this parameter
to different values on different instances.
? INSTANCE_NAME: The instance’s SID. The SID identifies the instance’s shared
memory on a host. Any alphanumeric characters can be used. The value for this
parameter is automatically set to the database unique name followed by an incrementing
number during the creation of the database when using DBCA.
? INSTANCE_NUMBER: An Oracle RAC parameter that specifies a unique number that
maps the instance to one free list group for each database object. This parameter must be
set for every instance in the cluster. It is automatically defined during the creation of the
database when using DBCA.
? REMOTE_LISTENER: This dynamic parameter specifies a network name that resolves
to an address or address list of Oracle Net remote listeners (that is, listeners that are not
running on the same machine as this instance). The address or address list is specified in
the TNSNAMES.ORA file or other address repository as configured for your system.
Parameters That Require Identical Settings
? ACTIVE_INSTANCE_COUNT
? ARCHIVE_LAG_TARGET
? COMPATIBLE
? CLUSTER_DATABASE/CLUSTER_DATABASE_INSTANCES
? CONTROL_FILES
? DB_BLOCK_SIZE
? DB_DOMAIN
? DB_FILES
? DB_NAME
? DB_RECOVERY_FILE_DEST/DB_RECOVERY_FILE_DEST_SIZE
? DB_UNIQUE_NAME
? INSTANCE_TYPE (RDBMS or ASM)
? PARALLEL_EXECUTION_MESSAGE_SIZE
? REMOTE_LOGIN_PASSWORD_FILE
? UNDO_MANAGEMENT


Quiescing RAC Databases
? Use the ALTER SYSTEM QUIESCE RESTRICTED
statement from a single instance:
? You must have the Database Resource Manager feature
activated to issue the statement above.
? The database cannot be opened by other instances after
the ALTER SYSTEM QUIESCE… statement starts.
? The ALTER SYSTEM QUIESCE RESTRICTED and ALTER
SYSTEM UNQUIESCE statements affect all instances in a
RAC environment.
? Cold backups cannot be taken when the database is in a
quiesced state.


Quiescing RAC Databases
To quiesce a RAC database, use the ALTER SYSTEM QUIESCE RESTRICTED statement from one
instance. It is not possible to open the database from any instance while the database is in the
process of being quiesced from another instance. After all the non-DBA sessions become
inactive, the ALTER SYSTEM QUIESCE RESTRICTED statement executes and the database is
considered to be quiesced. In a RAC environment, this statement affects all instances.
To issue the ALTER SYSTEM QUIESCE RESTRICTED statement in a RAC environment, you
must have the Database Resource Manager feature activated, and it must have been activated
since instance startup for all instances in the cluster database. It is through the Database
Resource Manager that non-DBA sessions are prevented from becoming active. The following
conditions apply to RAC:
? If you had issued the ALTER SYSTEM QUIESCE RESTRICTED statement, but the Oracle
server has not finished processing it, then you cannot open the database.
? You cannot open the database if it is already in a quiesced state.
? The ALTER SYSTEM QUIESCE RESTRICTED and ALTER SYSTEM UNQUIESCE statements
affect all instances in a RAC environment, not just the instance that issues the command.
Cold backups cannot be taken when the database is in a quiesced state because the Oracle
background processes may still perform updates for internal purposes even when the database
is in a quiesced state. Also, the file headers of online data files continue to appear as if they are
being accessed. They do not look the same as if a clean shutdown were done.


kill全域性session
Terminating Sessions on a Specific Instance
SQL> SELECT SID, SERIAL#, INST_ID
2 FROM GV$SESSION WHERE USERNAME='JMW';
SID SERIAL# INST_ID
---------- ---------- ----------
140 3340 2
SQL> ALTER SYSTEM KILL SESSION '140,3340,@2';
System altered.
SQL>
ALTER SYSTEM KILL SESSION '140,3340,@2'
*
ERROR at line 1:
ORA-00031: session marked for kill


sqlplus環境命令的影響範圍
How SQL*Plus Commands Affect Instances
Most SQL statements affect the current instance. You can use SQL*Plus to start and stop
instances in the RAC database. You do not need to run SQL*Plus commands as root on
UNIX-based systems or as Administrator on Windows-based systems. You need only the
proper database account with the privileges that you normally use for single-instance Oracle
database administration. The following are some examples of how SQL*Plus commands affect
instances:
? The ALTER SYSTEM SET CHECKPOINT LOCAL statement affects only the instance
to which you are currently connected, rather than the default instance or all instances.
? ALTER SYSTEM CHECKPOINT LOCAL affects the current instance.
? ALTER SYSTEM CHECKPOINT or ALTER SYSTEM CHECKPOINT GLOBAL
affects all instances in the cluster database.
? ALTER SYSTEM SWITCH LOGFILE affects only the current instance.
? To force a global log switch, use the ALTER SYSTEM ARCHIVE LOG CURRENT
statement.
? The INSTANCE option of ALTER SYSTEM ARCHIVE LOG enables you to archive
each online redo log file for a specific instance.






來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29477587/viewspace-1097989/,如需轉載,請註明出處,否則將追究法律責任。

相關文章