DBA Commands
DBA Commands
com
Contents
administration .............................................................................................................................................. 3
DATABASE ................................................................................................................................................. 3
parameter file ........................................................................................................................................... 7
CONTROLFILE ............................................................................................................................................ 8
Redo Log.................................................................................................................................................. 10
Archived Redo Log .................................................................................................................................. 12
Tablespace .............................................................................................................................................. 14
Data Files ................................................................................................................................................. 19
Undo........................................................................................................................................................ 22
objects ..................................................................................................................................................... 23
DBMS_SCHEDULER ................................................................................................................................. 43
PDB ......................................................................................................................................................... 55
Materialized View ................................................................................................................................... 59
Flashback................................................................................................................................................. 75
AUDIT ...................................................................................................................................................... 79
Parallel .................................................................................................................................................... 81
Large Objects .......................................................................................................................................... 82
Partitioning ............................................................................................................................................. 84
Autotrace .............................................................................................................................................. 108
DBMS_REDEFINITION............................................................................................................................ 109
External Table ....................................................................................................................................... 112
RAC............................................................................................................................................................ 116
CRSCTL................................................................................................................................................... 116
OCRCONFIG ........................................................................................................................................... 166
cluvfy ..................................................................................................................................................... 170
OIFCFG .................................................................................................................................................. 182
SRVCTL .................................................................................................................................................. 184
www.usefzadeh.com
vahidusefzadeh@gmail.com
ASM........................................................................................................................................................... 276
ASMCMD Instance Management.......................................................................................................... 276
ASMCMD File Management .................................................................................................................. 284
ASMCMD Disk Group Management...................................................................................................... 290
ASMCMD Volume Management ........................................................................................................... 305
ACFS Commands ................................................................................................................................... 310
Altering Disk Groups ............................................................................................................................. 333
EXPDP/IMPDP........................................................................................................................................... 339
RMAN........................................................................................................................................................ 359
data guard................................................................................................................................................. 404
www.usefzadeh.com
vahidusefzadeh@gmail.com
chapter 1
administration
DATABASE
--CREATE DATABASE
syntax
CREATE DATABASE [ database ] { USER SYS IDENTIFIED BY password | USER SYSTEM IDENTIFIED BY password
example(Creating a CDB)
GROUP 2 ('/u01/logs/my/redo02a.log','/u02/logs/my/redo02b.log')
GROUP 3 ('/u01/logs/my/redo03a.log','/u02/logs/my/redo03b.log')
MAXLOGHISTORY 1
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 1024
www.usefzadeh.com
vahidusefzadeh@gmail.com
DATAFILE '/u01/oracle/oradata/newcdb/system01.dbf'
DATAFILE '/u01/oracle/oradata/newcdb/deftbs01.dbf'
TEMPFILE '/u01/oracle/oradata/newcdb/temp01.dbf'
DATAFILE '/u01/oracle/oradata/newcdb/undotbs01.dbf'
SEED
DATAFILE '/u01/oracle/oradata/usefdb/usertbs01.dbf'
--ALTER DATABASE
syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
| instance_clauses | security_clause } ;
examples
--ALTER SESSION
syntax
ALTER SESSION { ADVISE { COMMIT | ROLLBACK | NOTHING } | CLOSE DATABASE LINK dblink
examples
--ALTER SYSTEM
syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
examples
--DROP DATABASE
DROP DATABASE ;
--Startup/Shutdown
www.usefzadeh.com
vahidusefzadeh@gmail.com
--useful query:
select a.name "DB Name", e.global_name "Global Name", b.banner "DB Version", c.host_name "Host Name",
c.instance_name "Instance Name" ,c.startup_time "Instance Start Time", decode(c.logins,'RESTRICTED','YES','NO')
"Restricted Mode",a.log_mode "Archive Log Mode" , decode(a.open_mode,'READ ONLY','YES','NO') "Read Only
Mode" from v$database a, v$version b, v$instance c,global_name e WHERE b.banner LIKE '%Oracle%'
---STARTUP TIME:
parameter file
-- CREATE PFILE
syntax
example
--CREATE SPFILE
syntax
example
www.usefzadeh.com
vahidusefzadeh@gmail.com
--useful query:
--- undocumented parameters
SELECT a.ksppinm parameter, a.ksppdesc description, b.ksppstvl session_value, c.ksppstvl instance_value FROM
x$ksppi a, x$ksppcv b, x$ksppsv c WHERE a.indx = b.indx AND a.indx = c.indx AND SUBSTR (a.ksppinm,1,1) = '_'
ORDER BY a.ksppinm;
---display current value of a parameter
---pfile or spfile?
SELECT DECODE(value, NULL, 'PFILE', 'SPFILE') "Init File Type" FROM sys.v_$parameter WHERE name = 'spfile';
CONTROLFILE
--set parameter:
www.usefzadeh.com
vahidusefzadeh@gmail.com
--CREATE CONTROLFILE
syntex
example
MAXLOGFILES 192
MAXLOGMEMBERS 3
MAXDATAFILES 1024
MAXINSTANCES 32
MAXLOGHISTORY 140228
LOGFILE
DATAFILE
'/u01/oracle/oradata/usefdb/system01.dbf',
'/u01/oracle/oradata/usefdb/undotbs01.dbf',
'/u01/oracle/oradata/usefdb/sysaux01.dbf',
'/u01/oracle/oradata/usefdb/users01.dbf'
OR
www.usefzadeh.com
vahidusefzadeh@gmail.com
V$CONTROLFILE, v$controlfile_record_section
--useful query:
SELECT RPAD(SUBSTR(name, 1, 50), 51,' ') "CONTROL FILE NAME" FROM gv$controlfile;
Redo Log
ALTER DATABASE ADD LOGFILE GROUP <group_number> ('<log_member_path_and_name>') SIZE <integer> <K |
M | G>;
www.usefzadeh.com
vahidusefzadeh@gmail.com
or
www.usefzadeh.com
vahidusefzadeh@gmail.com
ALTER SYSTEM DUMP LOGFILE '<logfile_path_and_name>' TIME MIN <value> TIME MIN <value>;
--view:
V$LOG, V$LOGFILE
--useful query:
SELECT * FROM V$LOG G, V$LOGFILE M where G.GROUP#=M.GROUP# order by M.GROUP#;
SHUTDOWN immediate
STARTUP MOUNT
LOG_ARCHIVE_FORMAT=%t_%s_%r.dbf
LOG_ARCHIVE_MIN_SUCCEED_DEST
www.usefzadeh.com
vahidusefzadeh@gmail.com
--view:
--useful query:
select LOG_MODE from V$DATABASE;
--count arcs per day
www.usefzadeh.com
vahidusefzadeh@gmail.com
Tablespace
--CREATE TABLESPACE
example
www.usefzadeh.com
vahidusefzadeh@gmail.com
--ALTER TABLESPACE
syntax
| MINIMUM EXTENT size_clause | RESIZE size_clause | COALESCE | SHRINK SPACE [ KEEP size_clause]
-- ADD DATAFILE
-- Bigfile Tablespaces
www.usefzadeh.com
vahidusefzadeh@gmail.com
-- Tablespace Groups
www.usefzadeh.com
vahidusefzadeh@gmail.com
-- Compressed Tablespaces
-- Encrypted Tablespaces
--Renaming Tablespaces
-- DROP TABLESPACE
syntax
DROP TABLESPACE tablespace [ INCLUDING CONTENTS [ {AND | KEEP} DATAFILES ][ CASCADE CONSTRAINTS ]] ;
examples
www.usefzadeh.com
vahidusefzadeh@gmail.com
--view
--useful query:
select * from dba_tablespace_usage_metrics;
www.usefzadeh.com
vahidusefzadeh@gmail.com
---tablespace info
Data File
- Creating Datafile
syntax
CREATE TABLESPACE ….
CREATE DATABASE …
----example:
ALTER TABLESPACE users ADD DATAFILE '/u01/oracle/usefdb/users03.dbf' SIZE 10M AUTOEXTEND ON NEXT 512K
MAXSIZE 250M;
ALTER TABLESPACE users ADD DATAFILE '/u01/oracle/usefdb/users03.dbf' SIZE 10M AUTOEXTEND ON NEXT 512K
MAXSIZE 250M;
-- Resizing a Datafile
www.usefzadeh.com
vahidusefzadeh@gmail.com
-- END BACKUP
--Rename File
www.usefzadeh.com
vahidusefzadeh@gmail.com
--drop tempfile
-- View
--useful query:
--data file info:
www.usefzadeh.com
vahidusefzadeh@gmail.com
Undo
--parameters:
UNDO_TABLESPACE = undotbs_01
UNDO_RETENTION=number(second)
www.usefzadeh.com
vahidusefzadeh@gmail.com
--view
v$UNDOSTAT
--useful query:
---undo sizes by STATUS
select 'Number of "ORA-01555 (Snapshot too old)" encountered since the last startup of the instance : ' ||
sum(ssolderrcnt) from v$undostat;
objects
Table
--Creating a Table
syntax
example
CREATE TABLE usef.admin_emp ( empno NUMBER(5) PRIMARY KEY, ename VARCHAR2(15) NOT NULL, ssn
www.usefzadeh.com
vahidusefzadeh@gmail.com
NUMBER(9) ENCRYPT USING 'AES256', job VARCHAR2(10), mgr NUMBER(5), hiredate DATE DEFAULT (sysdate),
photo BLOB, sal NUMBER(7,2), hrly_rate NUMBER(7,2) GENERATED ALWAYS AS (sal/2080), deptno NUMBER(3)
CREATE GLOBAL TEMPORARY TABLE admin_work_area (startdate DATE, enddate DATE, class CHAR(20))
-- Alter … parallel
INSERT /*+ APPEND */ INTO sales_history SELECT * FROM sales WHERE cust_id=8890;
COMMIT;
-- COMMENT
syntax
COMMENT ON { AUDIT POLICY policy | COLUMN [ schema. ] { table. | view. | materialized_view. } column
| MINING MODEL [ schema. ] model | OPERATOR [ schema. ] operator | TABLE [ schema. ] { table | view }
www.usefzadeh.com
vahidusefzadeh@gmail.com
} IS string ;
example
objname => 'EMPLOYEES', subobjname => '', row_id => 'AAAVEIAAGAAAABTAAD'), 1, 'No Compression', 2,
'Advanced Row Compression', 4, 'Hybrid Columnar Compression for Query High', 8, 'Hybrid Columnar
Compression for Query Low', 16, 'Hybrid Columnar Compression for Archive High', 32, 'Hybrid Columnar
Compression for Archive Low', 4096, 'Basic Table Compression', 'Unknown Compression Type')
--ALTER TABLE
syntax
-- Invisible Columns
www.usefzadeh.com
vahidusefzadeh@gmail.com
-- Moving a Table
ALTER TABLE usef.jobs MOVE STORAGE ( INITIAL 20K NEXT 40K MINEXTENTS 2 MAXEXTENTS 20 PCTINCREASE
0 ) TABLESPACE usef_tbs;
ALTER TABLE sales MOVE PARTITION sales_q4_2003 ROW STORE COMPRESS ADVANCED UPDATE INDEXES
ONLINE;
www.usefzadeh.com
vahidusefzadeh@gmail.com
TRUNCATE TABLE
ALTER TABLE UPGRADE INCLUDING DATA or ALTER TYPE CASCADE INCLUDING TABLE
Online redefinition
FLASHBACK TABLE
SELECT
CREATE/ALTER/DROP INDEX
DROP TABLE
--DROP TABLE
syntax
example
www.usefzadeh.com
vahidusefzadeh@gmail.com
--PURGE
syntax
PURGE { { TABLE table | INDEX index } | { RECYCLEBIN | DBA_RECYCLEBIN } | TABLESPACE tablespace [ USER
username ] } ;
syntax
--TRUNCATE_CLUSTER
--TRUNCATE_TABLE
TRUNCATE TABLE [schema.] table [ {PRESERVE | PURGE} MATERIALIZED VIEW LOG ] [ {DROP [ ALL ] | REUSE}
STORAGE ] [ CASCADE ] ;
example
CREATE TABLE admin_iot3(i PRIMARY KEY, j, k, l) ORGANIZATION INDEX PARALLEL AS SELECT * FROM usef.jobs;
CREATE TABLE admin_iot5(i INT, j INT, k INT, l INT, PRIMARY KEY (i, j, k)) ORGANIZATION INDEX COMPRESS;
CREATE TABLE admin_iot6(i INT, j INT, k INT, l INT, PRIMARY KEY(i, j, k)) ORGANIZATION INDEX COMPRESS 2;
www.usefzadeh.com
vahidusefzadeh@gmail.com
CREATE TABLE admin_iot7(i INT, j INT, k INT, l INT, PRIMARY KEY (i, j, k)) ORGANIZATION INDEX COMPRESS 1;
---ANALYZE
syntax
example
www.usefzadeh.com
vahidusefzadeh@gmail.com
ALTER TABLE dept DISABLE PRIMARY KEY KEEP INDEX, DISABLE UNIQUE (dname, loc)
KEEP INDEX;
ALTER TABLE dept ENABLE NOVALIDATE PRIMARY KEY, ENABLE NOVALIDATE UNIQUE
(dname, loc);
ALTER TABLE emp DROP PRIMARY KEY KEEP INDEX, DROP CONSTRAINT dept_fkey;
--gathering statistics
EXEC DBMS_STATS.GATHER_SCHEMA_STATS('SCOTT');
EXEC DBMS_STATS.GATHER_SCHEMA_STATS(OWNNAME=>'MRT');
EXEC DBMS_STATS.GATHER_SCHEMA_STATS('SCOTT',ESTIMATE_PERCENT=>10);
EXEC DBMS_STATS.GATHER_TABLE_STATS('SCOTT','EMP');
EXEC DBMS_STATS.GATHER_TABLE_STATS('SCOTT','EMP',ESTIMATE_PERCENT=>15);
EXEC DBMS_STATS.GATHER_INDEX_STATS('SCOTT','EMP_PK');
EXEC DBMS_STATS.GATHER_INDEX_STATS('SCOTT','EMP_PK',ESTIMATE_PERCENT=>15);
www.usefzadeh.com
vahidusefzadeh@gmail.com
--delete statistics
EXEC DBMS_STATS.DELETE_DATABASE_STATS;
EXEC DBMS_STATS.DELETE_SCHEMA_STATS('SCOTT');
EXEC DBMS_STATS.DELETE_TABLE_STATS('SCOTT','EMP');
EXEC DBMS_STATS.DELETE_INDEX_STATS('SCOTT','EMP_PK');
EXEC DBMS_STATS.DELETE_PENDING_STATS('SH','SALES');
EXEC DBMS_STATS.GATHER_SCHEMA_STATS(OWNNAME=>'PERFSTAT',CASCADE=>TRUE);
--useful query
www.usefzadeh.com
vahidusefzadeh@gmail.com
--CREATE TRIGGER
syntax
example
COMPOUND TRIGGER
statement;
--ALTER TRIGGER
syntax
example
--DROP TRIGGER
www.usefzadeh.com
vahidusefzadeh@gmail.com
--CREATE PROCEDURE
syntax
example
tot_emps NUMBER;
BEGIN
tot_emps := tot_emps - 1;
END;
--ALTER PROCEDURE
example
--DROP PROCEDURE
--compile PROCEDURE
--CREATE FUNCTION
syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
example
RETURN NUMBER
IS acc_bal NUMBER(11,2);
BEGIN
SELECT order_total
INTO acc_bal
FROM orders
RETURN(acc_bal);
END;
--ALTER FUNCTION
example
--DROP FUNCTION
--CREATE PACKAGE
syntax
example
END emp_bonus;
www.usefzadeh.com
vahidusefzadeh@gmail.com
syntax
example
BEGIN
DBMS_OUTPUT.PUT_LINE
END;
END emp_bonus;
--ALTER PACKAGE
--DROP PACKAGE
--compile PACKAGE
--useful query
Index
www.usefzadeh.com
vahidusefzadeh@gmail.com
-- create index
syntax
example
CREATE INDEX emp_ename ON emp(ename) TABLESPACE users STORAGE (INITIAL 20K NEXT 20k);
CREATE TABLE emp ( empno NUMBER(5) PRIMARY KEY, age INTEGER) ENABLE PRIMARY KEY USING INDEX
TABLESPACE users;
CREATE TABLE employees_part PARTITION BY HASH (employee_id) PARTITIONS 2 AS SELECT * FROM employees;
CREATE INDEX emp_ename ON emp(ename) TABLESPACE users STORAGE (INITIAL 20K NEXT 20k) INVISIBLE;
www.usefzadeh.com
vahidusefzadeh@gmail.com
--ALTER INDEX
--Renaming an Index
www.usefzadeh.com
vahidusefzadeh@gmail.com
--Partitioned Indexes
(range):
ticket_sales(month) GLOBAL
PARTITION BY range(month)
(hash):
-- DROP INDEX
syntax
example
www.usefzadeh.com
vahidusefzadeh@gmail.com
--info
syntax
example
CREATE VIEW sales_staff AS SELECT empno, ename, deptno FROM emp WHERE deptno = 10
--ALTER VIEW
syntax
example
--DROP VIEW
syntax
--COMPILE VIEW
www.usefzadeh.com
vahidusefzadeh@gmail.com
--usefule query
select view_name from all_views where view_name like '%LOGMNR " ;'
--CREATE SEQUENCE
syntax
example
CREATE SEQUENCE emp_sequence INCREMENT BY 1 START WITH 1 NOMAXVALUE NOCYCLE CACHE 10;
--ALTER SEQUENCE
syntex
example
--DROP SEQUENCE
syntex
-- Creating Synonyms
syntex
www.usefzadeh.com
vahidusefzadeh@gmail.com
example
-- ALTER SYNONYM
syntex
example
--DROP SYNONYM
syntex
Cluster
-- create cluster
syntax
CREATE CLUSTER [ schema. ] cluster (column datatype [ SORT ] [, column datatype [ SORT ] ]... )
example
CREATE TABLE emp ( empno NUMBER(5) PRIMARY KEY, ename VARCHAR2(15) NOT NULL, deptno NUMBER(3)
REFERENCES dept) CLUSTER emp_dept (deptno);
CREATE TABLE dept ( deptno NUMBER(3) PRIMARY KEY, . . . ) CLUSTER emp_dept (deptno);
www.usefzadeh.com
vahidusefzadeh@gmail.com
STORAGE (INITIAL 250K NEXT 50K MINEXTENTS 1 MAXEXTENTS 3 PCTINCREASE 0) HASH IS trialno HASHKEYS
150;
CREATE TABLE trial ( trialno NUMBER(5,0) PRIMARY KEY) CLUSTER trial_cluster (trialno);
CREATE TABLE call_detail ( telephone_number NUMBER, call_timestamp NUMBER SORT, call_duration NUMBER
SORT, other_info VARCHAR2(30) ) CLUSTER call_detail_cluster ( telephone_number, call_timestamp, call_duration
);
-- DROP CLUSTER
syntax
example
www.usefzadeh.com
vahidusefzadeh@gmail.com
DBMS_SCHEDULER
--Creating a Job
BEGIN
DBMS_SCHEDULER.CREATE_JOB (
END;
BYMONTHDAY any positive or negative number (eg -1 last day of the month)
BYDAY (MON, TUE, and so on) can be prefixed with a number -1FRI
examples:
www.usefzadeh.com
vahidusefzadeh@gmail.com
each month
BEGIN
DBMS_SCHEDULER.CREATE_JOB (
END;
BEGIN
DBMS_SCHEDULER.CREATE_JOB (
END;
www.usefzadeh.com
vahidusefzadeh@gmail.com
BEGIN
DBMS_SCHEDULER.CREATE_JOB (
END;
BEGIN
DBMS_SCHEDULER.CREATE_JOB (
END;
--Creating a Credential
BEGIN
END;
BEGIN
www.usefzadeh.com
vahidusefzadeh@gmail.com
DBMS_SCHEDULER.CREATE_DATABASE_DESTINATION (
END;
BEGIN
DBMS_SCHEDULER.CREATE_GROUP(
END;
BEGIN
DBMS_SCHEDULER.CREATE_JOB (
END;
www.usefzadeh.com
vahidusefzadeh@gmail.com
BEGIN
DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE (
argument_position => 2,
END;
--Altering Jobs
BEGIN
DBMS_SCHEDULER.SET_ATTRIBUTE (
END;
--Running Jobs
BEGIN
DBMS_SCHEDULER.RUN_JOB(
END;
-- Copying Jobs
begin
DBMS_SCHEDULER.COPY_JOB (
www.usefzadeh.com
vahidusefzadeh@gmail.com
old_job =>'MY_OLD_JOB',
new_job =>'MY_NEW_JOB');
end;
--Stopping Jobs
BEGIN
END;
--Dropping Jobs
BEGIN
END;
--Disabling Jobs
BEGIN
END;
Enabling Jobs
BEGIN
END;
--Creating Programs
BEGIN
DBMS_SCHEDULER.CREATE_PROGRAM (
www.usefzadeh.com
vahidusefzadeh@gmail.com
END;
BEGIN
DBMS_SCHEDULER.DEFINE_PROGRAM_ARGUMENT (
argument_position => 2,
END;
--Altering Programs
BEGIN
DBMS_SCHEDULER.SET_ATTRIBUTE (
END;
--Dropping Programs
BEGIN
www.usefzadeh.com
vahidusefzadeh@gmail.com
END;
--Enabling Programs
BEGIN
END;
-- create a window
BEGIN
DBMS_SCHEDULER.CREATE_WINDOW (
END;
-- Altering Windows
BEGIN
dbms_scheduler.set_attribute(
END;
www.usefzadeh.com
vahidusefzadeh@gmail.com
-- closing a window
begin
dbms_scheduler.close_window ('WORK_HOURS_WINDOW');
end;
--Dropping Windows
BEGIN
windowgroup1, windowgroup2');
END;
--Disabling Windows
BEGIN
END;
--Enabling Windows
BEGIN
END;
BEGIN
DBMS_SCHEDULER.CREATE_GROUP (
www.usefzadeh.com
vahidusefzadeh@gmail.com
END;
BEGIN
END;
BEGIN
END;
BEGIN
END;
BEGIN
END;
BEGIN
www.usefzadeh.com
vahidusefzadeh@gmail.com
END;
-- Creating Schedules
BEGIN
DBMS_SCHEDULER.CREATE_SCHEDULE (
END;
-- altering schedules
BEGIN
dbms_scheduler.set_attribute(
END;
-- Dropping Schedules
BEGIN
DBMS_SCHEDULER.DROP_SCHEDULE (
www.usefzadeh.com
vahidusefzadeh@gmail.com
END;
BEGIN
DBMS_SCHEDULER.CREATE_JOB_CLASS (
END;
BEGIN
dbms_scheduler.set_attribute(
END;
BEGIN
END;
--useful query
www.usefzadeh.com
vahidusefzadeh@gmail.com
PDB
syntax
examples
OR
www.usefzadeh.com
vahidusefzadeh@gmail.com
file_name_convert=(‘/u01/oracle/oradata/USEF_CDB/pdb1/datafile’,’/u01/oracle/oradata/USEF_CDB/pdb
_clone/datafile’);
--Connecting to a PDB:
TNS:
PDB1 =
(CONNECT_DATA =
(SERVER = DEDICATED)
(service_name = pdb1) ) )
CREATE USER testpdb IDENTIFIED BY password DEFAULT TABLESPACE pdb1_tbs QUOTA UNLIMITED ON pdb1_tbs
CONTAINER = CURRENT;
ALTER PLUGGABLE DATABASE <pdb_name> OPEN READ [WRITE] [UPGRADE] [RESTRICTED] [FORCE]
[INSTANCES = <('<instance_name>' | <ALL [EXCEPT ('<instance_name'>)] >);
www.usefzadeh.com
vahidusefzadeh@gmail.com
ALTER PLUGGABLE DATABASE pdb5 OPEN READ WRITE INSTANCES = ('ORCLDB_1', 'ORCLDB_2');
ALTER PLUGGABLE DATABASE <pdb_name> DATAFILE <'<datafile_name>' | filenumber> <ONLINE | OFFLINE [FOR
DROP] | RESIZE <size_clause> | <autoextend_clause> | END BACKUP>;
www.usefzadeh.com
vahidusefzadeh@gmail.com
--Supplemental Logging
--Unplugging PDB
--RMAN
backup
restore
rman target /
run{
www.usefzadeh.com
vahidusefzadeh@gmail.com
example
Materialized View
Syntax
[ query_rewrite_clause ] AS subquery ;
www.usefzadeh.com
vahidusefzadeh@gmail.com
ON [COMMIT | DEMAND ]
example
--Fast Refresh
Syntax
<tablespace_name> BUILD IMMEDIATE REFRESH <FAST | FORCE> ON <COMMIT | DEMAND> <USING INDEX |
Example:
CREATE MATERIALIZED VIEW mv_simple TABLESPACE uwdata BUILD IMMEDIATE REFRESH FAST ON COMMIT AS
SELECT * FROM servers;
--Force Refresh
Syntax
statement>);
Example:
www.usefzadeh.com
vahidusefzadeh@gmail.com
--Complete Refresh
Syntax
Example:
Syntax
CREATE MATERIALIZED VIEW <schema.name> [LOGGING] [CACHE] PCTFREE <integer> PCTUSED <integer>
USING INDEX TABLESPACE <tablespace_name> REFRESH <COMPLETE | FORCE> START WITH <date>
Example:
--Prebuilt Table
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
Example:
Syntax
Example:
EXPLAIN PLAN FOR SELECT s.srvr_id, i.installstatus, COUNT(*) FROM servers s, serv_inst i
WHERE s.srvr_id = i.srvr_id AND s.srvr_id = 502 GROUP BY s.srvr_id, i.installstatus;
CREATE MATERIALIZED VIEW mv_rewrite TABLESPACE uwdata REFRESH ON DEMAND ENABLE QUERY REWRITE
AS SELECT s.srvr_id, i.installstatus, COUNT(*) FROM servers s, serv_inst I WHERE s.srvr_id = i.srvr_id GROUP
BY s.srvr_id, i.installstatus;
EXPLAIN PLAN FOR SELECT s.srvr_id, i.installstatus, COUNT(*) FROM servers s, serv_inst i
WHERE s.srvr_id = i.srvr_id AND s.srvr_id = 502 GROUP BY s.srvr_id, i.installstatus;
www.usefzadeh.com
vahidusefzadeh@gmail.com
syntax
, OBJECT ID | , PRIMARY KEY | , ROWID | , SEQUENCE | , COMMIT SCN } ]... ] (column [, column ]...) [
example
CREATE MATERIALIZED VIEW LOG ON sales WITH ROWID (prod_id, cust_id, time_id, channel_id, promo_id,
CREATE MATERIALIZED VIEW LOG ON sales PURGE START WITH sysdate NEXT sysdate+1 WITH ROWID (prod_id,
-- Shrink Log
www.usefzadeh.com
vahidusefzadeh@gmail.com
ALTER MATERIALIZED VIEW LOG [FORCE] ON <schema.table_name> ALLOCATE EXTENT (SIZE <integer> <M | G |
T>);
ALTER MATERIALIZED VIEW LOG [FORCE] ON <schema.table_name> ALLOCATE EXTENT (DATAFILE <file_name>);
ALTER MATERIALIZED VIEW LOG [FORCE] ON <schema.table_name> ALLOCATE EXTENT SIZE (INSTANCE <integer>);
--Log Caching
syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
MAXTRANS 255 COMPUTE STATISTICS STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS
syntax
Examples
ALTER MATERIALIZED VIEW emp_data REFRESH COMPLETE START WITH TRUNC(SYSDATE+1) + 9/24 NEXT
SYSDATE+7;
--Allocate Extent
INSTANCE <integer>;
--Caching
www.usefzadeh.com
vahidusefzadeh@gmail.com
--Coalesce
--Compile
--Consider Fresh
--Deallocate Unused
--LOB Storage
--Logging
--Parallel Access
--Physical Attributes
www.usefzadeh.com
vahidusefzadeh@gmail.com
--Query Rewrite
--Refresh
--Shrink
--Table Compression
--Table Partitioning
syntax
example
www.usefzadeh.com
vahidusefzadeh@gmail.com
useful query
select o.owner, o.object_name mview, username, s.sid from v$lock l, dba_objects o, v$session s where
o.object_id=l.id1 and l.type='JI' and l.lmode=6 and s.sid=l.sid and o.object_type='TABLE';
User
-- CREATE USER
syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
| PROFILE profile | PASSWORD EXPIRE | ACCOUNT { LOCK | UNLOCK } [ DEFAULT TABLESPACE tablespace
UNLIMITED } ON tablespace }... | PROFILE profile | PASSWORD EXPIRE | ACCOUNT { LOCK | UNLOCK } |
example
CREATE USER user1 IDENTIFIED BY urs1754 TEMPORARY TABLESPACE TEMPTBS01 DEFAULT TABLESPACE user1ts
--ALTER USER
syntax
| DEFAULT ROLE { role [, role ]... | ALL [ EXCEPT role [, role ]... ] | NONE } | PASSWORD EXPIRE
| ACCOUNT { LOCK | UNLOCK } | ENABLE EDITIONS [ FOR object_type [, object_type ]... ] [ FORCE ]
--grant to users
sytax
example
www.usefzadeh.com
vahidusefzadeh@gmail.com
syntax
example
-- UNLOCK/LOCK
-- dropping user
--useful query:
---user qoutas
select name, round(sysdate-ptime) last_modify from sys.user$ where ltime is null order by name;
www.usefzadeh.com
vahidusefzadeh@gmail.com
syntax
example
idle_time 60 sessions_per_user 2;
syntax
example
syntax
example
--Managin Passwords
www.usefzadeh.com
vahidusefzadeh@gmail.com
ALTER PROFILE test_profile LIMIT PASSWORD_LIFE_TIME 30; -- in days (refere to profile section)
--password file
orapwd syntax
--other examples
REMOTE_OS_AUTHENT=TRUE
useradd usef
passwd usef
www.usefzadeh.com
vahidusefzadeh@gmail.com
su - usef
sqlplus /
--CREATE ROLE
syntax
CREATE ROLE role [ NOT IDENTIFIED | IDENTIFIED { BY password | USING [ schema. ] package | EXTERNALLY
| GLOBALLY } ] [ CONTAINER = { CURRENT | ALL } ];
example
--ALTER ROLE
ALTER ROLE role { NOT IDENTIFIED | IDENTIFIED { BY password | USING [ schema. ] package | EXTERNALLY
| GLOBALLY } } ;
example
-- disable role
VALUES('SQL*Plus','TESTER','ROLES','TEST123');
www.usefzadeh.com
vahidusefzadeh@gmail.com
-- enable role
-- Dropping a Role
Database Link
--Privileges required
syntax
example
syntax
example
www.usefzadeh.com
vahidusefzadeh@gmail.com
ALTER SHARED PUBLIC DATABASE LINK shared_pub_link CONNECT TO scott IDENTIFIED BY scott_new_password
AUTHENTICATED BY hr IDENTIFIED BY hr_new_password;
syntax
--view
CHARACTER SET
--changing character set
shutdown abort
or
Flashback
-- Flashback Table
www.usefzadeh.com
vahidusefzadeh@gmail.com
syntax
FLASHBACK TABLE [ schema. ] table [, [ schema. ] table ]... TO { { { SCN | TIMESTAMP } expr | RESTORE POINT
example
OR
MM-DD HH24:MI:SS');
OR
-- Flashback Drop
-- Flashback Database
-- Exepting a tablespace
www.usefzadeh.com
vahidusefzadeh@gmail.com
-- Flashback db in action
syntax
FLASHBACK [ STANDBY ] DATABASE [ database ] { TO { { SCN | TIMESTAMP } expr | RESTORE POINT restore_point
examples
STARTUP MOUNT;
RECOVER DATABASE;
-- current scn
-- Restore Points
syntax
example
www.usefzadeh.com
vahidusefzadeh@gmail.com
-- FLASHBACK:
-- flashback db status
PURGE RECYCLEBIN;
www.usefzadeh.com
vahidusefzadeh@gmail.com
AUDIT
syntax
example
CREATE AUDIT POLICY table_pol PRIVILEGES CREATE ANY TABLE, DROP ANY TABLE;
ALTER AUDIT POLICY dml_pol ADD PRIVILEGES CREATE ANY TABLE, DROP ANY TABLE;
ALTER AUDIT POLICY java_pol ADD ACTIONS CREATE JAVA, ALTER JAVA, DROP JAVA;
ALTER AUDIT POLICY security_pol ADD PRIVILEGES CREATE ANY LIBRARY, DROP ANY LIBRARY ACTIONS DELETE on
hr.employees, INSERT on hr.employees, UPDATE on hr.employees, ALL on hr.departments ROLES dba, connect;
syntax
example
audit session ;
www.usefzadeh.com
vahidusefzadeh@gmail.com
syntax
example
syntax
AUDIT { POLICY policy [ { BY user [, user]... } | { EXCEPT user [, user]... } ] [ WHENEVER [ NOT ] SUCCESSFUL ]
[, CONTEXT NAMESPACE namespace ATTRIBUTES attribute [, attribute ]... ]... [ BY user [, user]... ] } ;
syntax
NOAUDIT { POLICY policy | CONTEXT NAMESPACE namespace ATTRIBUTES attribute [, attribute ]...
[, CONTEXT NAMESPACE namespace ATTRIBUTES attribute [, attribute ]... ]... } [ BY user [, user]... ] ;
--Clear audit-Table
www.usefzadeh.com
vahidusefzadeh@gmail.com
----useful query
Parallel
syntax
--Parallel Query
--useful query
www.usefzadeh.com
vahidusefzadeh@gmail.com
--Parallel DML
--Parallel DDL
CREATE INDEX emp_ix ON emp (emp_id) TABLESPACE ind STORAGE (INITIAL 1M NEXT 1M PCTINCREASE 0
MAXEXTENTS 20) PARALLEL (DEGREE 4);
--Parallel Recovery
Large Objects
--BLOB CREATE
www.usefzadeh.com
vahidusefzadeh@gmail.com
example
CREATE TABLE blobtab ( recid NUMBER(5), blobcol BLOB) LOB (blobcol) STORE AS blobseg (TABLESPACE uwdata
STORAGE (INITIAL 1M) CHUNK 4096 NOCACHE NOLOGGING) TABLESPACE uwdata;
--CLOB CREATE
LOB_parameters [ storage_clause ]}]... <LOB_parameters> ::= [<ENABLE | DISABLE> STORAGE IN ROW] [CHUNK
<chunk_size>] [PCTVERSION <integer>] [RETENTION < MAX | MIN integer | AUTO | NONE>] [FREEPOOLS
example
CREATE TABLE clobtab ( recid NUMBER(5), clobcol CLOB) LOB (clobcol) STORE AS clobseg (TABLESPACE uwdata
--Cache Reads
CREATE TABLE cache_test (testlob BLOB) LOB (testlob) STORE AS (CACHE READS);
--Move LOB
ALTER TABLE lobtab MOVE LOB (lobcol) STORE AS (TABLESPACE example DISABLE STORAGE IN ROW);
www.usefzadeh.com
vahidusefzadeh@gmail.com
Partitioning
prof_history_id NUMBER(10),
prof_hist_comments VARCHAR2(2000))
PARTITIONS 3
first_name VARCHAR2(30),
last_name VARCHAR2(30))
www.usefzadeh.com
vahidusefzadeh@gmail.com
TABLESPACE uwdata;
ORDER BY 1, 2;
INSERT INTO interval_part (person_id, first_name, last_name) VALUES (101, 'Heli', 'Helskyaho');
INSERT INTO interval_part (person_id, first_name, last_name) VALUES (567, 'Tara', 'Havemeyer');
INSERT INTO interval_date (person_id, last_name, dob) VALUES (1, 'John', SYSDATE-365);
INSERT INTO interval_date (person_id, last_name, dob) VALUES (2, 'Lofstrom', SYSDATE-365);
INSERT INTO interval_date (person_id, last_name, dob) VALUES (3, 'Havemeyer', SYSDATE-200);
INSERT INTO interval_date (person_id, last_name, dob) VALUES (4, 'Catz', SYSDATE-60);
INSERT INTO interval_date (person_id, last_name, dob) VALUES (5, 'Ellison', SYSDATE+60);
SELECT partition_name, tablespace_name, high_value FROM user_tab_partitions WHERE table_name =
'INTERVAL_DATE';
www.usefzadeh.com
vahidusefzadeh@gmail.com
--Interval-Interval Range Partitioned Table with new partitions created every six months
--Interval-Interval Range Partitioned Table with new partitions created every hour using OLTP
compression
www.usefzadeh.com
vahidusefzadeh@gmail.com
www.usefzadeh.com
vahidusefzadeh@gmail.com
ALTER TABLE ref_parent ADD CONSTRAINT pk_ref_parent PRIMARY KEY (table_name) USING INDEX;
SELECT table_name, tablespace_name, partitioned FROM user_tables WHERE table_name = 'REF_PARENT';
SELECT partition_name, tablespace_name FROM user_tab_partitions WHERE table_name = 'REF_PARENT';
www.usefzadeh.com
vahidusefzadeh@gmail.com
PARTITION BY REFERENCE(fk_ref_child_parent);
--Partition by System
INSERT INTO json_orders (tx_id, tx_date, jsondata) VALUES (1, SYSDATE, '{"Seattle": 1, "siteId": 9}');
www.usefzadeh.com
vahidusefzadeh@gmail.com
INSERT INTO json_orders (tx_id, tx_date, jsondata) VALUES (2, SYSDATE, '{"New York": 2, "siteId": 11}');
SELECT * FROM json_orders;
SELECT * FROM json_orders PARTITION(p1);
SELECT * FROM json_orders PARTITION(p2);
INSERT INTO composite_rng_hash SELECT c.cust_id, c.cust_first_name || ' ' || c.cust_last_name, s.amount_sold,
s.time_id+5000 FROM sh.sales@orcl s, sh.customers@orcl c WHERE s.cust_id = c.cust_id AND rownum < 250001;
www.usefzadeh.com
vahidusefzadeh@gmail.com
cust_id NUMBER(10),
cust_name VARCHAR2(25),
cust_state VARCHAR2(2),
time_id DATE)
PARTITION BY RANGE(time_id)
SUBPARTITION TEMPLATE(
www.usefzadeh.com
vahidusefzadeh@gmail.com
cust_id NUMBER(10),
cust_name VARCHAR2(25),
cust_state VARCHAR2(2),
time_id DATE)
PARTITION BY RANGE(time_id)
SUBPARTITION TEMPLATE(
www.usefzadeh.com
vahidusefzadeh@gmail.com
CREATE TABLE t(
sequence_id NUMBER,
reservation_date DATE,
www.usefzadeh.com
vahidusefzadeh@gmail.com
location_code VARCHAR2(5))
PARTITION BY RANGE (reservation_date)
INTERVAL (NUMTOYMINTERVAL(1, 'MONTH'))
SUBPARTITION BY LIST(location_code)
SUBPARTITION TEMPLATE (
SUBPARTITION spart01 VALUES ('USA'),
SUBPARTITION spart02 VALUES ('IND'),
SUBPARTITION spart03 VALUES ('GER')) (
PARTITION root VALUES LESS THAN (TO_DATE('01-JAN-2015','DD-MON-YYYY')));
ALTER TABLE composite_rng_hash MOVE PARTITION sales_pre11 TABLESPACE uwdata UPDATE INDEXES;
--Moving Subpartitions
www.usefzadeh.com
vahidusefzadeh@gmail.com
ALTER TABLE composite_rng_hash MOVE SUBPARTITION sales_pre11_sp1 TABLESPACE uwdata PARALLEL (DEGREE
2);
SELECT DISTINCT 'ALTER TABLE ' || table_owner || '.' || table_name || ' MODIFY DEFAULT ATTRIBUTES
TABLESPACE newtbs;'
cust_id NUMBER(10),
channel_id NUMBER(3),
amount_sold NUMBER(10,2),
time_id DATE)
PARTITION BY RANGE(time_id)
SUBPARTITION BY LIST(channel_id)
SUBPARTITION TEMPLATE(
www.usefzadeh.com
vahidusefzadeh@gmail.com
(PARTITION sp10
PARTITION s11
PARTITION s12
PARTITION s13
PARTITION s14
PARTITION pm
ALTER TABLE range_list MERGE SUBPARTITIONS sp10_sp1, sp10_sp2 INTO SUBPARTITION spmin PARALLEL
(DEGREE 2) TABLESPACE part1;
ALTER TABLE <table_name> MODIFY DEFAULT ATTRIBUTES FOR PARTITION <partition_name> TABLESPACE
<tablespace_name>;
ALTER TABLE range_list MODIFY DEFAULT ATTRIBUTES FOR PARTITION s11 TABLESPACE part1;
www.usefzadeh.com
vahidusefzadeh@gmail.com
ALTER TABLE list_part MODIFY PARTITION q1_northcent ADD VALUES ('MI', 'OH');
www.usefzadeh.com
vahidusefzadeh@gmail.com
ALTER TABLE <table_name> EXCHANGE PARTITION <partition_name> WITH TABLE <new_table_name> <including
| excluding> INDEXES <with | without> VALIDATION EXCEPTIONS INTO <schema.table_name>;
ALTER TABLE list_part EXCHANGE PARTITION q1_northwest WITH TABLE q1_northwest INCLUDING INDEXES
WITHOUT VALIDATION EXCEPTIONS INTO USEF.problems;
ALTER TABLE <table_name> EXCHANGE PARTITION <partition_name> WITH TABLE <table_name> [INCLUDING
INDEXES <WITH | WITHOUT> VALIDATION];
rid NUMBER,
col1 VARCHAR2(10),
col2 VARCHAR2(100))
PARTITION BY RANGE(rid) (
rid NUMBER,
col1 VARCHAR2(10),
col2 VARCHAR2(100));
www.usefzadeh.com
vahidusefzadeh@gmail.com
INSERT /*+ APPEND ORDERED FULL(s1) USE_NL(s2) */ INTO new_part SELECT 3000 + TRUNC((rownum-1)/500,6),
TO_CHAR(rownum), RPAD('x',100)
set timing on
ALTER TABLE range_part EXCHANGE PARTITION pm WITH TABLE new_part WITHOUT VALIDATION;
ALTER TABLE range_part ADD CONSTRAINT pk_range_part PRIMARY KEY(rid) USING INDEX LOCAL;
ALTER TABLE new_part ADD CONSTRAINT pk_new_part PRIMARY KEY(rid) USING INDEX;
set timing on
ALTER TABLE range_part EXCHANGE PARTITION pm WITH TABLE new_part INCLUDING INDEXES WITHOUT
VALIDATION;
-- repeat again but this time do the following before the exchange
ALTER TABLE range_part EXCHANGE PARTITION pm WITH TABLE new_part INCLUDING INDEXES WITHOUT
VALIDATION;
www.usefzadeh.com
vahidusefzadeh@gmail.com
3 lname VARCHAR2(30),
4 dob DATE)
6 INTERVAL (NUMTOYMINTERVAL(1,'MONTH'))
7 STORE IN (uwdata) (
SQL> INSERT INTO interval_date (per_id, lname, dob) VALUES (0, 'Hurd', TO_DATE('31-DEC-2013'));
PNAME HIGH_VALUE
---------- ------------------------------------------------------------------------------------
SQL> ALTER TABLE interval_date EXCHANGE PARTITION p2 WITH TABLE interval_new WITHOUT VALIDATION;
ERROR at line 2:
www.usefzadeh.com
vahidusefzadeh@gmail.com
-- force creation of a partition with the correct high_value for the exchange
PNAME HIGH_VALUE
---------- ------------------------------------------------------------------------------------
SQL> ALTER TABLE interval_date EXCHANGE PARTITION SYS_P2614 WITH TABLE interval_new WITHOUT
VALIDATION;
--Rename a partition
--Split Partition
www.usefzadeh.com
vahidusefzadeh@gmail.com
COMMIT;
www.usefzadeh.com
vahidusefzadeh@gmail.com
product_id NUMBER(6),
ad_id NUMBER(6),
ad_composite BLOB,
ad_sourcetext CLOB,
ad_finaltext CLOB,
ad_fltextn NCLOB,
ad_textdocs_ntab TEXTDOC_TAB,
ad_photo BLOB,
ad_graphic BFILE,
ad_header ADHEADER_TYP)
ALTER TABLE print_media_part SPLIT PARTITION p2 AT (150) INTO ( PARTITION p2a TABLESPACE uwdata
ALTER TABLE <table_name> ADD PARTITION <new_partition_name> VALUES LESS THAN (MAXVALUE)
www.usefzadeh.com
vahidusefzadeh@gmail.com
ALTER TABLE print_media_part ADD PARTITION p3 VALUES LESS THAN (MAXVALUE) LOB (ad_photo,
ad_composite) STORE AS (TABLESPACE part3) LOB (ad_sourcetext, ad_finaltext) STORE AS (TABLESPACE part4);
--Index Partitions
ON <table_name> <column_name_list>;
www.usefzadeh.com
vahidusefzadeh@gmail.com
ON range_part (person_id)
LOCAL (
EXPLAIN PLAN FOR SELECT * FROM range_part WHERE record_date BETWEEN TO_DATE('01-JAN-1998') AND
TO_DATE('31-JAN-1998');
EXPLAIN PLAN FOR SELECT * FROM range_part WHERE record_date BETWEEN TO_DATE('01-JAN-1998') AND
TO_DATE('31-DEC-2000');
EXPLAIN PLAN FOR SELECT * FROM range_part WHERE record_date BETWEEN TO_DATE('01-JAN-1999') AND
TO_DATE('31-DEC-2002');
ON <table_name> <column_name_list>
www.usefzadeh.com
vahidusefzadeh@gmail.com
ON range_part (organization_id)
TABLESPACE part1,
TABLESPACE part2);
ALTER TABLE <table_name> MODIFY PARTITION <partition_name> REBUILD UNUSABLE LOCAL INDEXES;
ALTER TABLE range_part MODIFY PARTITION yr0 REBUILD UNUSABLE LOCAL INDEXES;
--Rebuild any unusable local index partitions associated with a hash partition at the specific
composite partitioned table subpartition level
www.usefzadeh.com
vahidusefzadeh@gmail.com
ALTER TABLE composite_rng_hash MODIFY SUBPARTITION sales_1999_sp4 REBUILD UNUSABLE LOCAL INDEXES;
TABLESPACE <new_tablespace_name>;
SELECT DISTINCT 'ALTER INDEX ' || index_owner || '.' || index_name || 'MODIFY DEFAULT ATTRIBUTES
TABLESPACE newtbs;'
--Drop Partition
www.usefzadeh.com
vahidusefzadeh@gmail.com
Autotrace
Syntax
--Trace Only
--Stop Tracing
www.usefzadeh.com
vahidusefzadeh@gmail.com
DBMS_REDEFINITION
--ABORT_REDEF_TABLE
dbms_redefinition.abort_redef_table(
uname IN VARCHAR2,
orig_table IN VARCHAR2,
int_table IN VARCHAR2,
part_name IN VARCHAR2 := NULL);
example
--CAN_REDEF_TABLE
dbms_redefinition.can_redef_table(
uname IN VARCHAR2,
tname IN VARCHAR2,
options_flag IN BINARY_INTEGER := 1,
part_name IN VARCHAR2 := NULL);
example
--COPY_TABLE_DEPENDENTS
Copies the dependant objects of the original table to the interim table.
dbms_redefinition.copy_table_dependents(
uname IN VARCHAR2,
orig_table IN VARCHAR2,
int_table IN VARCHAR2,
copy_indexes IN PLS_INTEGER := 1,
copy_triggers IN BOOLEAN := TRUE,
copy_constraints IN BOOLEAN := TRUE,
copy_privileges IN BOOLEAN := TRUE,
ignore_errors IN BOOLEAN := FALSE,
num_errors OUT PLS_INTEGER,
www.usefzadeh.com
vahidusefzadeh@gmail.com
example
--FINISH_REDEF_TABLE
dbms_redefinition.finish_redef_table(
uname IN VARCHAR2,
orig_table IN VARCHAR2,
int_table IN VARCHAR2,
part_name IN VARCHAR2 := NULL
dml_lock_timeout IN PLS_INTEGER := NULL,
continue_after_errors IN BOOLEAN := FALSE);
example
--REDEF_TABLE
dbms_redefinition.redef_table(
uname IN VARCHAR2,
tname IN VARCHAR2,
table_compression_type IN VARCHAR2 := NULL,
table_part_tablespace IN VARCHAR2 := NULL,
index_key_compression_type IN VARCHAR2 := NULL,
index_tablespace IN VARCHAR2 := NULL,
lob_compression_type IN VARCHAR2 := NULL,
lob_tablespace IN VARCHAR2 := NULL,
lob_store_as IN VARCHAR2 := NULL);
example
--REGISTER_DEPENDENT_OBJECT
www.usefzadeh.com
vahidusefzadeh@gmail.com
dbms_redefinition.register_dependent_object(
uname IN VARCHAR2, -- schema name
orig_table IN VARCHAR2, -- table to redefine
int_table IN VARCHAR2, -- interim table
dep_type IN PLS_INTEGER, -- type of dependent object
dep_owner IN VARCHAR2, -- owner of dependent object
dep_orig_name IN VARCHAR2, -- name of orig dependent object
dep_int_name IN VARCHAR2); -- name of interim dependent obj.
example
--START_REDEF_TABLE
dbms_redefinition.start_redef_table(
uname IN VARCHAR2, -- schema name
orig_table IN VARCHAR2, -- table to redefine
int_table IN VARCHAR2, -- interim table
col_mapping IN VARCHAR2 := NULL, -- column mapping
options_flag IN BINARY_INTEGER := 1, -- redefinition type
orderby_cols IN VARCHAR2 := NULL, -- order by col list ASC/DESC
part_name IN VARCHAR2 := NULL, -- partition name
copy_vpd_opt IN BINARY_INTEGER := 1, -- by default do not copy
continue_after_errors IN BOOLEAN := FALSE);
example
--SYNC_INTERIM_TABLE
dbms_redefinition.sync_interim_table(
uname IN VARCHAR2, -- schema name
orig_table IN VARCHAR2, -- original table
int_table IN VARCHAR2, -- interim table
part_name IN VARCHAR2 := NULL, -- partition name
continue_after_errors IN BOOLEAN := FALSE);
example
www.usefzadeh.com
vahidusefzadeh@gmail.com
--UNREGISTER_DEPENDENT_OBJECT
dbms_redefinition.unregister_dependent_object(
uname IN VARCHAR2,
orig_table IN VARCHAR2,
int_table IN VARCHAR2,
dep_type IN PLS_INTEGER,
dep_owner IN VARCHAR2,
dep_orig_name IN VARCHAR2,
dep_int_name IN VARCHAR2);
example
External Tables
--Create Table
TERMINATED BY '<terminator>' OPTIONALLY ENCLOSED BY '<character>' REJECT ROWS WITH ALL NULL FIELDS
MISSING FIELD VALUES ARE NULL (<column_name_list>))\ LOCATION ('<file_name>')) [PARALLEL] REJECT LIMIT
<UNLIMITED | integer>;
example 1
CREATE TABLE ext_tab1 (empno CHAR(4), ename CHAR(20), job CHAR(20), deptno CHAR(3))
www.usefzadeh.com
vahidusefzadeh@gmail.com
BADFILE ext:'bad_%a_%p.bad'
LOGFILE ext:'log_%a_%p.log'
(empno, ename, job, deptno)) LOCATION ('demo1.dat')) PARALLEL REJECT LIMIT 0 NOMONITORING;
example 1
Alter Table
--Access Parameters
www.usefzadeh.com
vahidusefzadeh@gmail.com
--Add Column
--Default Directory
--Drop Column
--Modify Column
--Parallel Access
--Project Column
--Reject Limit
--Rename To
--Set Unused
www.usefzadeh.com
vahidusefzadeh@gmail.com
www.usefzadeh.com
vahidusefzadeh@gmail.com
chapter 2
RAC
CRSCTL
www.usefzadeh.com
vahidusefzadeh@gmail.com
Use the crsctl add resource command to register a resource to be managed by Oracle Clusterware. A resource can
be an application process, a database, a service, a listener, and so on.
Syntax
crsctl add resource resource_name -type resource_type [-file file_path | -attr "attribute_name=attribute_value
,attribute_name=attribute_value,..."] [-i] [-f]
Examples
Example 1
START_DEPENDENCIES=hard(ora.net1.network)pullup(ora.net1.network), STOP_DEPENDENCIES=hard(ora.net1.network)"
Example 2
Example 3
www.usefzadeh.com
vahidusefzadeh@gmail.com
Example 4
Example 5
To register an Apache web server of the generic_application resource type using the PID_FILES attribute:
Example 6
Use the crsctl add type command to create a resource type in Oracle Clusterware.
Syntax
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
Use the crsctl add wallet command to create and add users to a wallet.
Syntax
crsctl add wallet -type wallet_type [-name name] [-user user_name -passwd]
Example
Use the crsctl check css command to check the status of Cluster Synchronization Services. This command
is most often used when Oracle Automatic Storage Management (Oracle ASM) is installed on the local
server.
Syntax
Example
Use the crsctl check evm command to check the status of the Event Manager.
Syntax
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
Use the crsctl delete resource command to remove resources from the Oracle Clusterware
configuration.
Syntax
Example
Use the crsctl delete type command to remove resource types from the Oracle Clusterware
configuration.
Syntax
Example
Use the crsctl delete wallet command to remove wallets or users from a wallet.
Syntax
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
Use the crsctl eval add resource command to predict the effects of adding a resource without making
changes to the system. This command may be useful to application administrators.
Syntax
Use the crsctl eval fail resource command to predict the consequences of a resource failing.
Syntax
Example
Use the crsctl eval modify resource command to predict the effects of modifying a resource without
making changes to the system.
Syntax
Use the crsctl eval relocate resource command to simulate relocating a resource without making
changes to the system.
www.usefzadeh.com
vahidusefzadeh@gmail.com
Syntax
crsctl eval relocate resource {resource_name | -all} {-s source_server |-w "filter"} [-n destination_server] [-f]
Use the crsctl eval start resource command to predict the effects of starting a resource without making
changes to the system.
Syntax
crsctl eval start resource {resource_name [...] | -w "filter" | -all} [-n server_name] [-f]
Use the crsctl eval stop resource command to predict the effects of stopping a resource without making
changes to the system.
Syntax
Use the crsctl get hostname command to retrieve the host name of the local server.
Syntax
Example
node2
www.usefzadeh.com
vahidusefzadeh@gmail.com
Use the crsctl getperm resource command to display the user and group permissions for the specified
resource.
Syntax
Example
Name: app.appvip
owner:root:rwx,pgrp:oinstall:rwx,other::r--
Name: app.appvip
rwx
Name: app.appvip
r--
Use the crsctl getperm type command to obtain permissions for a particular resource type.
Syntax
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
Use the crsctl modify resource command to modify the attributes of a particular resource in Oracle
Clusterware.
Syntax
Example
Use the crsctl modify type command to modify an existing resource type.
Syntax
Example
Use the crsctl modify wallet command to modify the password for a specific user in a specific wallet.
Syntax
crsctl modify wallet -type wallet_type [-name name] [-user user_name -passwd]
www.usefzadeh.com
vahidusefzadeh@gmail.com
Example
Use the crsctl query wallet command to query low-privileged users from a wallet.
Syntax
crsctl query wallet -type wallet_type [-name name] [-user user_name] [-all]
Example
Use the crsctl relocate resource command to relocate resources to another server in the cluster.
Syntax
crsctl relocate resource {resource_name | resource_name | -all -s source_server |-w "filter"} [-n
destination_server] [-k cid] [-env "env1=val1,env2=val2,..."] [-i] [-f]
Example
Use the crsctl restart resource command to restart idle resources in the cluster, instead of having to run
two commands to stop and start the resource.
Syntax
crsctl restart resource {resource_name [...] | -w "filter"} [-k cid] [-d did] [-env "env1=val1,env2=val2,..."] [-i] [-f]
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
Use the crsctl setperm resource command to set permissions for a particular resource.
Example
Use the crsctl setperm type command to set permissions resources of a particular resource type.
Syntax
crsctl setperm type resource_type_name {-u acl_string | -x acl_string |-o user_name | -g group_name}
Example
Use the crsctl start resource command to start many idle resources on a particular server in the cluster.
Syntax
crsctl start resource {resource_name [...] | -w "filter" | -all} [-n server_name | -s server_pool_names] [-k cid] [-d
did] [-env "env1=val1,env2=val2,..."] [-begin] [-end] [-i] [-f] [-l]
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
Use the crsctl status resource command to obtain the status and configuration information of many
particular resources.
Syntax
crsctl status resource resource_name [...] | -w "filter" [-p | -v] | [-f | -l | -g] [[-k cid | -n server_name] [ -e [-p | -v]]
[-d did]] | [-s -k cid [-d did]]
Examples
Use the crsctl status type command to obtain the configuration information of one or more particular
resource types.
Syntax
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
Syntax
crsctl stop resource {resource_name [...] | -w "filter" | -all} [-n server_name] [-k cid] [-d did] [-env
"env1=val1,env2=val2,..."] [-begin | -end] [-i] [-f] [-l]
Example
Syntax
Example
$ crsctl add category cat1 -attr "EXPRESSION='(CPU_COUNT > 2) AND (MEMORY_SIZE > 2048)'"
Use the crsctl add crs administrator command to add a user to the list of cluster administrators.
Syntax
Example
Use the crsctl add css votedisk command to add one or more voting files to the cluster on storage
devices other than an Oracle ASM disk group.
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
Example
Use the crsctl add policy command to add a configuration policy to the policy set.
Syntax
Example
Use the crsctl add serverpool command to add a server pool that is for hosting non-database resources
(such as application servers) to Oracle Clusterware.
Syntax
Example 1
Use the crsctl check cluster command on any node in the cluster to check the status of the Oracle
Clusterware stack.
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
Example
Use the crsctl check crs command to check the status of Oracle High Availability Services and the Oracle
Clusterware stack on the local server.
Syntax
Example
Use the crsctl check resource command to initiate the check action inside the application-specific agent
of a particular resource. Oracle Clusterware only provides output if something prevents the system from
issuing the check request, such as a bad resource name.
Syntax
crsctl check resource {resource_name [...] | -w "filter" } [-n node_name] [-k cardinality_id] [-d degree_id] }
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
Use the crsctl check ctss command to check the status of the Cluster Time Synchronization services.
Syntax
Example
or
Use the crsctl config crs command to display Oracle High Availability Services automatic startup
configuration.
Syntax
Example
Use the crsctl create policyset command to create a single policy set, in the form of a text file, that
reflects the server pool configuration. After you create a policy set, you can copy the contents of the
text file to create other policy sets.
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
Example
Syntax
Example
Use the crsctl delete crs administrator command to remove a user from the Oracle Clusterware
administrator list.
Syntax
Example
Use the crsctl delete css votedisk to remove a voting file from the Oracle Clusterware configuration.
Syntax
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
Use the crsctl delete node to remove a node from the cluster.
Syntax
Example
Use the crsctl delete policy command to delete a configuration policy from the policy set.
Syntax
Use the crsctl delete serverpool command to remove a server pool from the Oracle Clusterware
configuration.
Syntax
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
Use the crsctl disable crs command to prevent the automatic startup of Oracle High Availability Services
when the server boots.
Syntax
Example
Use the crsctl discover dhcp command to send DHCP discover packets on the network at the specified
port. If DHCP servers are present on the network, then they respond to the discovery message and the
command succeeds.
Syntax
Example
Use the crsctl enable crs command to enable automatic startup of Oracle High Availability Services when
the server boots.
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
Example
Use the crsctl eval activate policy command to predict the effects of activating a specific policy without
making changes to the system. This command may be useful to cluster administrators.
Syntax
crsctl eval activate policy policy_name [-f] [-admin [-l serverpools | resources | all] [-x] [-a]]
Use the crsctl eval add server command to simulate the addition of a server without making changes to
the system.
Syntax
crsctl eval add server server_name [-file file_path] | [-attr "attr_name=attr_value[,...]"] [-admin [-l level [-x] [-a]] [-
f]
Example
Use the crsctl eval add serverpool command to predict the effects of adding a server pool without
making changes to the system.
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
Use the crsctl eval delete server command to predict the effects of deleting a server without making
changes to the system.
Syntax
crsctl eval delete server server_name [-admin [-l level] [-x] [-a]] [-f]
Use the crsctl eval delete serverpool command to simulate the deletion of a server pool without making
changes to the system.
Syntax
crsctl eval delete serverpool server_pool_name [-admin [-l level] [-x] [-a]]
Use the crsctl eval modify serverpool command to predict the effects of modifying a server pool without
making changes to the system.
Syntax
Use the crsctl eval relocate server command to predict the effects of relocating a server to a different
server pool without making changes to the system.
Syntax
crsctl eval relocate server server_name -to server_pool_name [-f][-admin [-l level] [-x] [-a]]
www.usefzadeh.com
vahidusefzadeh@gmail.com
Use the crsctl get clientid dhcp command to display the client ID that the Oracle Clusterware agent uses
to obtain the IP addresses from the DHCP server for configured cluster resources. The VIP type is
required.
Syntax
crsctl get clientid dhcp -cluname cluster_name -viptype vip_type [-vip vip_res_name] [-n node_name]
Example
CRS-10007: stmjk0462clr-stmjk01-vip
Use the crsctl get cluster hubsize command to obtain the value of Hub Nodes in an Oracle Flex Cluster.
Syntax
Example
Use the crsctl get cluster mode command to ascertain whether the cluster is configured for Oracle Flex
Clusters or the current status.
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
Use the crsctl cpu equivalency command to obtain the value of the CPU_EQUIVALENCY server
configuration attribute.
Syntax
Use the crsctl get css command to obtain the value of a specific Cluster Synchronization Services
parameter.
Syntax
Example
Use the crsctl get css ipmiaddr command to get the address stored in the Oracle Local Registry of the
local Intelligent Platform Management Interface (IPMI) device.
Syntax
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
Use the crsctl get css leafmisscount command to obtain the amount of time (in seconds) that must pass
without any communication between a Leaf Node and the Hub Node to which it is attached, before the
connection is declared to be no longer active and the Leaf Node is removed from the cluster.
Syntax
Use the crsctl get node role command to obtain the configured node role of nodes in the cluster.
Syntax
Example
Use the crsctl get nodename command to obtain the name of the local node.
Syntax
Example
node2
Use the crsctl get resource use command to check the current setting value of
the RESOURCE_USE_ENABLED parameter.
www.usefzadeh.com
vahidusefzadeh@gmail.com
Syntax
Example
Use the crsctl get server label command to check the current setting value of the SERVER_LABEL server
attribute.
Syntax
Example
Use the crsctl getperm serverpool command to obtain permissions for a particular server pool.
Syntax
Example
NAME: sp1
owner:root:rwx,pgrp:root:r-x,other::r--
crsctl lsmodules
Use the crsctl lsmodules command to list the components of the modules that you can debug.
www.usefzadeh.com
vahidusefzadeh@gmail.com
Syntax
crsctl lsmodules {mdns | gpnp | css | crf | crs | ctss | evm | gipc}
Example
Use the crsctl modify category command to modify an existing server category.
Syntax
Example
Use the crsctl modify policy command to modify an existing configuration policy.
Syntax
Example
Use the crsctl modify policyset command to modify an existing policy set.
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
Example
Use the crsctl modify serverpool command to modify an existing server pool.
Syntax
Example
Use the crsctl pin css command to pin many specific nodes. Pinning a node means that the association of
a node name with a node number is fixed. If a node is not pinned, its node number may change if the
lease expires while it is down. The lease of a pinned node never expires.
Syntax
Example
Use the crsctl query crs administrator command to display the list of users with Oracle Clusterware
administrative privileges.
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
Example
Use the crsctl query crs activeversion command to display the active version and the configured patch
level of the Oracle Clusterware software running in the cluster. During a rolling upgrade, however, the
active version is not advanced until the upgrade is finished across the cluster, until which time the
cluster operates at the pre-upgrade version.
Syntax
Example
Use the crsctl query crs autostart command to obtain the values of the Oracle Clusterware automatic
resource start criteria.
Syntax
Example
'Autostart delay': 60
'Autostart servercount': 2
www.usefzadeh.com
vahidusefzadeh@gmail.com
Use the crsctl query crs releasepatch command to display the patch level which is updated in the Grid
home patch repository while patching a node. The patch level corresponds to only the local node in
which the command is executed. This command can be executed while the stack is not running.
Syntax
Example
Oracle Clusterware release patch level is [3180840333] and the complete list of
Use the crsctl query crs releaseversion command to display the version of the Oracle Clusterware
software stored in the binaries on the local node.
Syntax
Example
Oracle High Availablity Services release version on the local node is [11.2.0.2.0]
Use the crsctl query crs softwarepatch command to display the configured patch level of the installed
Oracle Clusterware.
Syntax
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
Use the crsctl query crs softwareversion command to display latest version of the software that has
been successfully started on the specified node.
Syntax
Example
Use the crsctl query css ipmiconfig command to determine whether Oracle Clusterware on the local
server has been configured to use IPMI for failure isolation. Note that this command detects the
presence of configuration data, but cannot not validate its correctness.
Syntax
Example
Or
Use the crsctl query css ipmiconfig command to determine the presence of the Intelligent Platform
Management Interface (IPMI) driver on the local system.
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
Example
Or
Use the crsctl query css votedisk command to display the voting files used by Cluster Synchronization
Services, the status of the voting files, and the location of the disks, whether they are stored on Oracle
ASM or elsewhere.
Syntax
Example
Use the crsctl query dns command to obtain a list of addresses returned by DNS lookup of the name
with the specified DNS server.
Syntax
crsctl query dns {-servers | -name name [-dnsserver DNS_server_address][-port port] [-attempts
number_of_attempts] [-timeout timeout_in_seconds] [-v]}
Example
stmjk07-vip.stmjk0462.foo.com
If you choose the -servers parameter, then the command returns output similar to the following:
www.usefzadeh.com
vahidusefzadeh@gmail.com
192.168.249.41
192.168.249.52
192.168.202.15
Use the crsctl query socket udp command to verify that a daemon can listen on specified address and
port.
Syntax
Examples
The first of the preceding two commands was not run as root, and in both commands no port was
specified, so CRSCTL assumed the default, 53, which is less than 1024. This condition necessitates
running the command as root.
Similar to the first two examples, the first of the preceding two commands was not run as root, and,
although a port number was specified, it is still less than 1024, which requires root privileges to run the
command.
www.usefzadeh.com
vahidusefzadeh@gmail.com
In this last example, a port number greater than 1024 is specified, so there is no need to run the
command as root:
Use the crsctl release dhcp command to send a DHCP lease release request to a specific client ID and
send release packets on the network to a specific port.
Syntax
Example
on port 67
Use the crsctl relocate resource command to relocate resources to another server in the cluster.
Syntax
crsctl relocate resource {resource_name [-k cid] | {resource_name | -all} -s source_server | -w "filter"} [-n
destination_server] [-env "env1=val1,env2=val2,..."] [-i] [-f]
Example
Use the crsctl relocate server command to relocate a server to a different server pool.
www.usefzadeh.com
vahidusefzadeh@gmail.com
Syntax
Example
Use the crsctl replace discoverystring command to replace the existing discovery string used to locate
voting files.
Syntax
Example
Use the crsctl replace votedisk command to move or replace the existing voting files. This command
creates voting files in the specified locations, either in Oracle ASM or some other storage option. Oracle
Clusterware copies existing voting file information into the new locations and removes the voting files
from the former locations.
Syntax
Example
Example 1
Example 2
www.usefzadeh.com
vahidusefzadeh@gmail.com
Use the crsctl request action command to perform a specific action on specific resource.
Syntax
crsctl request action action_name {-r resource_name [...] | -w "filter"} [-env "env1=val1,env2=val2,..."] [-i]
Example
Use the crsctl request dhcp command to send DHCP request packets on the network at the specified
port. If the DHCP server has an IP address it can provide, then it responds with the IP address for the
client ID.
Syntax
Example
Use the crsctl set cluster hubsize command to set the maximum number of Hub Nodes for an Oracle Flex
Cluster.
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
Example
Use the crsctl set cluster mode command to change a cluster to an Oracle Clusterware standard Cluster
or an Oracle Flex Cluster.
Syntax
Use the crsctl set cpu equivalency command to set a value for the CPU_EQUIVALENCY server
configuration attribute.
Syntax
Use the crsctl set crs autostart command to set the Oracle Clusterware automatic resource start criteria.
The autostart delay and minimum server count criteria delay Oracle Clusterware resource autostart until
one of the two conditions are met.
Syntax
Example
To ensure that Oracle Clusterware delays resource autostart for 60 seconds after the first
server in the cluster is ONLINE:
www.usefzadeh.com
vahidusefzadeh@gmail.com
To ensure that Oracle Clusterware waits for there to be at least two servers ONLINE before it
initiates resource autostart:
To ensure that Oracle Clusterware delays resource autostart until either of the previous two
conditions are met (in no particular order):
Use the crsctl set css command to set the value of a Cluster Synchronization Services parameter.
Syntax
Use the crsctl set css ipmiaddr command to store the address of the local Intelligent Platform
Management Interface (IPMI) device in the Oracle Local Registry.
Syntax
Example
Use the crsctl set css ipmiadmin command to store the login credentials of an Intelligent Platform
Management Interface (IPMI) administrator in the Oracle Local Registry.
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
Example
Use the crsctl set css leafmisscount command to specify, in seconds, the amount of time that must pass
without any communication between a Leaf Node and the Hub Node to which it is attached, before the
connection is declared to be no longer active and the Leaf Node is removed from the cluster.
Syntax
Example
Use the crsctl set node role command to set the role of a specific node in the cluster.
Syntax
Example
Use the crsctl set resource use command to set the value of the RESOURCE_USE_ENABLED server
configuration parameter for the server on which you run this command.
Syntax
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
Use the crsctl set server label command to set the configuration value of the SERVER_LABEL server
configuration attribute for the server on which you run this command.
Syntax
Example
Use the crsctl setperm serverpool command to set permissions for a particular server pool.
Syntax
crsctl setperm serverpool server_pool_name {-u acl_string | -x acl_string |-o user_name | -g group_name}
Example
Use the crsctl start cluster command on any node in the cluster to start the Oracle Clusterware stack.
Syntax
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
Use the crsctl start crs command to start Oracle High Availability Services on the local server.
Syntax
crsctl start crs [-excl [-nocrs] [-cssonly]] | [-wait | -waithas | -nowait] | [-noautostart]
Example
crsctl start ip
Use the crsctl start ip command to start a given IP name or IP address on a specified interface with a
specified subnet mask. Run this command on the server on which you want to start the IP.
Syntax
Example
The crsctl start rollingpatch command transitions Oracle Clusterware and Oracle ASM into rolling patch
mode. In this mode, the software tolerates nodes having different patch levels.
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
The crsctl start rollingupgrade command transitions Oracle Clusterware and Oracle ASM into rolling
upgrade mode.
Syntax
Use the crsctl start testdns command to start a test DNS server that will listen on a specified IP address
and port. The test DNS server does not respond to incoming packets but does display the packets it
receives. Typically, use this command to check if domain forwarding is set up correctly for the GNS
domain.
Syntax
Example
Use the crsctl status category command to obtain information about a server category.
Syntax
crsctl status category {category_name [category_name [...]] | [-w "filter" | -server server_name]}
Examples
NAME=my_category_i
ACL=owner:mjkeenan:rwx,pgrp:svrtech:rwx,other::r--
www.usefzadeh.com
vahidusefzadeh@gmail.com
ACTIVE_CSS_ROLE = hub
EXPRESSION=(CPU_COUNT > 3)
NAME=my_category
ACL=owner:mjkeenan:rwx,pgrp:svrtech:rwx,other::r--
ACTIVE_CSS_ROLE = hub
EXPRESSION=
crsctl status ip
Use the crsctl status ip command to check if a given IP address is up on the network.
Syntax
Example
Use the crsctl status policy command to view the status and definition of a configuration policy.
Syntax
Use the crsctl status policyset command to view the current policies in the policy set, including the
access control list, which governs who can modify the set, the last activated policy, and the
configuration which is now in effect, which is known as the Current policy.
www.usefzadeh.com
vahidusefzadeh@gmail.com
Syntax
Use the crsctl status server command to obtain the status and configuration information of one or more
particular servers.
Syntax
crsctl status server {server_name [...] | -w "filter"} [-g | -p | -v | -f] | [-category category_name | -w "filter"]
Example
NAME=node2
STATE=ONLINE
ACTIVE_POOLS=Generic ora.usefdb
STATE_DETAILS=
Use the crsctl status serverpool command to obtain the status and configuration information of one or
more particular server pools.
Syntax
crsctl status serverpool [server_pool_name [...] | -w "filter"] [-p | -v | -f]crsctl status serverpool
{[server_pool_name [...]} -g
Examples
Example 1
www.usefzadeh.com
vahidusefzadeh@gmail.com
NAME=spl
IMPORTANCE=1
MIN_SIZE=0
MAX_SIZE=-1
PARENT_POOLS=Generic
EXCLUSIVE_POOLS=
ACL=owner:oracle:rwx,pgrp:oinstall:rwx,other::r--
ACTIVE_SERVERS=node3 node4
Example 2
To display all the server pools and the servers associated with them, use the following command:
NAME=Free
ACTIVE_SERVERS=
NAME=Generic
ACTIVE_SERVERS=node1 node2
NAME=ora.usefdb
ACTIVE_SERVERS=node1 node2
NAME=sp1
ACTIVE_SERVERS=node3 node4
Example 3
To find a server pool that meets certain criteria, use the following command:
NAME=sp2
ACTIVE_SERVERS=node3 node4
www.usefzadeh.com
vahidusefzadeh@gmail.com
Use the crsctl status testdns command to query the test DNS server running on a specified address and
local host name.
Syntax
Example
stmjk07-vip.stmjk0462.foo.com
Use the crsctl stop cluster command on any node in the cluster to stop the Oracle Clusterware stack on
all servers in the cluster or specific servers.
Syntax
Example
Use the crsctl stop crs command to stop Oracle High Availability Services on the local server.
Syntax
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
crsctl stop ip
Use the crsctl stop ip command to stop a given IP name or IP address on a specified interface with a
specified subnet mask. Run this command on the server on which you want to stop the IP.
Syntax
Example
The crsctl stop rollingpatch command transitions Oracle Clusterware and Oracle ASM out of rolling patch
mode. Once transitioned out of rolling patch mode, the software does not tolerate nodes having
different patch levels.
Syntax
Use the crsctl stop testdns command to stop a test DNS server.
Syntax
crsctl stop testdns [-address address [-port port]] [-domain GNS_domain] [-v]
Example
local node
www.usefzadeh.com
vahidusefzadeh@gmail.com
Use the crsctl unpin css command to unpin many servers. If a node is not pinned, its node number may
change if the lease expires while it is down.
Syntax
Example
Use the crsctl unset css command to unset the value of a Cluster Synchronization Services parameter
and restore it to its default value.
Syntax
Example
Use the crsctl unset css ipmiconfig command to clear all previously stored IPMI configuration (login
credentials and IP address) from the Oracle Local Registry. This is appropriate when deconfiguring IPMI
in your cluster or if IPMI configuration was previously stored by the wrong user.
Syntax
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
Use the crsctl unset css leafmisscount command to clear the amount of time that passes before the
grace time begins after communication fails between a Hub Node and a Leaf Node and reset to the
default.
Syntax
Use the crsctl check has command to check the status of ohasd.
Syntax
Example
Use the crsctl check has command to display the automatic startup configuration of the Oracle High
Availability Services stack on the server.
Syntax
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
Use the crsctl disable has command to disable automatic startup of the Oracle High Availability Services
stack when the server boots up.
Syntax
Example
Use the crsctl enable has command to enable automatic startup of the Oracle High Availability Services
stack when the server boots up.
Syntax
Example
Use the crsctl query has releaseversion command to display the release version of the Oracle
Clusterware software that is stored in the binaries on the local node.
Syntax
Example
Oracle High Availability Services release version on the local node is [11.2.0.0.2]
www.usefzadeh.com
vahidusefzadeh@gmail.com
Use the crsctl query has softwareversion command to display the software version on the local node.
Syntax
Example
Use the crsctl start has command to start Oracle High Availability Services on the local server.
Syntax
Example
Use the crsctl stop has command to stop Oracle High Availability Services on the local server.
Syntax
Example
Use the crsctl set log command to set log levels for Oracle Clusterware.
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
You can also set log levels for the agents of specific resources, as follows:
Examples
OCRCONFIG
ocrconfig -add
Use the ocrconfig -add command to add an OCR location to a shared file system or Oracle Automatic
Storage Management (Oracle ASM) disk group. OCR locations that you add must exist, have sufficient
permissions, and, in the case of Oracle ASM disk groups, must be mounted before you can add them.
Syntax
Example
ocrconfig -backuploc
Use the ocrconfig -backuploc command to specify an OCR backup directory location.
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
Example
ocrconfig -delete
Syntax
Example
ocrconfig -downgrade
Use the ocrconfig -downgrade command to downgrade OCR to an earlier specified version.
Syntax
Example
ocrconfig -export
Use the ocrconfig -export command to export the contents of OCR to a target file.
Syntax
Example
ocrconfig -import
www.usefzadeh.com
vahidusefzadeh@gmail.com
Use the ocrconfig -import command to import the contents of a target file into which you exported the
contents of OCR back into OCR.
Syntax
Example
ocrconfig -manualbackup
Use the ocrconfig -manualbackup command to back up OCR on demand in the location you specify with
the -backuploc option.
Syntax
Example
# ocrconfig -manualbackup
ocrconfig -overwrite
Use the ocrconfig -overwrite command to overwrite an OCR configuration in the OCR metadata with the
current OCR configuration information that is found on the node from which you run this command.
Syntax
ocrconfig -overwrite
Example
# ocrconfig -overwrite
ocrconfig -repair
Use the ocrconfig -repair command to repair an OCR configuration on the node from which you run this
command. Use this command to add, delete, or replace an OCR location on a node that may have been
stopped while you made changes to the OCR configuration in the cluster. OCR locations that you add
www.usefzadeh.com
vahidusefzadeh@gmail.com
must exist, have sufficient permissions, and, in the case of Oracle ASM disk groups, must be mounted
before you can add them.
Syntax
ocrconfig -repair -add file_name | -delete file_name | -replace current_file_name -replacement new_file_name
Example
ocrconfig -replace
Use the ocrconfig -replace command to replace an OCR device or file on the node from which you run
this command. OCR locations that you add must exist, have sufficient permissions, and, in the case of
Oracle ASM disk groups, must be mounted before you can add them.
Syntax
Example
ocrconfig -restore
Use the ocrconfig -restore command to restore OCR from an automatically created OCR backup file.
Syntax
Example
ocrconfig -showbackup
Use the ocrconfig -showbackup command to display the backup location, timestamp, and the originating
node name of the backup files. By default, this command displays information for both automatic and
manual backups unless you specify auto or manual.
www.usefzadeh.com
vahidusefzadeh@gmail.com
Syntax
Example
ocrconfig -upgrade
Only root scripts use the ocrconfig -upgrade command to upgrade OCR from a previous version.
cluvfy
Use the cluvfy comp acfs component verification command to check the integrity of Oracle Automatic
Storage Management Cluster File System (Oracle ACFS) on all nodes in a cluster.
Syntax
Use the cluvfy comp admprv command to verify user accounts and administrative permissions for
installing Oracle Clusterware and Oracle RAC software, and for creating an Oracle RAC database or
modifying an Oracle RAC database configuration.
Syntax
cluvfy comp admprv [-n node_list] { -o user_equiv [-sshonly] | -o crs_inst [-orainv orainventory_group] |
Examples
www.usefzadeh.com
vahidusefzadeh@gmail.com
Use the cluvfy comp asm component verification command to check the integrity of Oracle Automatic
Storage Management (Oracle ASM) on all nodes in the cluster. This check ensures that the Oracle ASM
instances on the specified nodes are running from the same Oracle home and that asmlib, if it exists, has
a valid version and ownership.
Syntax
Examples
Use the cluvfy comp baseline command to capture system and cluster configuration information to
create a baseline. You can use this baseline for comparison with the state of the system. You can collect
baselines at strategic times, such as after Oracle Clusterware installation, before and after upgrading
Oracle Clusterware, or automatically as part of periodic execution of CVU running as an Oracle
Clusterware resource. You can also compare several baselines.
Syntax
cluvfy comp baseline -collect {all | cluster | database} [-n node_list] [-db db_unique_name] [-bestpractice | -
mandatory] [-binlibfilesonly [-reportname report_name] [-savedir save_dir]]
Examples
www.usefzadeh.com
vahidusefzadeh@gmail.com
$ cluvfy comp baseline -collect all -n all -db usefdb -bestpractice -report bl1 -savedir /tmp
Use the cluvfy comp cfs component verification command to check the integrity of the clustered file
system (OCFS2) you provide using the -f option. CVU checks the sharing of the file system from the
nodes in the node list.
Syntax
Examples
Use the cluvfy comp clocksync component verification command to clock synchronization across all the
nodes in the node list. CVU verifies a time synchronization service is running (Oracle Cluster Time
Synchronization Service (CTSS) or Network Time Protocol (NTP)), that each node is using the same
reference server for clock synchronization, and that the time offset for each node is within permissible
limits.
Syntax
Use the cluvfy comp clu component verification command to check the integrity of the cluster on all the
nodes in the node list.
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
Example
Use the cluvfy comp clumgr component verification command to check the integrity of cluster manager
subcomponent, or Oracle Cluster Synchronization Services (CSS), on all the nodes in the node list.
Syntax
Run the cluvfy comp crs component verification command to check the integrity of the Cluster Ready
Services (CRS) daemon on the specified nodes.
Syntax
Use the cluvfy comp dhcp component verification command to verify that the DHCP server exists on the
network and can provide a required number of IP addresses. This verification also verifies the response
time for the DHCP server. You must run this command as root.
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
Use the cluvfy comp dns component verification command to verify that the Grid Naming Service (GNS)
subdomain delegation has been properly set up in the Domain Name Service (DNS) server.
Syntax
cluvfy comp dns -server -domain gns_sub_domain -vipaddress gns_vip_address] [-port dns_port] [-method {sudo |
root}] [-location directory_path] [-user user_name][-verbose] cluvfy comp dns -client -domain gns_sub_domain -
vip gns_vip [-method {sudo | root}] [-location directory_path] [-user user_name [-port dns_port] [-last] [-verbose]
Use the cluvfy comp freespace component verification command to check the free space available in the
Oracle Clusterware home storage and ensure that there is at least 5% of the total space available. For
example, if the total storage is 10GB, then the check ensures that at least 500MB of it is free.
Syntax
Use the cluvfy comp gns component verification command to verify the integrity of the Grid Naming
Service (GNS) on the cluster.
Syntax
cluvfy comp gns -precrsinst -domain gns_domain -vip gns_vip [-n node_list] [-verbose]cluvfy comp gns -postcrsinst
[-verbose]
Use the cluvfy comp gpnp component verification command to check the integrity of Grid Plug and Play
on all of the nodes in a cluster.
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
cluvfy comp ha
Use the cluvfy comp ha component verification command to check the integrity of Oracle Restart on the
local node.
Syntax
Use the cluvfy comp healthcheck component verification command to check your Oracle Clusterware
and Oracle Database installations for their compliance with mandatory requirements and best practices
guidelines, and to ensure that they are functioning properly.
Syntax
Use the component cluvfy comp nodeapp command to check for the existence of node applications,
namely VIP, NETWORK, and ONS, on all of the specified nodes.
Syntax
Use the cluvfy comp nodecon component verification command to check the connectivity among the
nodes specified in the node list. If you provide an interface list, then CVU checks the connectivity using
only the specified interfaces.
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
Example
Use the cluvfy comp nodereach component verification command to check the reachability of specified
nodes from a source node.
Syntax
Example
Use the cluvfy comp ocr component verification command to check the integrity of Oracle Cluster
Registry (OCR) on all the specified nodes.
Syntax
Example
Use the cluvfy comp ohasd component verification command to check the integrity of the Oracle High
Availability Services daemon.
www.usefzadeh.com
vahidusefzadeh@gmail.com
Syntax
Example
Use the cluvfy comp olr component verification command to check the integrity of Oracle Local Registry
(OLR) on the local node.
Syntax
Example
Use the cluvfy comp peer component verification command to check the compatibility and properties of
the specified nodes against a reference node. You can check compatibility for non-default user group
names and for different releases of the Oracle software. This command compares physical attributes,
such as memory and swap space, and user and group values, kernel settings, and installed operating
system packages.
Syntax
cluvfy comp peer -n node_list [-refnode node] [-r {10gR1 | 10gR2 | 11gR1 | 11gR2}] [-orainv orainventory_group]
[-osdba osdba_group] [-verbose]
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
Use the cluvfy comp scan component verification command to check the Single Client Access Name
(SCAN) configuration.
Syntax
Example
Use the cluvfy comp software component verification command to check the files and attributes
installed with the Oracle software.
Syntax
cluvfy comp software [-n node_list] [-d oracle_home] [-r {10.1 | 10.2 | 11.1 | 11.2 | 12.1}] [-verbose]
Example
Use the cluvfy comp space component verification command to check for free disk space at the location
you specify in the -l option on all the specified nodes.
Syntax
Examples
www.usefzadeh.com
vahidusefzadeh@gmail.com
Use the cluvfy comp ssa component verification command to discover and check the sharing of the
specified storage locations. CVU checks sharing for nodes in the node list.
Syntax
cluvfy comp ssa [-n node_list | -flex -hub hub_list [-leaf leaf_list]][-s storageID_list] [-t {software | data |
ocr_vdisk}] [-asm [-asmdev asm_device_list]][-r {10.1 | 10.2 | 11.1 | 11.2 | 12.1}] [-verbose]
Example
Use the cluvfy comp sys component verification command to check that the minimum system
requirements are met for the specified product on all the specified nodes.
Syntax
cluvfy comp sys [-n node_list] -p {crs | ha | database} [-r {10gR1 | 10gR2 | 11gR1 | 11gR2}] [-osdba osdba_group]
[-orainv orainventory_group] [-fixup] [-verbose]
Examples
Use the cluvfy comp vdisk component verification command to check the voting files configuration and
the udev settings for the voting files on all the specified nodes.
Syntax
Use the cluvfy stage -pre acfscfg command to verify your cluster nodes are set up correctly before
configuring Oracle Automatic Storage Management Cluster File System (Oracle ACFS).Use the cluvfy
stage -post acfscfg to check an existing cluster after you configure Oracle ACFS.
www.usefzadeh.com
vahidusefzadeh@gmail.com
Syntax
Use the cluvfy stage -pre cfs stage verification command to verify your cluster nodes are set up correctly
before setting up OCFS2.Use the cluvfy stage -post cfs stage verification command to perform the
appropriate checks on the specified nodes after setting up OCFS2.
Syntax
Example
Use the cluvfy stage -pre crsinst command to check the specified nodes before installing Oracle
Clusterware. CVU performs additional checks on OCR and voting files if you specify the -c and -q options.
Use the cluvfy stage -post crsinst command to check the specified nodes after installing Oracle
Clusterware.
Syntax
cluvfy stage -pre crsinst -n node_list [-r {10.1 | 10.2 | 11.1 | 11.2 | 12.1}] [-c ocr_location_list] [-q voting_disk_list]
[-osdba osdba_group] [-orainv orainventory_group] [-asm [-asmgrp asmadmin_group] [-asmdev asm_device_list]]
[-crshome Grid_home] [-fixup] [-networks network_list] [-verbose]]
www.usefzadeh.com
vahidusefzadeh@gmail.com
Use the cluvfy stage -pre dbcfg command to check the specified nodes before configuring an Oracle RAC
database to verify whether your system meets all of the criteria for creating a database or for making a
database configuration change.
Syntax
Use the cluvfy stage -pre dbinst command to check the specified nodes before installing or creating an
Oracle RAC database to verify that your system meets all of the criteria for installing or creating an
Oracle RAC database.
Syntax
cluvfy stage -pre dbinst -n node_list [-r {10gR1 | 10gR2 | 11gR1 | 11gR2}][-osdba osdba_group] [-d Oracle_home]
[-fixup] [-serviceuser user_name [-servicepwd]][-verbose]
Use the cluvfy stage -pre hacfg command to check a local node before configuring Oracle Restart.
Use the cluvfy stage -post hacfg command to check the local node after configuring Oracle Restart.
Syntax
Use the cluvfy stage -post hwos stage verification command to perform network and storage
verifications on the specified nodes in the cluster before installing Oracle software. This command also
checks for supported storage types and checks each one for sharing.
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
Use the cluvfy stage -pre nodeadd command to verify the specified nodes are configured correctly
before adding them to your existing cluster, and to verify the integrity of the cluster before you add the
nodes.
This command verifies that the system configuration, such as the operating system version, software
patches, packages, and kernel parameters, for the nodes that you want to add, is compatible with the
existing cluster nodes, and that the clusterware is successfully operating on the existing nodes. Run this
node on any node of the existing cluster.
Use the cluvfy stage -post nodeadd command to verify that the specified nodes have been successfully
added to the cluster at the network, shared storage, and clusterware levels.
Syntax
Use the cluvfy stage -post nodedel command to verify that specific nodes have been successfully deleted
from a cluster. Typically, this command verifies that the node-specific interface configuration details
have been removed, the nodes are no longer a part of cluster configuration, and proper Oracle ASM
cleanup has been performed.
Syntax
OIFCFG
The Oracle Interface Configuration Tool (OIFCFG) command-line interface helps you to define and
administer network interfaces. You can use OIFCFG commands Oracle Clusterware environments to:
www.usefzadeh.com
vahidusefzadeh@gmail.com
Syntax
oifcfg [-help]
Examples
$ oifcfg iflist
$ oifcfg getif
OLSNODES
The olsnodes command provides the list of nodes and other information for all nodes participating in
the cluster. You can use this command to quickly check that your cluster is operational, and all nodes are
registered as members of the cluster. This command also provides an easy method for obtaining the
node numbers.
Syntax
olsnodes [[-n] [-i] [-s] [-t] [node_name | -l [-p]] | [-c]] [-a] [-g] [-v]
Examples
Example 1: List the VIP addresses for all nodes currently in the cluster
[root@node1]# olsnodes -i
Example 2: List the node names and node numbers for cluster members
[root@node1]# olsnodes -n
www.usefzadeh.com
vahidusefzadeh@gmail.com
[root@node1]# olsnodes -a
SRVCTL
add
The srvctl add command adds the configuration and the Oracle Clusterware applications to OCR for the
cluster database, named instances, named services, or for the named nodes. To perform srvctl
add operations, you must be logged in as the database administrator and be the Oracle account owner
on Linux and UNIX systems, or you must be logged on as a user with Administrator privileges on
Windows systems.
When adding an instance, the name that you specify with -instance must match
the ORACLE_SID parameter. The database name given with -database db_unique_name must match
the DB_UNIQUE_NAME initialization parameter setting. If DB_UNIQUE_NAME is unspecified, then
match the DB_NAME initialization parameter setting. The default setting for DB_UNIQUE_NAME uses
the setting for DB_NAME. Also, the domain name given with -domain db_domain must match
theDB_DOMAIN setting.
Adds a record for an Oracle ASM instance to the entire cluster. This command must be run only one
time from the Oracle Grid Infrastructure home.
Syntax
srvctl add asm [-listener listener_name] [-pwfile password_file_path [-remote [-count {number_of_instances |
ALL}] | -proxy]
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
Syntax
Examples
Syntax
srvctl add database -db db_unique_name [-eval] -oraclehome oracle_home [-node node_name] [-domain
domain_name] [-spfile spfile] [-pwfile password_file_path] [-dbtype {RACONENODE | RAC | SINGLE} [-server
"server_list"] [-instance instance_name] [-timeout timeout]] [-role {PRIMARY | PHYSICAL_STANDBY |
LOGICAL_STANDBY | SNAPSHOT_STANDBY"] [-startoption start_options] [-stopoption stop_options] [-dbname
db_name] [-acfspath "acfs_path_list"] [-policy {AUTOMATIC | MANUAL | NORESTART}] [-serverpool
"server_pool_list" [-pqpool "pq_pool_list"]] [-diskgroup "disk_group_list"] [-verbose]
Examples
srvctl add database -db crm -oraclehome /u01/oracle/product/12c/mydb -domain example.com -spfile
Syntax
srvctl add exportfs -name unique_name -id havip_name -path path_to_export [-clients nfs_client_string] [-
options nfs_client_string]
www.usefzadeh.com
vahidusefzadeh@gmail.com
Example
Adds a device containing a file system (Oracle ACFS or other) to the Oracle Clusterware stack for
automount and high availability. This command must be run only one time from the Oracle Grid
Infrastructure home.
An Oracle ACFS file system resource is typically created for use with application resource dependency
lists. For example, if an Oracle ACFS file system is configured for use as an Oracle Database home, then a
resource created for the file system can be included in the resource dependency list of the Oracle
Database application. This will cause the file system and stack to be automatically mounted because of
the start action of the database application.
To manage Oracle ACFS on Oracle Database 12c installations, use the SRVCTL binary in the Oracle Grid
Infrastructure home for a cluster (Grid home). If you have Oracle RAC or Oracle Database installed, then
you cannot use the SRVCTL binary in the database home to manage Oracle ACFS.
Syntax
Example
To add an Oracle ACFS file system on the dynamic volume device asm-test-55, with this file system
mounted on one of the specified nodes at a time:
# srvctl add filesystem -fstype ACFS -device asm-test-55 -mountpath myacfs -nodes node1,node2,node3
www.usefzadeh.com
vahidusefzadeh@gmail.com
Use this command to add the Grid Naming Service (GNS) to a cluster when you are using a DHCP public
network or to create a client cluster.
Syntax
To change a cluster that is not running GNS to be a client cluster of another cluster that is running GNS:
Examples
Adds highly available VIPs (HAVIPs) (used for highly available NFS exports) to a cluster.
Syntax
srvctl add havip -id havip_name {-address {host_name | ip_address} [-netnum network_number]}
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
You can only use this command for administrator-managed databases. If you have a policy-managed
database, then use the srvctl modify srvpoolcommand to add an instance to increase either the
maximum size, minimum size, or both, of the server pool used by the database.
Syntax
srvctl add instance -db db_unique_name -instance instance_name -node node_name [-force]
Examples
Syntax
srvctl add listener [-listener listener_name] [-netnum network_number] [-oraclehome Oracle_home] -user
www.usefzadeh.com
vahidusefzadeh@gmail.com
Example
The following command adds a listener named listener112 that is listening on ports 1341, 1342, and
1345 and runs from the Oracle home directory on every node in the cluster:
Syntax
Example
Syntax
Example
The following command adds a management listener that is listening on port 1341 to the cluster:
Adds a static or dynamic network. If your server connects to more than one network, then you can use
this command to configure an additional network interface for Oracle RAC, allowing you to create VIPs
www.usefzadeh.com
vahidusefzadeh@gmail.com
on multiple public networks. You can also use the LISTENER_NETWORKS database initialization
parameter to control client redirects to the appropriate network
Syntax
srvctl add network [-netnum net_number] -subnet subnet/netmask[/if1[|if2|...]] [-nettype {static | dhcp |
autoconfig | mixed}] [-leaf] [-verbose]
Example
Syntax
srvctl add nodeapps {-node node_name -address {vip_name | ip_address}/netmask[/if1[|if2|..]] [-skip]} [-emport
em_port] [-onslocalport ons_local_port] [-onsremoteport ons_remote_port] [-onshostport hostname_port_list]
[-remoteservers hostname_port_list [-verbose]
Example
Syntax
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
Note:
Syntax
srvctl add ons [-l ons_local_port] [-r ons_remote_port] [-t host[:port][,host[:port]][...]] [-v]
Example
Adds Oracle Clusterware resources for the given SCAN. This command creates the same number of
SCAN VIP resources as the number of IP addresses that SCAN resolves to, or 3
when network_number identifies a dynamic network and Oracle GNS configuration. For static networks,
the addresses to which the SCAN resolves in DNS must match the address type of the subnet. For an
IPv4 network, the SCAN must resolve to IPv4 addresses.
Syntax
Example
Adds Oracle Clusterware resources for the SCAN listeners. The number of SCAN listener resources
created is the number of SCAN VIP resources.
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
Example
Adds services to a database and assigns them to instances. If you have multiple instances of a cluster
database on the same node, then always use only one instance on that node for all of the services that
node manages.
Note:
The srvctl add service command does not accept placement parameters for Oracle RAC One Node
databases.
Syntax
policy {AUTOMATIC | MANUAL}] [-notification {TRUE | FALSE}] [-clbgoal {SHORT | LONG}] [-failovertype
force]
www.usefzadeh.com
vahidusefzadeh@gmail.com
srvctl add service -database db_unique_name -service service_name [-eval] -preferred preferred_list -available
force] [-verbose]
srvctl add service -db db_unique_name -service service_name -newinst {-prefered preferred_list | -available
Examples
Use this example syntax to add the gl.example.com service to the my_rac database with Fast Application
Notification enabled for OCI connections, a failover method of BASIC, a Connection Load Balancing Goal
of LONG, a failover type of SELECT, and 180 failover retries with a failover delay of 5 seconds:
srvctl add service -db my_rac -service gl.example.com -notification TRUE \ -failovermethod BASIC -failovertype
SELECT -failoverretry 180 -failoverdelay 5 \ -clbgoal LONG
Use this example syntax to add a named service to a database with preferred instances and available
instances and enabled for TAF:
srvctl add service -db crm -service sales -preferred crm01,crm02 -available crm03\ -tafpolicy BASIC
www.usefzadeh.com
vahidusefzadeh@gmail.com
Syntax
srvctl add srvpool -serverpool server_pool_name [-eval] [-importance importance] [-min min_size] [-max
max_size] [-servers "node_list" | -category server_category] [-force] [-verbose]
Example
Syntax
srvctl add vip -node node_name -address {VIP_name|ip}/netmask[/if1[|if2|...]] -netnum network_number [-skip]
[-verbose]
Example
config
The srvctl config command displays the configuration stored in the Oracle Clusterware resource
attributes.
Note:
If you disabled an object for which you are trying to obtain configuration information using the srvctl
disable object -nnode_name command, then remember that using the srvctl disable object -
n node_name command on a per-node basis in your cluster to disable an object throughout the
cluster is different from globally disabling an object using the srvctl disableobject command without
the -n parameter. In the former case, the srvctl config object command may report that the object is still
enabled.
www.usefzadeh.com
vahidusefzadeh@gmail.com
Syntax
Example
Displays the configuration for an Oracle RAC database or lists all configured databases that are
registered with Oracle Clusterware.
Syntax
Example
Syntax
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
Syntax
Examples
To list the configuration of all file systems, use the following example:
To show the configuration for a specific device, use the following example:
Note:
Syntax
srvctl config gns [-subdomain] [-multicastport] [-node node_name] [-port] [-status] [-version] [-query name] [-list]
[-clusterguid] [-clustername] [-clustertype] [-loglevel] [-network] [-detail]
Displays configuration information for a specific highly available VIP (HAVIP) (used for highly available
NFS exports) or all HAVIP resources in a cluster.
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
Example
VIP: /mjk-vm3-vip/10.149.237.196/10.149.236.0/255.255.252.0/eth0
Description: HR Exports
Displays configuration information of a specific listener that is registered with Oracle Clusterware.
Syntax
Displays configuration information for the management database (CHM repository) resource.
Syntax
Displays configuration information for the management listener resource (for CHM).
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
Syntax
Example
Syntax
Example
Note:
www.usefzadeh.com
vahidusefzadeh@gmail.com
Displays the configuration information for all SCAN VIPs, by default, or a specific SCAN VIP identified
by ordinal_number.
Syntax
Example
Displays the configuration information for all SCAN listeners, by default, or a specific listener identified
by ordinal_number.
Syntax
Example
Syntax
Examples
www.usefzadeh.com
vahidusefzadeh@gmail.com
This command displays information similar to the following for a administrator-managed database:
Displays configuration information including name, minimum size, maximum size, importance, and a list
of server names, if applicable, for a specific server pool in a cluster.
Syntax
Example
Displays all VIPs on all networks in the cluster except for user VIPs.
Syntax
Example
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
Examples
If you do not specify any parameters, then SRVCTL displays configuration information for all volumes,
similar to the following:
The srvctl convert database command converts a database either to or from an Oracle RAC One Node
database.
Syntax
srvctl convert database -db db_unique_name -dbtype RACONENODE [-instance instance_name] [-timeout
timeout]
Example
disable
Disables a specified object (cluster database, database instance, Oracle ASM instance, or service). Use
the srvctl disable command when you must shut down an object for maintenance. The disabled object
does not automatically restart.
When you issue the disable command, the object is disabled and unavailable to run under Oracle
Clusterware for automatic startup, failover, or restart. Additionally, you cannot run the srvctl
start command on a disabled object until you first re-enable the object. If you specify -
instance instance_name or -node node_name, then SRVCTL only disables the object on the specified
instance or node.
www.usefzadeh.com
vahidusefzadeh@gmail.com
Disables the Oracle ASM proxy resource. Oracle ASM will restart if it contains Oracle Clusterware data or
if the node restarts and it was running before the node failed. The srvctl disable asm command also
prevents the srvctl start asm command from starting Oracle ASM instances.
Disabling the Oracle ASM proxy resource prevents the databases and disk groups from starting because
they depend on the Oracle ASM proxy resource.
Syntax
Example
Disable the Cluster Verification Utility (CVU) for Oracle Clusterware management, if enabled.
Syntax
Examples
Disables a database. If the database is a cluster database, then its instances are also disabled.
Syntax
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
Syntax
Example
Syntax
Example
Syntax
Example
Disables GNS for a specific node, or all available nodes in the cluster.
www.usefzadeh.com
vahidusefzadeh@gmail.com
Syntax
Example
Prevents a specific highly available VIP (HAVIP) (used for highly available NFS exports) resource from
running on a number of specified nodes.
Syntax
Example
Disables an instance. If the instance that you disable with this command is the last enabled instance,
then this operation also disables the database.
Syntax
Example
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
Example
Disables the management database (CHM repository) resource on the specified node.
Syntax
Example
Disables the management listener resource (for CHM) on the specified node.
Syntax
Example
Syntax
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
Syntax
Example
Disables the Oracle Notification Service daemon for Oracle Restart installations.
The only parameter for this command is -verbose, which indicates that verbose output should be
displayed.
Disables all SCAN VIPs, by default, or a specific SCAN VIP identified by ordinal_number.
Syntax
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
Syntax
Example
Disables a service. Disabling an entire service affects all of the instances, disabling each one. When the
entire service is already disabled, a srvctl disable service operation on the entire service affects all of the
instances and disables them; it just returns an error. This means that you cannot always use the entire
set of service operations to manipulate the service indicators for each instance.
Syntax
srvctl disable service -db db_unique_name -servics "service_name_list" [-instance instance_name | -node
node_name]
Example
The following example disables a service for the CRM database that is running on the CRM1 instance,
resulting in the service still being available for the database, but on one less instance:
Syntax
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
This command allows a volume device to be stopped by operating on the Oracle Clusterware resource
for the volume. This command does not stop volume device.
Syntax
Example
The srvctl downgrade database command downgrades the configuration of a database and its services
from its current version to the specified lower version.
Syntax
Syntax
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
Enable the Cluster Verification Utility (CVU) for Oracle Clusterware management if disabled.
Syntax
Examples
Syntax
Example
Syntax
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
Syntax
Example
Syntax
Example
Syntax
Example
Enables a specific highly available VIP (HAVIP) (used for highly available NFS exports) to run on a number
of specified nodes.
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
Example
Enables an instance for an Oracle RAC database. If you use this command to enable all instances, then
the database is also enabled.
Syntax
Example
Syntax
Example
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
Example
Syntax
Example
Syntax
Example
Syntax
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
Note:
Syntax
Example
Enables all SCAN VIPs, by default, or a specific SCAN VIP identified by its ordinal_number.
Syntax
Example
Enables all SCAN listeners, by default, or a specific listener identified by its ordinal_number.
Syntax
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
Enables a service for Oracle Clusterware. Enabling an entire service also affects the enabling of the
service over all of the instances by enabling the service at each one. When the entire service is already
enabled, an srvctl enable service operation does not affect all of the instances and enable them. Instead,
this operation returns an error. Therefore, you cannot always use the entire set of service operations to
manipulate the service indicators for each instance.
Syntax
srvctl enable service -db db_unique_name -service "service_name_list" [-instance instance_name | -node
node_name]
Examples
Syntax
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
This command allows a volume device to be started by operating on the Oracle Clusterware resource for
the volume. This command does not start the volume device, and is different from the SQL
command ALTER DISKGROUP ENABLE VOLUME or the ASMCMD command volenable, because these two
commands bring the volume device online, in a running state, making the volume device accessible.
Syntax
Example
export
The srvctl export gns command exports Grid Naming Service (GNS) instance data to a file that you can
use when you are either moving GNS from one server cluster to another or when you are creating a
client cluster
The srvctl export gns command exports Grid Naming Service (GNS) instance data to a file that you can
use when you are either moving GNS from one server cluster to another or when you are creating a
client cluster.
The credentials used to authorize users, which includes the VIP address on which the server listens
Syntax
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
Displays the values for environment variables associated with Oracle ASM.
Syntax
Example
Syntax
Example
Syntax
Example
Gets the environment variables for the management database (CHM repository).
www.usefzadeh.com
vahidusefzadeh@gmail.com
Syntax
Example
Gets the environment variables for the management listener resource (for CHM).
Syntax
Example
Syntax
Example
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
Example
import
The srvctl import command imports data from a file that you create when you run the srvctl export
gns command. Use this command when you want to locate GNS to a different server cluster.
The srvctl import command imports data from a file that you create when you run the srvctl export
gns command. Use this command when you want to locate GNS to a different server cluster.
When you import GNS data, SRVCTL stores the credentials and places the record data into OCR. If
another GNS instance is running or data for another instance is encountered during the import
procedure, then an error occurs.
This command also makes the cluster in which you run it the server cluster.
Syntax
Example
modify
Enables you to modify the instance configuration without removing and adding Oracle Clusterware
resources. Using modify preserves the environment in the OCR configuration that would otherwise need
to be reentered. The configuration description is modified in the OCR configuration, and a new Oracle
Clusterware profile is generated and registered. The change takes effect when the application is next
restarted.
www.usefzadeh.com
vahidusefzadeh@gmail.com
Modify the listener used by Oracle ASM, the disk group discovery string used by Oracle ASM, or the
SPFILE used by Oracle ASM for a noncluster database or a cluster database.
Syntax
srvctl modify asm [-listener listener_name] [-pwfile password_file_path] [-diskstring asm_diskstring] [-spfile
spfile_path_name [-proxy]]
Example
Syntax
Example
Syntax
srvctl modify database -db db_unique_name [-eval] [-dbname db_name] [-instance instance_name] [-oraclehome
oracle_home] [-user user_name] [-server server_list] [-timeout timeout] [-domain db_domain] [-spfile spfile] [-
www.usefzadeh.com
vahidusefzadeh@gmail.com
Examples
The following example directs the racTest database to use the SYSFILES, LOGS, and OLTP Oracle ASM
disk groups.
Syntax
srvctl modify exportfs -name unique_name [-path path_to_export][-clients node_list] [-options nfs_options_string]
Example
Syntax
srvctl modify filesystem -device volume_device -user user_name [-path mount_point_path] [-node node_list | -
serverpool server_pool_list] [-fsoptions options] [-description description] [-autostart {ALWAYS | NEVER |
RESTORE}]
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
Syntax
srvctl modify gns -loglevel log_level srvctl modify gns [-resolve address] [-verify name] [-parameter
parameter:value[,parameter:value...]] [-vip vip_address] [-clientdata file_name] [-forward domain_list] [-refused
domain_list] [-excluded interface_list] [-verbose]
Example
Modifies a highly available VIP (HAVIP) (used for highly available NFS exports).
Syntax
srvctl modify havip -id havip_name [-address {host_name | ip_address} [-netnum network_number]] [-
description text]
Example
For an administrator-managed database, this command modifies the configuration for a database
instance from its current node to another node. For a policy-managed database, this command defines
an instance name to use when the database runs on the specified node.
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
Examples
The following example causes the policy-managed database pmdb, when and if it runs on mynode, to
use the instance name pmdb1:
The following example removes the directive established by the previous example:
Changes the Oracle home directory from which the listener runs, the name of the operating system user
who owns Oracle home directory from which the listener runs, the listener endpoints, or the public
subnet on which the listener listens, either for the default listener, or a specific listener, that is
registered with Oracle Restart or with Oracle Clusterware.
If you want to change the name of a listener, then use the srvctl remove listener and srvctl add
listener commands.
Syntax
srvctl modify listener [-listener listener_name] [-oraclehome oracle_home] [-user user_name] [-netnum
network_number] [-endpoints "[TCP:]port_list[/IPC:key][/NMP:pipe_name][/TCPS:s_port][/SDP:port]"]
Example
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
srvctl modify mgmtdb [-pwfile password_file_path] [-spfile spfile_path] [-startoption start_option] [-stopoption
stop_option] [-diskgroup "diskgroup_list"]
Example
Modifies the configuration for the management listener resource (for CHM).
Syntax
Example
Syntax
Examples
The following example changes the subnet number, netmask, and interface list:
The following example adds an IPv6 subnet and netmask to the default network:
www.usefzadeh.com
vahidusefzadeh@gmail.com
Syntax
verbose]
Example
The following example changes the nodeapps resource on mynode1 to use the application VIP of
100.200.300.40 with a subnet mask of 255.255.255.0 on the network interface eth0:
Syntax
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
Modifies the ports used by the Oracle Notification Service daemon that is registered with Oracle Restart.
Syntax
Modifies the number of SCAN VIPs to match the number of IP addresses returned by looking up
the scan_name you specify in DNS. You use this command when DNS was modified to add, change, or
remove IP addresses, and now you must adjust the Oracle Clusterware resource configuration to match.
Syntax
Example
Assume your system currently has a SCAN named scan_name1, and it resolves to a single IP address in
DNS. If you modify the SCAN scan_name1 in DNS to resolve to three IP addresses, then use the following
command to create the additional SCAN VIP resources:
Modifies the SCAN listener to match SCAN VIP's or modifies the SCAN listener endpoints or service
registration restrictions.
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
Example
Assume your system currently has a SCAN named scan_name1, and you recently modified the DNS entry
to resolve to three IP addresses instead of one. After running the srvctl modify scan command to create
additional SCAN VIP resources, use the following command to create Oracle Clusterware resources for
the additional two SCAN listeners to go with the two additional SCAN VIPs:
This command supports some online modifications to the service, such as:
Performing online changes to service attributes from DBMS_SERVICE (for example, failover delay,
runtime load balancing goal, and so on)
syntax:
srvctl modify service -db db_unique_name -service service_name -oldinst old_instance_name -newinst
new_instance_name [-force]
Note:
srvctl modify service -db db_unique_name -service service_name -available avail_inst_name -toprefer [-force]
srvctl modify service -db db_unique_name -service service_name -modifyconfig -preferred "preferred_list" [-
available "available_list"] [-force]
www.usefzadeh.com
vahidusefzadeh@gmail.com
srvctl modify service -db db_unique_name -service service_name [-eval] [-serverpool pool_name] [-cardinality
[-verbose] [-force]
Examples
$ srvctl modify service -db crm -service crm -oldinst crm1 -newinst crm2
$ srvctl modify service -db crm -service crm -available crm1 -toprefer
$ srvctl modify service -db crm -service crm -modifyconfig -preferred "crm1" \ -available "crm2"
Modifies a server pool in a cluster. If minimum size, maximum size, and importance are numerically
increased, then the CRS daemon may attempt to reassign servers to this server pool, if by resizing other
server pools have comparatively lower minimum size and importance, to satisfy new sizes of this server
pool.
Syntax
srvctl modify srvpool -serverpool pool_name [-eval] [-importance importance] [-min min_size] [-max max_size] [-
servers "server_list"] [-category "server_category"] [-verbose] [-force]
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
The following example changes the importance rank to 0, the minimum size to 2, and the maximum size
to 4 for the server pool srvpool1:
Modifies IP address type but you can also use it to modify just the IP address.
Syntax
Example
The following example adds an IPv4 address to a VIP, if one does not already exist. If the VIP has an IPv4
address, then it is replaced with the new network specification.
predict
The predict command helps you evaluate the consequences of a resource failure. This command does
not make any modifications to the system.
Syntax
Examples
www.usefzadeh.com
vahidusefzadeh@gmail.com
The srvctl predict database command predicts what happens if the specified database fails.
Syntax
Example
Syntax
Example
Syntax
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
Syntax
Example
Syntax
Example
Syntax
Example
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
Example
Syntax
Example
Syntax
Example
Syntax
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
relocate
The relocate command causes the specified object to run on a different node. The specified object must
be running already.
The relocation of the object is temporary until you modify the configuration. The previously
described modify command permanently changes the configuration.
Syntax
Example
The srvctl relocate database command initiates the relocation of an Oracle RAC One Node database
from one node to another node. This command also cleans up after a failed relocation.
The srvctl relocate database command can only be used for relocating Oracle RAC One Node databases.
Syntax
srvctl relocate database -db db_unique_name [-node target_node] [-timeout timeout] [-verbose]
Example
The following example relocates an administrator-managed Oracle RAC One Node database
named rac1 to a server called node7.
www.usefzadeh.com
vahidusefzadeh@gmail.com
Relocates GNS from its current hosting node to another node within the cluster.
Syntax
Example
Relocates a highly available VIP (HAVIP) (used for highly available NFS exports) to another node in a
cluster.
Syntax
Example
Relocates the management database (CHM repository) resource from one node of the cluster to
another.
Syntax
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
Relocates an OC4J instance from its current hosting node to another node within the cluster.
Syntax
Example
Relocates a specific SCAN VIP from its current hosting node to another node within the cluster.
Syntax
Example
Relocates a specific SCAN listener from its current hosting node to another node within the cluster.
Syntax
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
Syntax
Example
Relocates the named service names from one named instance to another named instance. The srvctl
relocate command works on only one source instance and one target instance at a time, relocating a
service from a single source instance to a single target instance. The target instance must be on the
preferred or available list for the service.
Syntax
srvctl relocate service -db db_unique_name -service service_name [-eval] -currentnode source_node -targetnode
target_node [-force] srvctl relocate service -db db_unique_name -service service_name [-eval] -oldinst
old_instance_name -newinst new_instance_name [-force]
Example
$ srvctl relocate service -db crm -service crm -oldinst crm1 -newinst crm3
Relocates a specific VIP from its current hosting node to another node within the cluster.
Syntax
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
remove
Removes the configuration information for the specified target from Oracle Clusterware. Environment
settings for the object are also removed. Using this command does not destroy the specified target.
Use the remove verb to remove the associated resource from the management of Oracle Clusterware or
Oracle Restart. Depending on the noun used, you can remove databases, services, nodeapps, Oracle
ASM, Oracle Notification Service, and listeners.
If you do not use the force parameter (-force), then Oracle Clusterware or Oracle Restart prompts you to
confirm whether to proceed. If you use -force, then the remove operation proceeds without prompting
and continues processing even when it encounters errors. Even when the Oracle Clusterware resources
cannot be removed, the OCR configuration is removed, so that the object now appears not to exist, but
there are still Oracle Clusterware resources. Use the force parameter (-force) with extreme caution
because this could result in an inconsistent OCR.
To use the remove verb, you must first stop the node applications, database, instance, or service for
which you are specifying srvctl remove. Oracle recommends that you perform a disable operation
before using this command, but this is not required. You must stop the target object before running
thesrvctl remove command. See the stop command.
Syntax
Example
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
Example
Syntax
Example
Removes a specific Oracle ASM disk group resource from Oracle Clusterware or Oracle Restart.
Syntax
Example
Syntax
Examples
www.usefzadeh.com
vahidusefzadeh@gmail.com
Syntax
Example
Syntax
Example
Removes a highly available VIP (HAVIP) (used for highly available NFS exports).
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
Example
If you use the -force parameter, then any services running on the instance stop. Oracle recommends
that you reconfigure services to not use the instance to be removed as a preferred or available instance
before removing the instance.
Notes:
This command is only available with Oracle Clusterware and Oracle RAC.
If you attempt to use this command on an Oracle RAC One Node database, then the command returns
an error stating that cannot remove the instance except by removing the database.
Syntax
Example
Removes the configuration of a specific listener or all listeners from Oracle Clusterware or Oracle
Restart.
Syntax
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
Removes the management database (CHM repository) from Oracle Clusterware management.
Syntax
Example
Use this command to remove the management listener resource (for CHM) from Oracle Clusterware.
Syntax
Example
Removes the network configuration. You must have full administrative privileges to run this command.
On Linux and UNIX systems, you must be logged in asroot and on Windows systems, you must be logged
in as a user with Administrator privileges.
Syntax
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
Syntax
Example
Syntax
Removes Oracle Notification Service from the Oracle Grid Infrastructure home.
Note:
Syntax
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
Example
Syntax
Example
Syntax
srvctl remove service -db db_unique_name -service service_name [-instance instance_name] [-global_override] [-
force]
Examples
This command removes the sales service from all instances of the clustered database named crm:
The following example removes the sales service from a specific instance of the crm clustered database:
www.usefzadeh.com
vahidusefzadeh@gmail.com
Removes a specific server pool. If there are databases or services that depend upon this server pool,
then those resources are removed from the server pool first so that the remove server pool operation
succeeds.
Syntax
Example
Syntax
Example
Syntax
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
setenv
The setenv command sets values for the environment in the configuration file. Use setenv to set
environment variables—items such as language or TNS_ADMIN—for Oracle Clusterware that you would
typically set in your profile or session when you manage this database or database instance.
The unsetenv command unsets values for the environment in the configuration file.
Syntax
Example
Syntax
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
Syntax
Example
Administers the environment configuration for the management database (CHM repository).
Syntax
Example
Administers the environment configuration for the management listener resource (for CHM).
Syntax
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
Syntax
Example
Syntax
srvctl setenv vip -vip vip_name {-envs "name=val[,name=val,...]" | -env "name=val"} [-verbose]
Example
The following example sets the language environment configuration for a cluster VIP:
start
Starts Oracle Restart or Oracle Clusterware enabled, non-running applications for the database, all or
named instances, all or named service names, or node-level applications. For the start command, and
for other operations that use a connect string, if you do not provide a connect string, SRVCTL uses /as
sysdbato perform the operation. To run such operations, the owner of the oracle binary executables
must be a member of the OSDBA group, and users running the commands must also be in the OSDBA
group.
www.usefzadeh.com
vahidusefzadeh@gmail.com
Notes:
To manage Oracle ASM on Oracle Database 12c installations, use the SRVCTL binary in the Oracle Grid
Infrastructure home for a cluster (Grid home). If you have Oracle RAC or Oracle Database installed, then
you cannot use the SRVCTL binary in the database home to manage Oracle ASM.
Syntax
Examples
An example of this command to start an Oracle ASM instance on a single node of a cluster is:
An example to start an Oracle ASM instance on all nodes in the cluster, or for a noncluster database, is:
Starts the CVU resource on one node in a cluster. If you specify a node name, then CVU starts on that
node.
Syntax
Examples
Starts a cluster database and its enabled instances and all listeners on nodes with database instances.
You can disable listeners that should not be started.
www.usefzadeh.com
vahidusefzadeh@gmail.com
Syntax
srvctl start database -db db_unique_name [-eval] [-startoption start_options] [-node node_name]
Example
Syntax
Example
Syntax
Example
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
Examples
Syntax
Example
An example of this command to start the GNS on the cluster node named crmnode1 is:
Starts a specific highly available VIP (HAVIP) (used for highly available NFS exports) on a specific node.
Syntax
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
Starts all the Oracle Restart-managed or Oracle Clusterware-managed resources on the specified Oracle
home.
Syntax
Example
Starts instances in the cluster database and all listeners on nodes with database instances. You can
disable listeners that should not be started.
Syntax
srvctl start instance -db db_unique_name -node node_name [-instance "instance_name"] [-startoption
start_options]
Example
Starts the default listener on the specified node_name, or starts the specified listener on all nodes that
are registered with Oracle Clusterware or on the given node.
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
Example
Syntax
Examples
An example of this command to start the management database on the crmnode1 node of the cluster is:
Syntax
Examples
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
Example
Syntax
Note:
Syntax
There is only one parameter for this command, -verbose, which is used to indicate that verbose output
should be displayed.
Starts all SCAN VIPs, by default, or a specific SCAN VIP, on all nodes or a specific node in the cluster.
Syntax
Example
To start the SCAN VIP identified by the ordinal number 1 on the crm1 node, use the following command:
www.usefzadeh.com
vahidusefzadeh@gmail.com
Starts all SCAN listeners, by default, or a specific listener on all nodes or a specific node in the cluster.
Syntax
Example
Starts a service or multiple services on the specified instance. The srvctl start service command will fail if
you attempt to start a service on an instance if that service is already running on its maximum number
of instances, that is, its number of preferred instances. You may move a service or change the status of a
service on an instance with the srvctl modify service and srvctl relocate service commands described
later in this appendix.
Syntax
srvctl start service -db db_unique_name [-eval] [-service "services_list" [-node node_name | -instance
instance_name | -serverpool pool_name | -global_override] [-startoption start_options] [-verbose]
Examples
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
Example
Syntax
srvctl start volume {-volume volume_name -diskgroup disk_group_name | -device volume_device} [-node
node_list]
Example
The following example starts a volume named VOLUME1 that resides in a disk group named DATA:
Syntax
Example
Displays the current state of the CVU resource on one node in a cluster. If you specify a node name, then
the command checks CVU status on that node.
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
Examples
Displays the status of instances and their services, and where the instances are running.
If you run this command on an Oracle RAC One Node database, then the output shows the status of any
online database relocation (active, failed, or inactive), and the source and destination nodes of the
relocation.
Syntax
Example
Syntax
Example
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
Example
Syntax
Examples
This command displays output similar to the following, depending on whether you specify a device
name:
Note:
In the preceding examples, the file system is Oracle ACFS. If you are using other file systems, then they
will display as EXT3 or EXT4.
www.usefzadeh.com
vahidusefzadeh@gmail.com
Syntax
Displays the status of all highly available VIPs (HAVIPs) (used for highly available NFS exports) in a cluster
or one particular highly available VIP.
Syntax
Example
Displays the status of all the Oracle Restart-managed or Oracle Clusterware-managed resources for the
specified Oracle home.
Syntax
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
Syntax
srvctl status instance -db db_unique_name {-node node_name | -instance "instance_name_list"} [-force] [-
verbose]
Example
Syntax
Example
Displays the current state of the management database (CHM repository) resource.
Syntax
Examples
www.usefzadeh.com
vahidusefzadeh@gmail.com
Syntax
Example
Syntax
Determines which node is running the Oracle Database QoS Management server.
Syntax
Note:
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
Displays the status for all SCAN VIPs, by default, or a specific SCAN VIP.
Syntax
Example
Displays the status for all SCAN listeners, by default, or a specific listener.
Syntax
Example
Syntax
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
For Oracle RAC One Node databases, if there is an online database relocation in process, then the srvctl
status service command displays the source and destination nodes and the status of the relocation,
whether it is active or failed.
Syntax
Example
Displays server pool names, number of servers in server pools, and, optionally, the names of the servers
in the server pools.
Syntax
Example
Syntax
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
Syntax
srvctl status volume [-device volume_device] [-volume volume_name] [-diskgroup disk_group_name] [-node
"node_list"]
Example
Syntax
Example
Stops the Cluster Verification Utility (CVU) that is either in the running or starting state.
Syntax
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
Stops a database, its instances, and its services. When the database later restarts, services
with AUTOMATIC management start automatically but services withMANUAL management policy must
be started manually.
Syntax
Example
Use this command to stop a specific disk group resource on a number of specified nodes.
Syntax
Example
Use this command to stop an export file system configuration managed by Oracle Clusterware.
Syntax
Example
Use this command to stop (unmount) the Oracle ACFS file system or generic file system.
www.usefzadeh.com
vahidusefzadeh@gmail.com
Syntax
Example
Syntax
Example
Stops the highly available VIPs (HAVIPs) (used for highly available NFS exports) on a specific node.
Syntax
Example
Stops all the Oracle Restart-managed or Oracle Clusterware-managed resources that run from the
specified Oracle home.
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
srvctl stop home -oraclehome Oracle_home -statefile state_file -node node_name [-stopoption stop_options] [-
force]
Example
~/state.txt
Stops instances and stops any services running on specified instances, unless you specify the -
force parameter. If you specify -force, then the services fail over to an available instance when the
instance stops.
Syntax
srvctl stop instance -db db_unique_name {-node node_name | -instance "instance_name_list"} [-stopoption
stop_options] [-force]
Example
Stops the default listener or a specific listener on all nodes or the specified node.
This command can also be used to stop a listener on a noncluster database from the noncluster
database home. However, SRVCTL does not accept the -nodeparameter when run from a noncluster
database home.
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
Example
Syntax
Example
Stops the management listener resource (for CHM) on all nodes or the specified node.
Syntax
Example
Syntax
srvctl stop nodeapps [-node node_name] [-gsdonly] [-adminhelper] [-force] [-relocate] [-verbose]
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
Syntax
Example
Note:
Syntax
Example
Stops all SCAN VIPs, by default, that are running or in starting state, or stops a specific SCAN VIP
identified by ordinal_number.
Syntax
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
Stops all SCAN listeners, by default, that are in a running or starting state, or a specific listener identified
by ordinal_number.
Syntax
Example
Stops one or more services globally across the cluster database, or on the specified instance.
Syntax
srvctl stop service -db db_unique_name [-service "services_list" [-node node_name | -instance instance_name | -
serverpool pool_name | -global_override]] [-eval] [-force]
Examples
The following example stops a service for all cluster database instances:
Stops a specific VIP or all VIPs on a specific node, including any VIPs that were relocated due to a
failover.
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
srvctl stop vip {-node node_name | -vip vip_name} [-force] [-relocate] [-verbose]
Example
Syntax
srvctl stop volume {-volume volume_name -diskgroup disk_group_name | -device volume_device} [-node
"node_list"]
Example
Syntax
Example
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
Example
Syntax
Example
Syntax
Example
Syntax
Use the -envs parameter to specify a comma-delimited list of the names of environment variables
enclosed in double quotation marks ("").
www.usefzadeh.com
vahidusefzadeh@gmail.com
Example
Syntax
Example
The following example unsets the environment configuration for all node applications:
Syntax
Example
The following example unsets the CLASSPATH environment variable for a cluster VIP:
update
The srvctl update command requests that the specified running object use the new configuration
information stored in the OCR.
www.usefzadeh.com
vahidusefzadeh@gmail.com
Syntax
Use the -db parameter to specify the unique name of the database to update.
Use the srvctl update gns command to modify a Grid Naming Service (GNS) instance.
Syntax
Use the srvctl update gns command with one of these syntax models:
srvctl update gns -advertise name -address ip_address [-timetolive time_to_live] [-verbose]
srvctl update gns -alias alias -name name [-timetolive time_to_live] [-verbose]
srvctl update gns -createsrv service -target target -protocol protocol [-weight weight] [-priority priority] [-port
port_number] [-timetolive time_to_live] [-instance instance_name] [-verbose]
srvctl update gns -deletesrv service_name -target target -protocol protocol [-verbose]
srvctl update gns -createtxt name -target target [-timetolive time_to_live] [-namettl name_ttl] [-verbose]
srvctl update gns -createptr name -target target [-timetolive time_to_live] [-namettl name_ttl] [-verbose]
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
Syntax
Use the srvctl update listener command with the following syntax:
This command does not accept any additional parameters, except for -help.
Syntax
Use the srvctl update scan_listener command with the following syntax:
This command does not accept any additional parameters, except for -help.
upgrade
The upgrade command upgrades the resources types and resources from an older version to a newer
version.
The srvctl upgrade database command upgrades the configuration of a database and all of its services to
the version of the database home from where this command is run.
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
ALTER DATABASE ADD STANDBY LOGFILE THREAD 1 GROUP 11 SIZE 100M, GROUP 12 SIZE 100M;
-- channel configuration
syntax
example
OR
www.usefzadeh.com
vahidusefzadeh@gmail.com
www.usefzadeh.com
vahidusefzadeh@gmail.com
chapter 3
ASM
dsget
Retrieves the discovery diskstring value that is used by the Oracle ASM instance and its clients.
Syntax
Example
profile: /devices1/disk*
parameter: /devices2/disk*
dsset
Sets the discovery diskstring value that is used by the Oracle ASM instance and its clients. The specified
diskstring must be valid for existing mounted disk groups. The updated value takes effect immediately.
Syntax
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
lsct
Lists information about current Oracle ASM clients from the V$ASM_CLIENT view. A client, such as
Oracle Database or Oracle ASM Dynamic Volume Manager (Oracle ADVM), uses disk groups that are
managed by the Oracle ASM instance to which ASMCMD is currently connected.
Syntax
Example
lsop
Syntax
Example
lspwusr
www.usefzadeh.com
vahidusefzadeh@gmail.com
List the users from the local Oracle ASM password file.
Syntax
lspwusr [--suppressheader]
Example
orapwusr
Syntax
pwcopy
Copies an Oracle ASM or database instance password file to the specified location.
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
pwcreate
Creates an Oracle ASM or database instance password file at the specified location.
Syntax
Example
pwdelete
Syntax
pwget
Returns the location of the password file for the Oracle ASM or database instance.
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
+DATA/orapwasm
pwmove
Moves an Oracle ASM or database instance password file to the specified location.
Syntax
Example
pwset
Sets the location of the password file for an Oracle ASM or database instance.
Syntax
Example
showclustermode
Syntax
showclustermode
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
showclusterstate
Syntax
showclusterstate
Example
showpatches
Syntax
showpatches
Example
showversion
Displays the patch levels of the Oracle ASM cluster release and software.
Syntax
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
Software patchlevel : 0
shutdown
Syntax
Example
spbackup
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
spcopy
Copies an Oracle ASM SPFILE from the source location to an SPFILE in the destination location.
Syntax
Example
spget
Retrieves the location of the Oracle ASM SPFILE from the Grid Plug and Play (GPnP) profile.
Example
+DATA/ASM/ASMPARAMETERFILE/registry.253.813507611
spmove
Moves an Oracle ASM SPFILE from source to destination and automatically updates the GPnP profile.
Example
spset
www.usefzadeh.com
vahidusefzadeh@gmail.com
Sets the location of the Oracle ASM SPFILE in the Grid Plug and Play (GPnP) profile.
Syntax
spset location
Example
startup
Syntax
cd
Syntax
cd [dir]
Examples
www.usefzadeh.com
vahidusefzadeh@gmail.com
cp
Enables you to copy files between Oracle ASM disk groups and between a disk group and the operating
system.
Syntax
cp src_file [rem_connect_str:]tgt_file
cp [rem_connect_str:]src_file tgt_file
Examples
Enter Password:
du
Displays the total space used for files in the specified directory and in the entire directory tree under the
directory.
Syntax
du [--suppressheader] [dir]
Example
Used_MB Mirror_used_MB
1756 3519
www.usefzadeh.com
vahidusefzadeh@gmail.com
find
Displays the absolute paths of all occurrences of the specified name pattern (with wildcards) in a
specified directory and its subdirectories.
Syntax
Examples
+data/USEFDB/DATAFILE/UNDOTBS1.258.691577151
+data/usefdb/CONTROLFILE/Current.260.691577263
ls
Lists the contents of an Oracle ASM directory, the attributes of the specified file, or the names and
attributes of all disk groups.
Syntax
Examples
www.usefzadeh.com
vahidusefzadeh@gmail.com
rw-rw-rw- EXAMPLE.265.691577295
lsof
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
mkalias
Syntax
Example
sysaux.f
mkdir
Syntax
Example
pwd
www.usefzadeh.com
vahidusefzadeh@gmail.com
Syntax
pwd
Example
+data/usefdb/datafile
rm
Syntax
Example
rmalias
Removes the specified aliases, retaining the files that the aliases reference.
Syntax
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
chdg
Changes a disk group (adds disks, drops disks, resizes disks, or rebalances a disk group) based on an XML
configuration file.
Syntax
<drop>
<fg name="fg1"></fg>
<dsk name="data_0001"/>
</drop>
<add>
<fg name="fg2">
<dsk string="/dev/disk5"/>
</fg>
</add>
</chdg>
www.usefzadeh.com
vahidusefzadeh@gmail.com
chkdg
Syntax
chkdg [--repair] diskgroup
Example
dropdg
Syntax
iostat
Displays I/O statistics for Oracle ASM disks in mounted disk groups.
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
lsattr
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
Name Value
compatible.asm 12.1.0.0.0
compatible.rdbms 11.2.0.3.0
lsdg
Syntax
Example
(continued)
0 N DATA
www.usefzadeh.com
vahidusefzadeh@gmail.com
lsdsk
Syntax
...
...
www.usefzadeh.com
vahidusefzadeh@gmail.com
lsod
Syntax
md_backup
The md_backup command creates a backup file containing metadata for one or more disk groups.
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
md_restore
The md_restore command restores disk groups from a metadata backup file.
Syntax
Example
mkdg
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
<fg name="fg1">
<dsk string="/dev/disk1"/>
<dsk string="/dev/disk2"/>
</fg>
<fg name="fg2">
<dsk string="/dev/disk3"/>
<dsk string="/dev/disk4"/>
</fg>
</dg>
mount
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
offline
Syntax
online
Online all disks, a single disk, or a failure group that belongs to a disk group.
Syntax
rebal
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
remap
Marks a range of blocks as unusable on the disk and relocates any data allocated in that range.
Syntax
Examples
setattr
Syntax
umount
www.usefzadeh.com
vahidusefzadeh@gmail.com
Syntax
chgrp
Syntax
chmod
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
chown
Syntax
groups
Lists all the user groups to which the specified user belongs.
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
asm_data
grpmod
Adds or removes operating system (OS) users to and from an existing Oracle ASM user group.
Syntax
lsgrp
Lists all Oracle ASM user groups or only groups that match a specified pattern.
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
lsusr
Syntax
3 1001 grid
1 1021 oracle1
2 1022 oracle2
mkgrp
Syntax
mkusr
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
passwd
Syntax
passwd user
Example
rmgrp
Syntax
rmusr
www.usefzadeh.com
vahidusefzadeh@gmail.com
Syntax
rpusr
Replaces one operating system (OS) user with another in a disk group.
Syntax
volcreate
Syntax
ASMCMD [+] > volcreate -G data -s 10G --width 64K --column 8 volume1
www.usefzadeh.com
vahidusefzadeh@gmail.com
State: ENABLED
Redundancy: MIRROR
Stripe Columns: 8
Usage:
Mountpath:
voldelete
Syntax
voldisable
Disables Oracle ADVM volumes in mounted disk groups and removes the volume device on the local
node.
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
volenable
Syntax
volinfo
Syntax
State: ENABLED
Redundancy: MIRROR
www.usefzadeh.com
vahidusefzadeh@gmail.com
Stripe Columns: 8
Usage: ACFS
Mountpath: /acfsmounts/acfs1
State: ENABLED
Redundancy: MIRROR
Stripe Columns: 4
Usage: ACFS
Mountpath: C:\oracle\acfsmounts\acfs1
volresize
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
volset
Syntax
ASMCMD [+] > volset -G data --usagestring 'no file system created' volume1
volstat
Syntax
Example
---------------------------------------
VOLUME_NAME
-------------------------------------------------------------
VOLUME1
www.usefzadeh.com
vahidusefzadeh@gmail.com
ACFS Commands
acfsload
acfsload loads or unloads Oracle ACFS, Oracle ADVM, and Oracle Kernel Services Driver (OKS) drivers.
Syntax
Example
# acfsload stop
acfsdriverstate
acfsdriverstate provides information on the current state of the Oracle ACFS, Oracle ADVM, and Oracle
Kernel Services Driver (OKS) drivers.
Syntax
Example
acfsplugin
The acfsplugin application programming interface (API) sends and receives messages to and from the
local plug-in enabled Oracle ACFS driver from the application plug-in module.
www.usefzadeh.com
vahidusefzadeh@gmail.com
Syntax
Example
fsck
Syntax
mkfs
Syntax
mkfs -t acfs -h
mkfs [-v] [-f]-t acfs [-n name ] volume_device [size]
Example
State: ENABLED
www.usefzadeh.com
vahidusefzadeh@gmail.com
mount
Syntax
mount -h
mount [-v] -t acfs [-o options] volume_device mount_point
mount
Examples
umount
Syntax
umount -h
umount [-v] volume_device |mount_point
umount -a [-t acfs]
umount -h displays usage text and exits.
Examples
# /bin/umount /dev/asm/volume1-123
# /bin/umount /acfsmounts/acfs1
Displays the tag names for tagged directories or file names in Oracle ACFS file systems.
www.usefzadeh.com
vahidusefzadeh@gmail.com
Syntax
Adds the given tag to the specified files or directories in an Oracle ACFS file system
Syntax
Removes the given tag name or all tag names from the specified file or directory.
Syntax
/acfsmounts/acfs1/myrepfiles/*.log
acfsutil repl bg
www.usefzadeh.com
vahidusefzadeh@gmail.com
Starts, stops, or displays information about the Oracle ACFS replication background processes.
Syntax
acfsutil repl bg -h
acfsutil repl bg {start |stop|info} mount_point
Examples
Verifies that files have been replicated on an Oracle ACFS file system.
Syntax
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
Initiates replication on all the files in an Oracle ACFS file system or only those files with a specified list of
tags.
Syntax
acfsutil repl init primary -s standby_connect_string [tagname...] [-m standby_mount_point] [-c primary_service][-
d trace_level] [-z {on|off}] mount_point
-s /@standby_repl_site
-m /standby/repl_data -c primary_repl_service
/acfsmounts/repl_data
-p /@primary_repl_site
-c standby_repl_service /standby/repl_data
www.usefzadeh.com
vahidusefzadeh@gmail.com
Syntax
Examples
Resumes replication on an Oracle ACFS file system where replication has been paused.
Syntax
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
Stops all replication activity on the Oracle ACFS file system at the site where it is run.
Syntax
Sets the replication trace level for gathering trace information on an Oracle ACFS file system.
Syntax
Updates replication information while replication is running on an Oracle ACFS file system.
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
Forces an archival of the audit trail for the current host on the specified Oracle ACFS file system.
Syntax
Disables auditing for either Oracle ACFS encryption or security on a specified file system.
Syntax
Enables auditing for either Oracle ACFS encryption or security on a specified file system.
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
Syntax
Audit Sources:
Security: ENABLED
Encryption: ENABLED
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
Syntax
Marks the audit trail to indicates to the audit manager that the log archive file for the current node has
been reviewed, backed up as necessary, and is safe to purge.
Syntax
acfsdbg
Syntax
acfsdbg -h
acfsdbg [-r] [-l] volume_device
Example
$ /sbin/acfsdbg /dev/asm/voume1-123
Oracle ASM Cluster File System (ACFS) On-Disk Structure Version: 39.0
www.usefzadeh.com
vahidusefzadeh@gmail.com
acfsdbg>
61,440
61440
61440
0xf000
0170000
1111:0000:0000:0000
acfsdbg test>
Syntax
acfsutil info fs
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
acfsutil info fs -h
acfsutil info fs [ {-o item|-s [interval [count] ] } ] [mount_point]
Example
$ /sbin/acfsutil info fs
/primary
flags: MountPoint,Available,Replication
volumes: 1
label:
flags: Primary,Available,ADVM
size: 5368709120
free: 4144230400
number of snapshots: 0
www.usefzadeh.com
vahidusefzadeh@gmail.com
/standby
flags: MountPoint,Available,Replication
volumes: 1
label:
flags: Primary,Available,ADVM
size: 5368709120
free: 5263945728
number of snapshots: 0
/primary
www.usefzadeh.com
vahidusefzadeh@gmail.com
/standby
/primary
/standby
/primary
/standby
...
www.usefzadeh.com
vahidusefzadeh@gmail.com
acfsutil info id
Displays Oracle ACFS file system information for a given identifier and mount point.
Syntax
acfsutil info id -h
acfsutil info id num mount_point
Example
Disables the Oracle ACFS plug-in infrastructure for an Oracle ACFS file system.
Syntax
Enables the Oracle ACFS plug-in infrastructure for an Oracle ACFS file system.
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
Displays information about the Oracle ACFS plug-in infrastructure for an Oracle ACFS file system.
Syntax
acfsutil registry
Registers an Oracle ACFS file system with the Oracle ACFS mount registry.
Syntax
acfsutil registry -h
acfsutil registry
www.usefzadeh.com
vahidusefzadeh@gmail.com
Example
acfsutil rmfs
Syntax
acfsutil rmfs -h
acfsutil rmfs device
Example
acfsutil size
Syntax
acfsutil size -h
acfsutil size [+|-]n[K|M|G|T|P ] mount_point
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
Converts the type of an existing snapshot image from read-only to read-write or read-write to read-only.
Syntax
Creates a read-only or read-write snapshot of an Oracle ACFS file system or an existing snapshot.
Syntax
$ ls /acfsmounts/critical_apps/.ACFS/snaps
www.usefzadeh.com
vahidusefzadeh@gmail.com
Syntax
Syntax
RO snapshot or RW snapshot: RW
RO snapshot or RW snapshot: RO
RO snapshot or RW snapshot: RO
www.usefzadeh.com
vahidusefzadeh@gmail.com
1 (delete pending)
acfsutil tune
The acfsutil tune command displays the value of a specific tunable parameter or all Oracle ACFS tunable
parameters, or sets the value of a tunable parameter in a persistent manner on a particular node.
Syntax
acfsutil tune -h
acfsutil tune [tunable_name]
acfsutil tune tunable_name=value
Examples
$ /sbin/acfsutil tune
advmutil canonical
advmutil canonical displays the canonical name of the specified Oracle ADVM device name.
Syntax
advmutil -h
advmutil canonical volume_device
Examples
asm-volume1-274
www.usefzadeh.com
vahidusefzadeh@gmail.com
asm-volume1-274
asm-volume1-274
asm-volume1-274
advmutil tune
advmutil tune displays the value of a specific Oracle ADVM parameter or sets the value of a specific
Oracle ADVM parameter.
Syntax
advmutil -h
advmutil tune parameter [= value]
Examples
deadlock_timer = 20 (0x14)
advmutil volinfo
Syntax
advmutil -h
advmutil volinfo [-l][-L] [volume_device]
Examples
www.usefzadeh.com
vahidusefzadeh@gmail.com
Device : /dev/asm/volume1-228
Interface Version: 1
Redundancy: mirror
Stripe Columns: 4
Volume: VOLUME1
Compatible.advm : 11.2.0.0.0
Compatible.advm : 11.2.0.0.0
Syntax
} ...
www.usefzadeh.com
vahidusefzadeh@gmail.com
Example
ATTRIBUTE 'au_size'='4M',
'compatible.asm' = '11.2',
'compatible.rdbms' = '11.2',
'compatible.advm' = '11.2';
OR
ALTER DISKGROUP
ALTER DISKGROUP
{ { diskgroup_name
{ { add_disk_clause | drop_disk_clause }
www.usefzadeh.com
vahidusefzadeh@gmail.com
| resize_disk_clause
} [ rebalance_diskgroup_clause ]
| { replace_disk_clause
| rename_disk_clause
| disk_online_clause
| disk_offline_clause
| rebalance_diskgroup_clause
| check_diskgroup_clause
| diskgroup_template_clauses
| diskgroup_directory_clauses
| diskgroup_alias_clauses
| diskgroup_volume_clauses
| diskgroup_attributes
| modify_diskgroup_file
| drop_diskgroup_file_clause
| usergroup_clauses
| user_clauses
| file_permissions_clause
| file_owner_clause
| scrub_clause
| ALL
} { undrop_disk_clause
www.usefzadeh.com
vahidusefzadeh@gmail.com
| diskgroup_availability
| enable_disable_volume
OR
ALTER DISKGROUP data1 ADD DISK '/devices/diska5' NAME diska5,'/devices/diska6' NAME diska6,
'/devices/diska7' NAME diska7,'/devices/diska8' NAME diska8;
OR
OR
SQL> ALTER DISKGROUP data2 REPLACE DISK diskc7 WITH '/devices/diskc18' POWER 3;
www.usefzadeh.com
vahidusefzadeh@gmail.com
SQL> ALTER DISKGROUP fra2 RENAME DISK 'FRA1_0001' TO 'FRA2_0001', 'FRA1_0002' TO 'FRA2_0002';
ALTER DISKGROUP data1 DROP DISK diska5 ADD FAILGROUP failgrp1 DISK '/devices/diska9' NAME diska9;
OR
SQL> ALTER DISKGROUP data SCRUB DISK DATA_0005 REPAIR POWER HIGH FORCE;
www.usefzadeh.com
vahidusefzadeh@gmail.com
rebalance operation
example
Dropping Disk
www.usefzadeh.com
vahidusefzadeh@gmail.com
Dropping Files
Creating a Directory
Renaming a Directory
Dropping a Directory
www.usefzadeh.com
vahidusefzadeh@gmail.com
chapter 4
EXPDP/IMPDP
ABORT_STEP
Used to stop the job after it is initialized. This allows the master table to be queried
Syntax
Example
ACCESS_METHOD
Syntax
Example
ATTACH
Syntax
ATTACH [=[schema_name.]job_name] Default: job currently in the user's schema, if there is only one
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
impdp hr ATTACH=import_job
CLUSTER
Determines whether Data Pump can use Oracle Real Application Clusters (Oracle
Syntax
Example
COMPRESSION
Syntax
Example
COMPRESSION_ALGORITHM
Specifies the compression algorithm to be used when compressing dump file data.
Syntax
Example
COMPRESSION_ALGORITHM=LOW
www.usefzadeh.com
vahidusefzadeh@gmail.com
OR
CONTENT
Syntax
Example
DATA_OPTIONS
The DATA_OPTIONS parameter designates how certain types of data should be handled
Syntax
Example
DIRECTORY
Syntax
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
DUMPFILE
Syntax
Example
ENCRYPTION
Syntax
Example
ENCRYPTION_ALGORITHM
Syntax
Example
ENCRYPTION_MODE
www.usefzadeh.com
vahidusefzadeh@gmail.com
Syntax
Example
ENCRYPTION_PASSWORD
Syntax
Example
ENCRYPTION_PWD_PROMPT
Specifies whether Data Pump should prompt you for the encryption password.
Syntax
Example
ESTIMATE
www.usefzadeh.com
vahidusefzadeh@gmail.com
Syntax
Example
ESTIMATE_ONLY
Syntax
Example
EXCLUDE
Syntax
EXCLUDE=object_type[:name_clause] [, ...]
Example
OR
EXCLUDE=FUNCTION
EXCLUDE=PROCEDURE
EXCLUDE=PACKAGE
www.usefzadeh.com
vahidusefzadeh@gmail.com
FILESIZE
Syntax
Example
FLASHBACK_SCN
Syntax
FLASHBACK_SCN=scn_value
Example
FLASHBACK_TIME
Syntax
FLASHBACK_TIME="TO_TIMESTAMP(time-value)"
Example
DIRECTORY=dpump_dir1
DUMPFILE=hr_time.dmp
database_link
www.usefzadeh.com
vahidusefzadeh@gmail.com
FULL
Syntax
Example
HELP
Syntax
Example
INCLUDE
Syntax
Example
SCHEMAS=HR
DUMPFILE=expinclude.dmp
DIRECTORY=dpump_dir1
LOGFILE=expinclude.log
www.usefzadeh.com
vahidusefzadeh@gmail.com
INCLUDE=PROCEDURE
INCLUDE=INDEX:"LIKE 'EMP%'"
expdp hr PARFILE=usef.par
OR
JOB_NAME
Syntax
JOB_NAME=jobname_string
Example
KEEP_MASTER
Indicates whether the master table should be deleted or retained at the end of a Data
Pump job that completes successfully. The master table is automatically retained for
Syntax
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
LOGFILE
Specifies the name, and optionally, a directory, for the log file of the export/import job.
Syntax
LOGFILE=[directory_object:]file_name
Example
LOGTIME
Syntax
Example
METRICS
Indicates whether additional information about the job should be reported to the Data
Syntax
METRICS=[YES | NO]
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
NETWORK_LINK
Syntax
NETWORK_LINK=source_database_link
Example
NOLOGFILE
Syntax
Example
PARALLEL
Syntax
PARALLEL=integer Default: 1
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
PARFILE
Syntax
Example
SCHEMAS=HR
DUMPFILE=exp.dmp
DIRECTORY=dpump_dir1
LOGFILE=exp.log
expdp hr PARFILE=usef.par
impdp hr PARFILE=hr_imp.par
QUERY
Syntax
Example
QUERY='sales:"WHERE EXISTS (SELECT cust_id FROM customers c WHERE cust_credit_limit > 10000 AND
ku$.cust_id = c.cust_id)"'
OR
QUERY='sales:"WHERE EXISTS (SELECT cust_id FROM customers c WHERE cust_credit_limit > 10000 AND cust_id =
c.cust_id)"'
expdp hr PARFILE=emp_query.par
REMAP_DATA
www.usefzadeh.com
vahidusefzadeh@gmail.com
Syntax
REMAP_DATA=[schema.]tablename.column_name:[schema.]pkg.function
Example
REUSE_DUMPFILES
Syntax
REUSE_DUMPFILES=[YES | NO]
Example
REMAP_DATAFILE
Syntax
REMAP_DATAFILE=source_datafile:target_datafile
Example
DIRECTORY=dpump_dir1
FULL=YES
DUMPFILE=db_full.dmp
REMAP_DATAFILE="'DB1$:[HRDATA.PAYROLL]tbs6.dbf':'/db1/hrdata/payroll/tbs6.dbf'"
www.usefzadeh.com
vahidusefzadeh@gmail.com
impdp hr PARFILE=payroll.par
REMAP_SCHEMA
Syntax
REMAP_SCHEMA=source_schema:target_schema
Example
REMAP_TABLE
Syntax
REMAP_TABLE=[schema.]old_tablename[.partition]:new_tablename
or
REMAP_TABLE=[schema.]old_tablename[:partition]:new_tablename
Example
REMAP_TABLESPACE
Syntax
REMAP_TABLESPACE=source_tablespace:target_tablespace
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
SQLFILE
Syntax
SQLFILE=[directory_object:]file_name
Example
TABLE_EXISTS_ACTION
Syntax
Example
SAMPLE
Syntax
SAMPLE="HR"."EMPLOYEES":50
Example
SCHEMAS
Syntax
SCHEMAS=schema_name [, ...]
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
SERVICE_NAME
Used to specify a service name to be used in conjunction with the CLUSTER parameter.
Syntax
SERVICE_NAME=name
Example
SOURCE_EDITION
Syntax
SOURCE_EDITION=edition_name
Example
STATUS
Syntax
STATUS=[integer]
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
SKIP_UNUSABLE_INDEXES
Specifies whether Import skips loading tables that have indexes that were set to the
Syntax
SKIP_UNUSABLE_INDEXES=[YES | NO]
Example
TABLES
Syntax
TABLES=[schema_name.]table_name[:partition_name] [, ...]
Example
TABLESPACES
Syntax
TABLESPACES=tablespace_name [, ...]
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
TRANSPORT_FULL_CHECK
Syntax
TRANSPORT_FULL_CHECK=[YES | NO]
Example
impdp hr PARFILE=full_check.par
TRANSPORT_TABLESPACES
Syntax
TRANSPORT_TABLESPACES=tablespace_name [, ...]
Example
DIRECTORY=dpump_dir1
NETWORK_LINK=source_database_link
TRANSPORT_TABLESPACES=tbs_6
TRANSPORT_FULL_CHECK=NO
TRANSPORT_DATAFILES='user01/data/tbs6.dbf'
impdp hr PARFILE=tablespaces.par
TRANSPORTABLE
Syntax
www.usefzadeh.com
vahidusefzadeh@gmail.com
Example
VERSION
Syntax
Example
VIEWS_AS_TABLES
Syntax
Example
www.usefzadeh.com
vahidusefzadeh@gmail.com
www.usefzadeh.com
vahidusefzadeh@gmail.com
chapter 5
RMAN
rman commands
rman
[ TARGET [=] ['] [userid][/[password]][@net_service_name] [']
| {CATALOG [=] ['] [userid][/[password]][@net_service_name] [']
| LOG [=] [']filename['] [APPEND]
...
]...
$ rman
$ rman NOCATALOG
$ rman TARGET SYS/pwd@target
$ rman TARGET SYS/pwd@target NOCATALOG
$ rman TARGET SYS/pwd@target LOG $ORACLE_HOME/dbs/my_log.log APPEND
$ rman CATALOG rman/pwd@catdb
$ rman TARGET=SYS/pwd@target CATALOG=rman/pwd@cat
$ rman TARGET / CATALOG rman/rman@cat
$ rman TARGET / SCRIPT dwh LOG /tmp/dwh.log
$ rman PIPE newpipe TARGET / TIMEOUT 90
$ rman @/my_dir/my_commands.txt
$ rman @backup_ts_generic.rman "/tmp" USERS
$ rman CMDFILE=backup_ts_users.rman
$ rman TARGET / @backup_db.rman
$ rman TARGET / CATALOG rman/pwd@cat CMDFILE cmdfile.rcv LOG outfile.txt
$ rman TARGET / CATALOG rman/pwd@cat DEBUG TRACE trace.log
$ rman TARGET SYS/pwd@prod CATALOG rman/rman@rcat @'/oracle/dbs/whole.rcv'
$ rman TARGET user/pwd CMDFILE=takefulldb.cmd @@takefulldb.cmd
$ rman CHECKSYNTAX @'/tmp/backup_db.cmd'
$ rman MSGNO
$ rman | tee rman.log
$ rman help=yes
www.usefzadeh.com
vahidusefzadeh@gmail.com
CONNECT command
Establish a connection between RMAN and a target, auxiliary, or recovery catalog database.
RMAN> CONNECT TARGET;
RMAN> CONNECT TARGET /
RMAN> CONNECT TARGET sys@tgt;
RMAN> CONNECT TARGET sys/pwd@tgt;
RMAN> CONNECT CATALOG rman@catdb;
RMAN> CONNECT CATALOG rman/pwd@catdb;
RMAN> CONNECT AUXILIARY /
RMAN> CONNECT AUXILIARY rman@auxdb;
RMAN> CONNECT AUXILIARY rman/pwd@auxdb;
www.usefzadeh.com
vahidusefzadeh@gmail.com
REGISTER command
Register the target database in the recovery catalog.
RMAN> REGISTER DATABASE;
RMAN> REGISTER CATALOG;
RMAN> REGISTER CATALOG TABLESPACE tbs-name;
www.usefzadeh.com
vahidusefzadeh@gmail.com
UNREGISTER command
Unregister a Oracle database from the recovery catalog.
RMAN> UNREGISTER DATABASE;
RMAN> UNREGISTER DATABASE NOPROMPT;
RMAN> UNREGISTER DATABASE prod1;
RMAN> UNREGISTER DATABASE prod2 NOPROMPT;
RMAN> UNREGISTER DB_UNIQUE_NAME prod2;
RMAN> UNREGISTER DB_UNIQUE_NAME prod1 NOPROMPT;
RMAN> UNREGISTER DB_UNIQUE_NAME prod2 INCLUDING BACKUPS;
RMAN> UNREGISTER DB_UNIQUE_NAME prod3 INCLUDING BACKUPS NOPROMPT;
GRANT command
Grant privileges to a recovery catalog user.
RMAN> GRANT CATALOG FOR DATABASE prod1 TO vpc1;
RMAN> GRANT REGISTER DATABASE TO bckop2;
RMAN> GRANT RECOVERY_CATALOG_OWNER TO rmanop1, rmanop3;
REVOKE command
www.usefzadeh.com
vahidusefzadeh@gmail.com
STARTUP command
Startup the target database. This command is equivalent to the SQL*Plus STARTUP command.
RMAN> STARTUP;
RMAN> STARTUP PFILE=’/u01/app/oracle/admin/pfile/initsid.ora’
RMAN> STARTUP NOMOUNT;
RMAN> STARTUP MOUNT;
RMAN> STARTUP FORCE;
RMAN> STARTUP FORCE DBA;
RMAN> STARTUP FORCE DBA PFILE=c:\Oracle\Admin\pfile\init.ora;
RMAN> STARTUP FORCE NOMOUNT;
RMAN> STARTUP FORCE MOUNT DBA PFILE=/tmp/inittrgt.ora;
RMAN> STARTUP AUXILIARY nomount;
SHUTDOWN command
Shutdown the target database. This command is equivalent to the SQL*Plus SHUTDOWN command.
RMAN> SHUTDOWN;
RMAN> SHUTDOWN NORMAL;
RMAN> SHUTDOWN TRANSACTIONAL;
RMAN> SHUTDOWN IMMEDIATE;
RMAN> SHUTDOWN ABORT;
www.usefzadeh.com
vahidusefzadeh@gmail.com
SHOW command
Display the current CONFIGURE settings.
SHOW
{ RETENTION POLICY
| BACKUP OPTIMIZATION
| [DEFAULT] DEVICE TYPE
| CONTROLFILE AUTOBACKUP [FORMAT]
| [AUXILIARY] CHANNEL [FOR DEVICE TYPE deviceSpecifier]
| MAXSETSIZE
| DATAFILE BACKUP COPIES
| ARCHIVELOG [BACKUP COPIES|DELETION POLICY]
| AUXNAME
| EXCLUDE
| ENCRYPTION {ALGORITHM | FOR [DATABASE|TABLESPACE]}
| COMPRESSION ALGORITHM
| SNAPSHOT CONTROLFILE NAME
| DB_UNIQUE_NAME
| ALL
} FOR *DB_UNIQUE_NAME *‘db_unique_name’|ALL++;
www.usefzadeh.com
vahidusefzadeh@gmail.com
www.usefzadeh.com
vahidusefzadeh@gmail.com
CONFIGURE command
To configure persistent RMAN settings. These settings apply to all RMAN sessions until explicitly
changed or disabled.
CONFIGURE deviceConf;
CONFIGURE backupConf;
CONFIGURE AUXNAME FOR DATAFILE datafileSpec {TO 'filename' | CLEAR};
CONFIGURE SNAPSHOT CONTROLFILE NAME {TO 'filename' | CLEAR};
CONFIGURE cfauConf;
CONFIGURE ARCHIVELOG DELETION POLICY
{CLEAR | TO {APPLIED ON [ALL] STANDBY | BACKED UP integer TIMES TO DEVICE TYPE deviceSpecifier
| NONE | SHIPPED TO [ALL] STANDBY}
[{APPLIED ON [ALL] STANDBY | BACKED UP integer TIMES TO DEVICE TYPE deviceSpecifier |
NONE | SHIPPED TO *ALL+ STANDBY}+ …
}
deviceConf::=
{ DEFAULT DEVICE TYPE { TO deviceSpec | CLEAR }
| DEVICE TYPE deviceSpec { PARALLELISM integer | CLEAR }
| [AUXILIARY] CHANNEL [integer] DEVICE TYPE deviceSpec {allocOperandList|CLEAR}
}
allocOperandList::=
{ PARMS [=] 'channel_parms'
| FORMAT [=] 'format_string' [, 'format_string']...
| { MAXPIECESIZE [=] integer | RATE [=] integer } [K | M | G]
...
}...
connectStringSpec::=
['] [userid] [/[password]] [@net_service_name] [']
www.usefzadeh.com
vahidusefzadeh@gmail.com
backupConf::=
{RETENTION POLICY {TO {RECOVERY WINDOW OF integer DAYS
| REDUNDANCY [=] integer | NONE
}
| CLEAR
}
| MAXSETSIZE {TO {integer [K | M | G]| UNLIMITED}
| CLEAR
}
| {ARCHIVELOG | DATAFILE}
BACKUP COPIES FOR DEVICE TYPE deviceSpec {TO integer | CLEAR}
| BACKUP OPTIMIZATION {ON | OFF | CLEAR}
| EXCLUDE FOR TABLESPACE tablespace_name [CLEAR]
}
cfauConf::==
CONTROLFILE AUTOBACKUP {ON | OFF | CLEAR | FORMAT FOR DEVICE TYPE deviceSpec {TO 'format
string'|CLEAR}}
www.usefzadeh.com
vahidusefzadeh@gmail.com
www.usefzadeh.com
vahidusefzadeh@gmail.com
SET command
Set the value of various attributes that affect RMAN behaviour for the duration of a RUN block or a
session.
set_rman_option::=
{ECHO {ON|OFF} | DBID [=] integer
| CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE deviceSpec TO 'frmt_string'
www.usefzadeh.com
vahidusefzadeh@gmail.com
set_run_option::=
{ NEWNAME FOR DATAFILE datafileSpec TO {'filename' | NEW}
| ARCHIVELOG DESTINATION TO 'log_archive_dest'
| untilClause
| COMMAND ID TO 'string'
| CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE deviceSpec TO 'frmt_string'
...
}
ECHO - Controls whether RMAN commands are displayed in the message log.
DBID - A unique 32-bit identification number computed when the database is created. RMAN displays
the DBID upon connection to the target database. We can obtain the DBID by querying V$DATABASE or
RC_DATABASE.
NEWNAME FOR DATAFILE - The default name for all subsequent RESTORE or SWITCH commands that
affect the specified datafile.
MAXCORRUPT FOR DATAFILE - A limit on the number of previously undetected physical block
corruptions that Oracle will allow in the datafile(s).
AUTOLOCATE - Force RMAN to automatically discover which nodes of an Oracle Real Application
Clusters configuration contain the backups that you want to restore.
www.usefzadeh.com
vahidusefzadeh@gmail.com
RMAN> SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE sbt TO 'cf_%F';
RMAN> SET CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO 'cf_%F.bak';
RMAN> SET UNTIL TIME ’04-23-2010:23:50:04’;
RMAN> SET ARCHIVELOG DESTINATION TO '/oracle/temp_restore';
RMAN> SET COMPRESSION ALGORITHM 'LOW';
RMAN> SET COMPRESSION ALGORITHM 'LOW' OPTIMIZE FOR LOAD FALSE;
RMAN> SET COMPRESSION ALGORITHM 'MEDIUM';
RMAN> SET COMPRESSION ALGORITHM 'HIGH';
BACKUP command
Backs up Oracle database files, copies of database files, archived logs, or backup sets.
Options::=
[backupOperand [backupOperand]...] backupSpec [backupSpec]...
[PLUS ARCHIVELOG [backupSpecOperand [backupSpecOperand]...]];
www.usefzadeh.com
vahidusefzadeh@gmail.com
backupOperand::=
{ FORMAT [=] 'format_string' [, 'format_string']...
| CHANNEL ['] channel_id [']
| CUMULATIVE
| MAXSETSIZE [=] integer [K | M | G]
| TAG [=] ['] tag_name [']
| keepOption
| SKIP {OFFLINE | READONLY | INACCESSIBLE}
| VALIDATE
| NOT BACKED UP [SINCE TIME [=] 'date_string']
| COPIES [=] integer
| DEVICE TYPE deviceSpecifier
...
}
backupSpec::=
[(]
{ BACKUPSET
{ {ALL | completedTimeSpec } | primary_key) [, primary_key]... }
| COPY OF { DATABASE
| TABLESPACE ['] tablespace_name ['] [, ['] tablespace_name [']]...
| DATAFILE datafileSpec [, datafileSpec]...
}
| DATAFILE datafileSpec [, datafileSpec]...
| DATAFILECOPY 'filename' [, 'filename']...
| DATAFILECOPY FROM TAG [=] ['] tag_name ['] [, ['] tag_name [']]...
| DATAFILECOPY { ALL | LIKE 'string_pattern' }
| TABLESPACE ['] tablespace_name ['] [, ['] tablespace_name [']]...
| DATABASE
| archivelogRecordSpecifier
| CURRENT CONTROLFILE [FOR STANDBY]
www.usefzadeh.com
vahidusefzadeh@gmail.com
| CONTROLFILECOPY 'filename'
| SPFILE
}
[backupSpecOperand [backupSpecOperand]...]
backupSpecOperand::=
{ FORMAT [=] 'format_string' [, 'format_string']...
| CHANNEL ['] channel_id [']
| CUMULATIVE
| MAXSETSIZE [=] integer [K | M | G]
| TAG [=] ['] tag_name [']
| keepOption
| SKIP {OFFLINE | READONLY | INACCESSIBLE}
| NOT BACKED UP [SINCE TIME [=] 'date_string' | integer TIMES]
| DELETE [ALL] INPUT
...
}
www.usefzadeh.com
vahidusefzadeh@gmail.com
www.usefzadeh.com
vahidusefzadeh@gmail.com
www.usefzadeh.com
vahidusefzadeh@gmail.com
BACKUP set
RMAN> BACKUP BACKUPSET ALL;
RMAN> BACKUP BACKUPSET ALL FORMAT = ‘/u01/.../backup_%u.bak’;
RMAN> BACKUP BACKUPSET COMPLETED BEFORE ‘SYSDATE-3’ DELETE INPUT;
RMAN> BACKUP DEVICE TYPE sbt BACKUPSET COMPLETED BEFORE 'SYSDATE-14' DELETE INPUT;
RMAN> BACKUP COPIES 2 DEVICE TYPE sbt BACKUPSET ALL;
RMAN> BACKUP AS COMPRESSED BACKUPSET;
RMAN> BACKUP AS COMPRESSED BACKUPSET DEVICE TYPE DISK COPIES 2 DATABASE FORMAT
'/disk1/db_%U', '/disk2/db_%U';
RMAN> BACKUP AS COMPRESSED BACKUPSET INCREMENTAL FROM SCN 4111140000000 DATABASE
TAG 'RMAN_RECOVERY';
RMAN> BACKUP AS BACKUPSET DATAFILE
'$ORACLE_HOME/oradata/users01.dbf','$ORACLE_HOME/oradata/tools01.dbf';
RMAN> BACKUP AS BACKUPSET DATAFILECOPY ALL;
RMAN> BACKUP AS BACKUPSET DATAFILECOPY ALL NODUPLICATES;
IMAGE copy
RMAN> BACKUP AS COPY DATABASE;
RMAN> BACKUP AS COPY COPY OF DATABASE FROM TAG 'test' CHECK LOGICAL TAG 'duptest';
RMAN> BACKUP AS COPY TABLESPACE 8;
RMAN> BACKUP AS COPY TABLESPACE test;
RMAN> BACKUP AS COPY TABLESPACE system, tools, users, undotbs;
RMAN> BACKUP AS COPY DATAFILE 1;
RMAN> BACKUP AS COPY DATAFILE 2 FORMAT '/disk2/df2.cpy' TAG my_tag;
RMAN> BACKUP AS COPY CURRENT CONTROLFILE;
RMAN> BACKUP AS COPY CURRENT CONTROLFILE FORMAT ‘/....’;
RMAN> BACKUP AS COPY ARCHIVELOG ALL;
RMAN> BACKUP AS COPY KEEP FOREVER NOLOGS CURRENT CONTROLFILE FORMAT
'?/oradata/cf_longterm.cpy', DATAFILE 1 FORMAT '?/oradata/df1_longterm.cpy', DATAFILE 2 FORMAT
www.usefzadeh.com
vahidusefzadeh@gmail.com
'?/oradata/df2_longterm.cpy';
RMAN> BACKUP AS COPY DATAFILECOPY 'bar' FORMAT 'foobar';
RMAN> BACKUP AS COPY DATAFILECOPY '/disk2/df2.cpy' FORMAT '/disk1/df2.cpy';
RMAN> BACKUP AS COPY REUSE TARGETFILE '/u01/oracle/11.2.0.2/dbs/orapwcrd' AUXILIARY FORMAT
'/u01/oracle/11.2.0.2/dbs/orapwcrd';
RMAN> BACKUP AS COPY CURRENT CONTROLFILE FOR STANDBY AUXILIARY format
'+DATA/crd/data1/control01.ctl';
Incremental backups
RMAN> BACKUP INCREMENTAL LEVEL=0 DATABASE;
RMAN> BACKUP INCREMENTAL LEVEL=1 DATABASE;
RMAN> BACKUP INCREMENTAL LEVEL=0 DATABASE PLUS ARCHIVELOG;
RMAN> BACKUP INCREMENTAL LEVEL 1 CUMULATIVE SKIP INACCESSIBLE DATABASE;
RMAN> BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'incr' DATABASE;
RMAN> BACKUP DEVICE TYPE DISK INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'oltp'
DATABASE;
RMAN> BACKUP DEVICE TYPE DISK INCREMENTAL FROM SCN 351986 DATABASE FORMAT
'/tmp/incr_standby_%U';
RMAN> BACKUP INCREMENTAL FROM SCN 629184 DATAFILE 5 FORMAT '/tmp/ForStandby_%U' TAG
'FORSTANDBY';
LIST command
Produce a detailed listing of backup sets or copies.
LIST
{ INCARNATION [OF DATABASE [[']database_name[']]]
| [EXPIRED] {listObjectSpec
www.usefzadeh.com
vahidusefzadeh@gmail.com
listObjectSpec::=
{BACKUP [OF listObjectList] [listBackupOption] | COPY [OF listObjectList] | archivelogRecordSpecifier}
listObjectList::=
[ DATAFILE datafileSpec [, datafileSpec]...
| TABLESPACE [']tablespace_name['] [, [']tablespace_name[']]...
| archivelogRecordSpecifier
| DATABASE [SKIP TABLESPACE [']tablespace_name['] [, [']tablespace_name[']] ...]
| CONTROLFILE
| SPFILE
]...
listBackupOption::=
[[BY BACKUP] [VERBOSE] | SUMMARY | BY {BACKUP SUMMARY|FILE}]
www.usefzadeh.com
vahidusefzadeh@gmail.com
www.usefzadeh.com
vahidusefzadeh@gmail.com
REPORT command
Report backup status: database, files, and backups. Perform detailed analyses of the content of the
recovery catalog.
REPORT
{{NEED BACKUP [{INCREMENTAL | DAYS} [=] integer| REDUNDANCY [=] integer | RECOVERY WINDOW
OF integer DAYS)]
| UNRECOVERABLE
}
reportObject
| SCHEMA [atClause]
| OBSOLETE [obsOperandList]
}
[DEVICE TYPE deviceSpecifier [,deviceSpecifier]... ]
reportObject::=
[ DATAFILE datafileSpec [, datafileSpec]...
| TABLESPACE [']tablespace_name['] [, [']tablespace_name[']] ...
| DATABASE [SKIP TABLESPACE [']tablespace_name['] [, [']tablespace_name[']] ...]
]
atClause::=
{AT TIME [=] 'date_string' | AT SCN [=] integer|AT SEQUENCE [=] integer THREAD [=] integer
}
obsOperandList::=
[REDUNDANCY [=] integer | RECOVERY WINDOW OF integer DAYS | ORPHAN]...
www.usefzadeh.com
vahidusefzadeh@gmail.com
CHANGE command
Update the status of a backup in the RMAN repository. Mark a backup piece, image copy, or archived
redo log as having the status UNAVAILABLE or AVAILABLE; remove the repository record for a backup or
copy; override the retention policy for a backup or copy; update the recovery catalog with the
DB_UNIQUE_NAME for the target database.
listObjList::=
[DATAFILE datafileSpec [, datafileSpec]...
www.usefzadeh.com
vahidusefzadeh@gmail.com
recordSpec::=
{{BACKUPPIECE | PROXY}
{'media_handle' [, 'media_handle']... | primary_key [, primary_key]... | TAG [=] ['] tag_name [']
}
| BACKUPSET primary_key [, primary_key]...
| {CONTROLFILECOPY | DATAFILECOPY}
{{primary_key [, primary_key]... | 'filename' [, 'filename']...}
| TAG [=] ['] tag_name ['] [, ['] tag_name [']]...
}
| ARCHIVELOG {primary_key [, primary_key]... | 'filename' [, 'filename']...}
}
www.usefzadeh.com
vahidusefzadeh@gmail.com
CROSSCHECK command
Check whether files managed by RMAN, such as archived logs, datafile copies, and backup pieces, still
exist on disk or tape.
CROSSCHECK
{{BACKUP [OF listObjList] | COPY [OF listObjList] | archivelogRecordSpecifier} [maintQualifier
[maintQualifier]...]
| recordSpec [DEVICE TYPE deviceSpecifier [, deviceSpecifier]...]
};
listObjList::=
[ DATAFILE datafileSpec [, datafileSpec]...
| TABLESPACE ['] tablespace_name ['] [, ['] tablespace_name [']]...
| archivelogRecordSpecifier
| DATABASE [SKIP TABLESPACE [']tablespace_name['] [, [']tablespace_name[']] ...]
| CONTROLFILE
| SPFILE
]...
recordSpec::=
{{ BACKUPPIECE | PROXY }
www.usefzadeh.com
vahidusefzadeh@gmail.com
www.usefzadeh.com
vahidusefzadeh@gmail.com
SQL command
Execute a SQL statement from within Recovery Manager.
RESTORE command
Restore files from backup sets or from disk copies to the default or a new location.
RESTORE
[(] restoreObject [(restoreSpecOperand [restoreSpecOperand]...] [)]...
[ CHANNEL ['] channel_id [']
| PARMS [=] 'channel_parms'
| FROM { BACKUPSET | DATAFILECOPY }
www.usefzadeh.com
vahidusefzadeh@gmail.com
| untilClause
| FROM TAG [=] ['] tag_name [']
| VALIDATE
| DEVICE TYPE deviceSpecifier [, deviceSpecifier]...
]...;
restoreObject::=
{ CONTROLFILE [TO 'filename']
| DATABASE [SKIP [FOREVER] TABLESPACE [']tablespace_name['] [, [']tablespace_name[']] ...]
| DATAFILE datafileSpec [, datafileSpec]...
| TABLESPACE ['] tablespace_name ['] [, ['] tablespace_name [']]...
| archivelogRecordSpecifier
| SPFILE [TO [PFILE] 'filename']
}
restoreSpecOperand::=
{ CHANNEL ['] channel_id ['] | FROM TAG [=] ['] tag_name ['] | PARMS [=] 'channel_parms'
| FROM {AUTOBACKUP [{MAXSEQ | MAXDAYS} [=] integer)]... | 'media_handle'}
}
www.usefzadeh.com
vahidusefzadeh@gmail.com
Restore the control file, (to all locations specified in the parameter file) then restore the database, using
that control file:
STARTUP NOMOUNT;
RUN
{
ALLOCATE CHANNEL c1 DEVICE TYPE sbt;
RESTORE CONTROLFILE;
ALTER DATABASE MOUNT;
RESTORE DATABASE;
www.usefzadeh.com
vahidusefzadeh@gmail.com
RECOVER command
Perform media recovery from RMAN backups and copies. Apply redo log files and incremental backups
to datafiles or data blocks restored from backup or datafile copies, to update them to a specified time.
recoverObject::=
{ DATABASE
[ untilClause
| [untilClause] SKIP [FOREVER] TABLESPACE [']tablespace_name['] [, [']tablespace_name[']] ...]
| TABLESPACE [']tablespace_name['] [, [']tablespace_name[']]...
| DATAFILE datafileSpec [, datafileSpec]...
}
recoverOptionList::=
{ DELETE ARCHIVELOG [MAXSIZE {integer [K | M | G]}]
| CHECK READONLY
| NOREDO
| {FROM TAG | ARCHIVELOG TAG} [=] ['] tag_name [']
...
}
www.usefzadeh.com
vahidusefzadeh@gmail.com
www.usefzadeh.com
vahidusefzadeh@gmail.com
DELETE command
Delete backups and copies, remove references to them from the recovery catalog, and update their
control file records to status DELETED.
recordSpec::=
{ { BACKUPPIECE | PROXY }
{ 'media_handle' [, 'media_handle']...| primary_key [, primary_key]...| TAG [=] ['] tag_name ['] }
| BACKUPSET primary_key [, primary_key]...
| { CONTROLFILECOPY | DATAFILECOPY }
www.usefzadeh.com
vahidusefzadeh@gmail.com
listObjectList::=
[ DATAFILE datafileSpec [, datafileSpec]...
| TABLESPACE ['] tablespace_name ['] [, ['] tablespace_name [']]...
| archivelogRecordSpecifier
| DATABASE [SKIP TABLESPACE [']tablespace_name['] [, [']tablespace_name[']] ...]
| CONTROLFILE
| SPFILE
]...
www.usefzadeh.com
vahidusefzadeh@gmail.com
DUPLICATE command
Use backups of the target database to create a duplicate database that we can use for testing purposes
or to create a standby database.
RMAN> DUPLICATE TARGET DATABASE;
RMAN> DUPLICATE TARGET DATABASE TO dwhdb;
RMAN> DUPLICATE TARGET DATABASE TO test PFILE=/u01/apps/db/inittest.ora;
www.usefzadeh.com
vahidusefzadeh@gmail.com
www.usefzadeh.com
vahidusefzadeh@gmail.com
SWITCH command
Specify that a datafile copy is now the current datafile, i.e. the datafile pointed to by the control file. This
command is equivalent to the SQL statement ALTER DATABASE RENAME FILE as it applies to datafiles.
RMAN> SWITCH DATABASE TO COPY;
RMAN> SWITCH TABLESPACE users TO COPY;
RMAN> SWITCH DATAFILE ALL;
RMAN> SWITCH DATAFILE '/disk1/tols.dbf' TO DATAFILECOPY '/disk2/tols.copy';
RMAN> SWITCH DATAFILE "+DG_OLD/db/datafile/sysaux.260.699468081" TO COPY;
RMAN> SWITCH TEMPFILE 1;
RMAN> SWITCH TEMPFILE 1 TO '/newdisk/dbs/temp1.f';
RMAN> SWITCH TEMPFILE ALL;
RMAN> SWITCH CLONE DATAFILE ALL;
CATALOG command
Add information about file copies and user-managed backups to the catalog repository.
RMAN> CATALOG DATAFILECOPY '/disk1/old_datafiles/01_10_2009/users01.dbf';
RMAN> CATALOG DATAFILECOPY '/disk2/backup/users01.bkp' LEVEL 0;
RMAN> CATALOG CONTROLFILECOPY '/disk3/backup/cf_copy.bkp';
RMAN> CATALOG ARCHIVELOG '/disk1/arch1_731.dbf', '/disk1/arch1_732.dbf';
RMAN> CATALOG BACKUPPIECE '/disk1/c-874220581-20090428-01';
RMAN> CATALOG LIKE '/backup';
RMAN> CATALOG START WITH '/fs2/arch';
RMAN> CATALOG START WITH '/disk2/archlog' NOPROMPT;
RMAN> CATALOG START WITH '+dg2';
RMAN> CATALOG RECOVERY AREA;
www.usefzadeh.com
vahidusefzadeh@gmail.com
ALLOCATE command
Establish a channel, which is a connection between RMAN and a database instance.
RMAN> ALLOCATE CHANNEL c1 DEVICE TYPE sbt;
RMAN> ALLOCATE CHANNEL ch DEVICE TYPE DISK FORMAT ‘C:\ORACLEBKP\DB_U%’;
RMAN> ALLOCATE CHANNEL t1 DEVICE TYPE DISK CONNECT 'sys/pwd@bkp1’;
RMAN> ALLOCATE CHANNEL c1 DEVICE TYPE sbt PARMS 'ENV=(OB_MEDIA_FAMILY=wholedb_mf)';
RMAN> ALLOCATE CHANNEL t1 DEVICE TYPE sbt PARMS 'ENV=(OB_DEVICE_1=tape1,
OB_DEVICE_2=tape3)';
RMAN> ALLOCATE CHANNEL t1 TYPE 'sbt_tape'
PARMS='SBT_LIBRARY=/usr/openv/netbackup/bin/libobk.so.1';
RMAN> ALLOCATE CHANNEL t1 TYPE 'sbt_tape' SEND "NB_ORA_CLIENT=CLIENT_MACHINE_NAME";
RMAN> ALLOCATE CHANNEL 'dev1' TYPE 'sbt_tape' PARMS 'ENV=OB2BARTYPE=ORACLE8,
OB2APPNAME=USEFDB, OB2BARLIST=MACHINENAME_USEFDB_ARCHLOGS)';
RMAN> ALLOCATE CHANNEL y1 TYPE DISK RATE 70M;
RMAN> ALLOCATE AUXILIARY CHANNEL ac1 TYPE DISK;
RMAN> ALLOCATE AUXILIARY CHANNEL ac2 DEVICE TYPE sbt;
ALLOCATE CHANNEL FOR MAINTENANCE - allocate a channel in preparation for issuing maintenance
commands such as DELETE.
RMAN> ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE DISK;
RMAN> ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE DISK FORMAT "/disk2/%U";
RMAN> ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE DISK CONNECT '@test1';
RMAN> ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE sbt;
RMAN> ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE sbt PARMS
'SBT_LIBRARY=/usr/local/oracle/backup/lib/libobk.so, ENV=(OB_DEVICE_1=tape2)';
www.usefzadeh.com
vahidusefzadeh@gmail.com
Release a channel that was allocated with an ALLOCATE CHANNEL or ALLOCATE CHANNEL FOR
MAINTENANCE command.
RMAN> RELEASE CHANNEL;
RMAN> RELEASE CHANNEL c1;
BLOCKRECOVER command
Will recover the corrupted blocks.
RMAN> BLOCKRECOVER CORRUPTION LIST;
RMAN> BLOCKRECOVER DATAFILE 8 BLOCK 22;
RMAN> BLOCKRECOVER DATAFILE 7 BLOCK 233,235 DATAFILE 4 BLOCK 101;
RMAN> BLOCKRECOVER DATAFILE 2 BLOCK 12,13 DATAFILE 3 BLOCK 5,98,99 DATAFILE 4 BLOCK 19;
RMAN> BLOCKRECOVER DATAFILE 3 BLOCK 2,4,5 TABLESPACE sales DBA 4194405,4194412 FROM
DATAFILECOPY;
RMAN> BLOCKRECOVER TABLESPACE dwh DBA 4194404,4194405 FROM TAG "weekly";
RMAN> BLOCKRECOVER TABLESPACE dwh DBA 94404 RESTORE UNTIL TIME 'SYSDATE-2';
www.usefzadeh.com
vahidusefzadeh@gmail.com
VALIDATE command
Examine a backup set and report whether its data is intact. RMAN scans all of the backup pieces in the
specified backup sets and looks at the checksums to verify that the contents can be successfully
restored.
RMAN> VALIDATE BACKUPSET 218;
RMAN> VALIDATE BACKUPSET 3871, 3890;
RMAN> VALIDATE DATABASE;
RMAN> VALIDATE CHECK LOGICAL DATABASE;
RMAN> VALIDATE SKIP INACCESSIBLE DATABASE;
RMAN> VALIDATE COPY OF DATABASE;
RMAN> VALIDATE TABLESPACE dwh;
RMAN> VALIDATE COPY OF TABLESPACE dwh;
RMAN> VALIDATE DATAFILE 2;
RMAN> VALIDATE DATAFILE 4,8;
RMAN> VALIDATE DATAFILE 4 BLOCK 56;
RMAN> VALIDATE DATAFILE 8 SECTION SIZE = 200M;
RMAN> VALIDATE CURRENT CONTROLFILE;
RMAN> VALIDATE SPFILE;
RMAN> VALIDATE RECOVERY FILES;
RMAN> VALIDATE RECOVERY AREA;
www.usefzadeh.com
vahidusefzadeh@gmail.com
SPOOL command
Write RMAN output to a log file.
RMAN> SPOOL LOG TO '/tmp/spool.log';
RMAN> SPOOL LOG TO '/tmp/backup.log' APPEND;
RMAN> SPOOL LOG OFF;
run command
Execute a sequence of one or more RMAN commands, which are one or more statements executed
within the braces of RUN.
RMAN> run {
ALLOCATE CHANNEL c1 TYPE DISK FORMAT '/orabak/%U';
BACKUP TABLESPACE users;
}
RMAN> run {
ALLOCATE CHANNEL c1 TYPE DISK FORMAT '&1/%U';
BACKUP TABLESPACE &2;
}
RMAN> run
{
ALLOCATE CHANNEL dev1 DEVICE TYPE DISK FORMAT '/fs1/%U';
ALLOCATE CHANNEL dev2 DEVICE TYPE DISK FORMAT '/fs2/%U';
BACKUP(TABLESPACE system,fin,mark FILESPERSET 20) (DATAFILE 2,3,6);
}
www.usefzadeh.com
vahidusefzadeh@gmail.com
RMAN> CREATE SCRIPT df {BACKUP DATAFILE &1 TAG &2.1 FORMAT '/disk1/&3_%U';}
RMAN> CREATE SCRIPT backup_ts_users FROM FILE 'backup_ts_users.rman';
RMAN> CREATE GLOBAL SCRIPT gl_backup_db {BACKUP DATABASE PLUS ARCHIVELOG;}
RMAN> CREATE GLOBAL SCRIPT backup_db
COMMENT "back up any database from the recovery catalog, with logs"
{BACKUP DATABASE;}
www.usefzadeh.com
vahidusefzadeh@gmail.com
www.usefzadeh.com
vahidusefzadeh@gmail.com
CONVERT command
Convert datafile formats for transporting tablespaces and databases across platforms.
RMAN> CONVERT DATABASE NEW DATABASE 'prodwin' TRANSPORT SCRIPT
'/tmp/convertdb/transportscript' TO PLATFORM 'Microsoft Windows IA (32-bit)'
DB_FILE_NAME_CONVERT '/disk1/oracle/dbs','/tmp/convertdb';
RMAN> CONVERT DATABASE ON DESTINATION PLATFORM CONVERT SCRIPT
'/tmp/convertdb/convertscript.rman' TRANSPORT SCRIPT '/tmp/convertdb/transportscript.sql' NEW
DATABASE 'prodwin' FORMAT '/tmp/convertdb/%U';
RMAN> CONVERT DATABASE ON DESTINATION PLATFORM CONVERT SCRIPT
'/tmp/convert_newdb.rman' TRANSPORT SCRIPT '/tmp/transport_newdb.sql' NEW DATABASE 'prodaix'
DB_FILE_NAME_CONVERT '/u01/oradata/datafile','+DATA';
www.usefzadeh.com
vahidusefzadeh@gmail.com
RMAN> exit;
RMAN> quit;
SEND command
Send a vendor-specific quoted string to one or more specific channels.
RMAN> SEND 'OB_DEVICE tape1';
HOST command
Invoke an operating system command-line subshell from within RMAN or run a specific operating
system command.
www.usefzadeh.com
vahidusefzadeh@gmail.com
RMAN> HOST;
RMAN> HOST 'ls -lt /disk2/*';
RMAN> HOST '/bin/mv $ORACLE_HOME/dbs/*.arc /disk2/archlog/';
www.usefzadeh.com
vahidusefzadeh@gmail.com
chapter 6
data guard
ALTER DATABASE ADD STANDBY LOGFILE '<path_and_file_name>' SIZE <integer> <M | G>;
select group#, bytes, 'online' as type from v$log union select group#, bytes,'standby' as type from
v$standby_log order by 1;
www.usefzadeh.com
vahidusefzadeh@gmail.com
--switchover
ALTER DATABASE <PREPARE | COMMIT> TO SWITCHOVER TO PHYSICAL STANDBY [WITH SESSION SHUTDOWN];
-- FAILOVER
--REGISTER LOGFILE
www.usefzadeh.com
vahidusefzadeh@gmail.com
--CREATE DATAFILE
--RENAME DATAFILE
-- Unsupported Operations
--DG_CONFIG
www.usefzadeh.com
vahidusefzadeh@gmail.com
--Protection Mode
---Maximum Performance
OR
---Maximum Protection
---Maximum Availability
FOR STANDBY
VALID_FOR=(online_logfile,primary_role)"
NOFILENAMECHECK;
--Backup-Based Duplication
www.usefzadeh.com
vahidusefzadeh@gmail.com
SPFILE
VALID_FOR=(online_logfile,primary_role)"
NOFILENAMECHECK;
$ DGMGRL
CONNECT username[@connect-identifier]
www.usefzadeh.com
vahidusefzadeh@gmail.com
Connected.
Error:
ORA-06512: at line 1
System altered.
Connected.
DGMGRL> exit
--Disable a configuration
DISABLE CONFIGURATION;
--Disable a database
www.usefzadeh.com
vahidusefzadeh@gmail.com
www.usefzadeh.com
vahidusefzadeh@gmail.com
Database State
--Edit Instance
--Enable Configuration
ENABLE CONFIGURATION;
--Enable Database
www.usefzadeh.com
vahidusefzadeh@gmail.com
Inaccessible Logfile LGWR is unable to write to any member of a log group due to an I/O error
Stuck Archiver Archiver is unable to archive a redo log because device is full or unavailable
EXIT;
DGMGRL> EXIT;
HELP;
DGMGRL> HELP;
QUIT;
DGMGRL> QUIT;
rem <remark_string>;
www.usefzadeh.com
vahidusefzadeh@gmail.com
--Removes config info, including all DB profiles and terminates management of all of associated databases
--Removes config info, including all DB profiles and terminates management of all of associated databases
--Removes the specified standby database's profile from the broker configuration and terminates broker
management of the standby database
www.usefzadeh.com
vahidusefzadeh@gmail.com
DGMGRL> STARTUP;
STOP OBSERVER;
SWITCHOVER TO <database-name>;
--useful query:
select THREAD#,max(SEQUENCE#) from gv$archived_log where applied='YES'and RESETLOGS_ID=865773832
group by thread#;
select SEQUENCE#,THREAD#,inst_id,STATUS,BLOCK# from gv$managed_standby where lower(status) like '%wait%'
or lower(status) like '%ap%';
www.usefzadeh.com