Professional Documents
Culture Documents
Issue 01
Date 2013-06-30
All other trademarks and trade names mentioned in this document are the property of their respective
holders.
Notice
The purchased products, services and features are stipulated by the contract made between Huawei and
the customer. All or part of the products, services and features described in this document may not be
within the purchase scope or the usage scope. Unless otherwise specified in the contract, all statements,
information, and recommendations in this document are provided "AS IS" without warranties, guarantees
or representations of any kind, either express or implied.
The information in this document is subject to change without notice. Every effort has been made in the
preparation of this document to ensure accuracy of the contents, but all statements, information, and
recommendations in this document do not constitute a warranty of any kind, express or implied.
Website: http://www.huawei.com
Email: support@huawei.com
Intended Audience
This document describes common operations on the Oracle database.
This document is intended for:
Customer maintenance engineers
Huawei maintenance engineers
Change History
Changes between document issues are cumulative. The latest document issue contains all the
changes made in earlier issues.
Issue 01 (2013-06-30)
This issue is the first official release.
Contents
Tables
1 Common Operations
If the value of log_buffer is less than the minimum value, wait events occur in the Redo
Buffers.
1.10 Expanding Tablespaces
Expand tablespaces so that new data can be written into tablespaces when the number of
database files continuously increases.
1.11 Collecting Data Table Statistics and Index Statistics That Have Not Been Analyzed
Collect data table statistics and index statistics that have not been analyzed to ensure that SQL
statement execution plans are correct.
Procedure
Step 1 Log in to the operating system as the oracle user.
Step 2 Connect to the database.
sqlplus '/ as sysdba'
Step 3 Check database instance status.
SQL> select status, logins from v$instance;
STATUS LOGINS
------------------------ --------------------
OPEN ALLOWED
If the value of OPEN_MODE is MOUNTED, the database is installed and allows only
creating control files and restoring the database.
Procedure
Step 1 Log in to the operating system as the oracle user.
Step 2 Connect to the database.
sqlplus '/ as sysdba'
Step 3 Check the database version.
SQL> select * from v$version;
The following information is displayed:
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
PL/SQL Release 11.1.0.7.0 - Production
CORE 11.1.0.7.0 Production
TNS for Linux: Version 11.1.0.7.0 - Production
NLSRTL Version 11.1.0.7.0 - Production
Alternatively, you can run the select * from registry$history; command to check the database version.
In the output of this command, the value in the VERSION column indicates the database version and
the value in the COMMENTS column indicates the database patch version.
----End
Precautions
Back up archive logs before deleting them.
Procedure
Step 1 Log in to the operating system as the oracle user.
Step 2 Log in to the RMAN.
rman target / nocatalog
Step 3 Delete archive logs.
RMAN> delete archivelog all;
The database is configured in the DataGuard or STREAMS environment. If the STREAMS environment
requires archive logs or the STREAM environment cannot be restored after longtime attempts, run the
following command:
RMAN> delete FORCE archivelog all;
Precautions
If you forcibly stop the database instance, starting the database instance may fail, affecting
services. Therefore, obtain customer approval before forcibly stopping the database instance.
Procedure
Step 1 Log in to the operating system as the oracle user.
Step 2 Connect to the database.
sqlplus '/ as sysdba'
Step 3 Stop the database instance.
To immediately stop the database instance and roll back pending transactions, run the
following command:
SQL> shutdown immediate;
If the database instance cannot be stopped a long time after you run the preceding
command, set up a connection to the database and run the following command to
forcibly stop the database instance:
SQL> shutdown abort;
Step 4 Start the database instance.
Context
When the database is in RAC networking mode, three daemons init.cssd, init.crsd, and
init.evmd run in the database. When you restart a database instance, all resources except the
three daemons are stopped and then started.
The path to the init.crs file for restarting database instances varies depending on operating
systems. Table 1-1 describes the init.crs file path.
Precautions
This operation applies only to the Oracle database 11g Release 1.
Procedure
Step 1 Log in to the operating system as the root user.
Step 2 Stop the database instance.
Determine the init.crs file path based on the operating system and run the following
command in the file path:
init.crs stop
For example, if the operating system is SuSE Linux, run the following command in
/etc/init.d/init.crs:
/etc/init.d/init.crs stop
Precautions
If service user indexes expire, recreate the indexes.
Contact Huawei engineers for confirmation because recreating indexes online affects services
and apply for a sufficient maintenance time segment.
The duration for recreating indexes varies depending on the data volume in the database.
Before recreating indexes, evaluate the duration with the service side and developers.
Procedure
Step 1 Log in to the operating system as the oracle user.
Step 2 Connect to the database.
sqlplus / as sysdba
Step 3 Query invalid indexes or index partitions.
In the preceding commands, [online] indicates that indexes are recreated online.
Precautions
After modifying processes, you must restart the database instance for the modification to take
effect, which affects services. Therefore, obtain approval from the customer, the service side,
and developers before modifying processes.
Determine the value of processes based on the site requirements.
Procedure
Step 1 Log in to the operating system as the root user.
Step 2 Obtain the IDs of oracle user processes.
ps -ef | grep LOCAL=NO
oracle 1323 1 0 17:03 ? 00:00:00 oraclemytest (LOCAL=NO)
oracle 1503 1350 0 17:03 pts/2 00:00:00 grep LOCAL=NO
kill -9 Process ID
Step 4 Switch to the oracle user.
su - oracle
Step 5 Connect to the database.
sqlplus '/ as sysdba'
Step 6 Obtain the value of processes.
SQL> show parameter processes;
NAME TYPE VALUE
-------------------------- ----------- --------------
processes integer 800
Context
The shared_pool_size parameter determines the row cache hit ratio that must be greater than
95%. If the row cache hit ratio is less than or equal to 95%, modify shared_pool_size to
increase the ratio. Determine the value of shared_pool_size based on the site requirements.
Procedure
Step 1 Log in to the operating system as the oracle user.
Step 2 Connect to the database.
sqlplus '/ as sysdba'
Step 3 Check the row cache hit ratio.
SQL> select (1 - (SUM(getmisses)/SUM(gets)))*100 FROM v$rowcache;
(1-(SUM(GETMISSES)/SUM(GETS)))*100
----------------------------------
98.900438
Step 4 If the row cache hit ratio is less than or equal to 95%, check the shared pool size.
SQL> select bytes/1024/1024 from v$sgainfo where name='Shared Pool Size';
BYTES/1024/1024
---------------
480
Precautions
After modifying log_buffer, you must restart the database instance for the modification to
take effect, which affects services. Therefore, obtain approval from the customer, the service
side, and developers before modifying log_buffer.
Determine the value of log_buffer based on the site requirements.
Procedure
Step 1 Log in to the operating system as the oracle user.
Step 2 Connect to the database.
sqlplus '/ as sysdba'
Step 3 Check the size of the Redo Buffers.
SQL> select bytes/1024/1024 from v$sgainfo where name='Redo Buffers';
BYTES/1024/1024
---------------
15.7929688
Step 4 If the size of the Redo Buffers is less than the minimum value required by the site, change the
value of log_buffer.
For example, to change the value of log_buffer to 83886080 (in bytes), run the following
command:
SQL> alter system set log_buffer=83886080 scope=spfile;
Step 5 Stop the database instance.
SQL> shutdown immediate;
Precautions
Determine the size by which a tablespace is to be expanded based on the site requirements.
Procedure
Step 1 Log in to the operating system as the oracle user.
Step 2 Connect to the database.
sqlplus '/ as sysdba'
Step 3 Check the vacancy rates of tablespaces.
SQL> SELECT D.TABLESPACE_NAME,SPACE "SUM_SPACE(M)",BLOCKS
SUM_BLOCKS,SPACE - NVL(FREE_SPACE, 0) "USED_SPACE(M)",(100-
ROUND((1 - NVL(FREE_SPACE, 0) / SPACE) * 100, 2))
"FREE_RATE(%)",FREE_SPACE "FREE_SPACE(M)"FROM (SELECT
TABLESPACE_NAME,ROUND(SUM(BYTES) / (1024 * 1024), 2)
SPACE,SUM(BLOCKS) BLOCKS FROM DBA_DATA_FILES GROUP BY
TABLESPACE_NAME) D,(SELECT TABLESPACE_NAME,ROUND(SUM(BYTES) /
(1024 * 1024), 2) FREE_SPACE FROM DBA_FREE_SPACE GROUP BY
TABLESPACE_NAME) F WHERE D.TABLESPACE_NAME =
F.TABLESPACE_NAME(+)UNION ALL SELECT D.TABLESPACE_NAME,SPACE
"SUM_SPACE(M)",BLOCKS SUM_BLOCKS,USED_SPACE "USED_SPACE(M)",
(100-ROUND(NVL(USED_SPACE, 0) / SPACE * 100, 2))
"FREE_RATE(%)",NVL(FREE_SPACE, 0) "FREE_SPACE(M)"FROM (SELECT
TABLESPACE_NAME,ROUND(SUM(BYTES) / (1024 * 1024), 2)
SPACE,SUM(BLOCKS) BLOCKS FROM DBA_TEMP_FILES GROUP BY
TABLESPACE_NAME) D,(SELECT
TABLESPACE_NAME,ROUND(SUM(BYTES_USED) / (1024 * 1024), 2)
USED_SPACE,ROUND(SUM(BYTES_FREE) / (1024 * 1024), 2) FREE_SPACE FROM
V$TEMP_SPACE_HEADER GROUP BY TABLESPACE_NAME) F WHERE
D.TABLESPACE_NAME = F.TABLESPACE_NAME(+)ORDER BY 5 DESC;
Based on the command output, the vacancy rate of each tablespace.
Step 4 Check the usage of tablespaces.
SQL> select t.segment_name, t.partition_name, t.segment_type,
round(t.bytes/1024/1024) MB, t.tablespace_name from dba_segments t order by MB
desc;
Step 5 Add data files to tablespaces.
If the data files to be added are file systems or raw devices, ensure that the file systems have sufficient
space or user permission on the raw devices is correct.
Precautions
Collecting statistics affects database performance. Therefore, collect statistics during low-
traffic hours.
Procedure
Step 1 Log in to the operating system as the oracle user.
Step 2 Connect to the database.
sqlplus '/ as sysdba'
Step 3 Collect data table statistics and index statistics that have not been analyzed.
1. Collect data table statistics.
SQL> exec dbms_stats.gather_table_stats(ownname =>'OWNER', tabname
=>'TABLE_NAME');
2. Collect index statistics.
SQL> exec dbms_stats.gather_schema_stats(ownname =>'OWNER');
----End