Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Oracle restart characteristics in oracle 11g

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Oracle restart sexual characteristic

Before oracle 11g R2, it was common to write scripts to start oracle automatically for a single instance. In oracle 11g R2, use the oracle restart function to configure automatic restart of the database after hardware or software failure or restart of the host where the database is located. For non-clustered environments, you only need to install OracleGrid Infrastructure, select "install grid infrastructure software only" during installation, and then run the following script

To install Oracle Restart:$GRID_HOME/crs/install/roothas.pl

[root@jyrac1 install] #. / roothas.pl

2014-05-28 12:11:54: Checking for super user privileges

2014-05-28 12:11:54: User has super user privileges

2014-05-28 12:11:54: Parsing the host name

Using configuration parameter file:. / crsconfig_params

Creating trace directory

LOCAL ADD MODE

Creating OCR keys for user 'grid', privgrp' oinstall'..

Operation successful.

CRS-4664: Node jyrac1 successfully pinned.

Adding daemon to inittab

CRS-4123: Oracle High Availability Services has been started.

Ohasd is starting

Jyrac1 2014-05-28 12:12:47 / grid/11.2.0/grid/cdata/jyrac1/backup_20140528_121247.olr

Successfully configured Oracle Grid Infrastructure for a Standalone Server

[root@jyrac1 install] # srvctl

-bash: srvctl: command not found

[root@jyrac1 install] # su-grid

[grid@jyrac1 ~] $srvctl

Usage: srvctl []

Commands: enable | disable | start | stop | status | add | remove | modify | getenv | setenv | unsetenv | config

Objects: database | service | asm | diskgroup | listener | home | ons | eons

For detailed help on each command and object and its options use:

Srvctl-h or

Srvctl-h

Oracel restart improves the availability of the database. When you install oracle restart, after a hardware or software failure or a restart of the host where the database is located

The oracle component can be restarted automatically.

Table: oracle components that are automatically restarted by oracle restart

-

Component description

-

Instance oracle restart can be used for multiple database instances on a single host

Listener

The database service does not include the default service created by default because it is managed by the oracle database and is not included when the database is created

The default service created

Oracle asm instance

Oracle asm disk group restart disk group and load disk group

Oracle ONS Notification Service in a separate environment, ONS is used in the data guard installation to pass between the main library and the standby library

Fast application notification (fan) automatically fails over. ONS is a service used to send

FAN events are integrated into the failover function of the client.

-

Oracle restart periodically runs check operations to monitor the health of these components. If the check operation on a component fails, the component will be shut down and then restarted.

Oracle restart can only be used in stand-alone server environments (non-clustered). For oracle rac, it is oracle clusterware that provides the ability to restart components automatically.

Oracle restart runs in a directory outside the oracle grid schema directory and its installation directory is separate from the home directory of the oracle database.

About the dependency of startup

Oracle restart ensures that oracle components are started in the right order according to the dependencies between components. For example, if the data file is stored in an oracle asm disk group, oracle restart ensures that the oracle asm instance is started and the required disk group is loaded before starting the database instance. Similarly, if a component must be closed, oracle restart ensures that the dependent component is closed first.

Oracle restart also manages weak dependencies between database instances and oracle snooping: when a database instance is started, oracle restart attempts to start snooping. If the listening startup fails, the database is still in the startup state. If startup fails after listening, oracle restart will not shut down the instance and then restart it.

And start and stop components using oracle restart

Oracle restart automatically restarts various oracle components when necessary, and oracle restart stops oracle components in a reasonable order when you manually shut down your operating system. There may be times when you want to start or stop individual oracle components manually. Oracle restart includes a service control tool (srvctl) that can be used to manually start and stop components managed by oracle restart. When using oracle restart, oracle strongly recommends using srvctl to start and stop components manually.

When you use srvctl to stop a component, oracle restart will not restart the component automatically if there is a failure. If you use srvctl to start this component, it can be used again for automatic restart.

Oracle tools such as SQL*Plus, snooping Control tool (LSNRCTL) and ASMCMD are all integrated into oracle restart. If you use SQL*Plus to shut down the database, oracle restart will not treat the database as a failure and will not attempt to restart the database. Similarly, if you use SQL*Plus or ASMCMD to shut down the oracle asm instance, oracle restart will not try to restart it.

There are important differences between starting a component with srvctl and starting with SQL*Plus (or other tools):

. When you start a component using srvctl, any components that the component depends on will first start automatically in a reasonable order.

. When you use SQL*Plus (or other tools) to start a component, the other components that the component depends on will not start automatically, you must make sure that the component it depends on has been started.

In addition, oracle restart allows you to start and stop all components by using a single command in the specified oracle home directory. This oracle home directory can be a database home directory or an oracle grid infrastructure home directory. This function is very useful when patching.

About starting and stopping oracle restart

The crsctl tool is used to start and stop oracle restart. You can also use the crsctl tool to enable or disable oracle highly available services. Oracle restart uses highly available services to automatically start and stop components managed by oracle restart. For example, the oracle highly available service daemon automatically starts databases, listeners, and oracle asm instances. When oracle highly available services are disabled, no components managed by oracle restart are automatically started when a node is restarted.

Generally speaking, you can use the crsctl tool when you want to stop all running oracle software during oracle installation. For example, recording may need to stop oracle restart while patching or performing operating system maintenance operations. When the maintenance operation is completed, you can use the crsctl tool to start oracle restart.

Oracle restart configuration

Oracle restart maintains a list of all oracle components managed by it and configuration information for each component. All this configuration information is a collection called oracle restart configuration. When oracle restart starts a component, it starts the component based on its configuration information. For example, oracle restart configuration contains a local server parameter file (spfile) for the database and a listener port for the listener.

If you install oracle restart and then use DBCA to create the database, DBCA will automatically add the database to the oracle restart configuration. When DBCA starts the database, the required dependencies between the database and other components (such as the disk group on which the data is stored) are created, and oracle restart begins to manage the database.

You can use the srvctl command to manually add or remove components from the oracle restart configuration. For example, if you have oracle restart installed on the host running the database, you can use srvctl to add a database to the oracle restart configuration. When you manually add a component to the oracle restart configuration, you can use srvctl to start it. Oracle restart will start to manage the component and restart it if necessary.

Note: adding a component to an oracle restart configuration can also be called registering a component using oracle restart

Other srvctl commands can be used to view the status and configuration information of oracle restart management components, such as temporarily disabling and re-enabling component management.

Many operations that create oracle components automatically add components to the oracle restart configuration when oracle restart is installed.

Table: create actions and oracle restart configuration

-

Create operations create components and automatically add to the oracle restart configuration?

-

Create a database yes using OUI or DBCA

Create a database no using the create database statement

Create an oracle asm instance yes using OUI,DBCA or ASMCA

Create a disk group yes using any method

Add a listening yes using netca

Create a database service yes using srvctl

Create a database service no by modifying the service_name initialization parameters

Create a database service no using dbms_service.create_service

Create a backup database no

-

The table below lists whether some delete/drop/remove operations automatically remove components from the oracle restart configuration

Table: Delete/Drop/Remove Operations and the Oracle Restart Configuration

-

Operation automatically removes components from oracle restart configuration?

-

Delete a database yes using DBCA

Delete the database no by deleting the data file using the operating system command

Use netca to delete a listening yes

Use any method to delete a disk group yes

Delete the database service yes using srvctl

Delete the database service no in other ways

-

Configure oracle restart

If you install oracle restart and then create a database for a stand-alone environment by installing oracle grid infrastructure, the database is automatically added to the oracle restart configuration and then automatically restarted as needed. However, if you install oracle restart after creating the database, you need to manually add databases, snooping, oracle asm management instances, and other components to the oracle restart configuration.

After configuring oracle restart to manage the database, you can do the following:

. Add components to the oracle restart configuration

. Remove components from the oracle restart configuration

. Temporarily suspend oracle restart management of one or more components

. Modify oracle restart configuration options for individual components.

Prepare to run srvctl

Be sure to run srvctl from the correct oracle home directory and log in to the host with the correct user. Table 4-6 shows a list of components that can be configured using srvctl. For each component, the oracle home directory required to run srvctl is listed.

Table: determine which oracle home directory to run srvctl from

-

The oracle home directory where the configured component runs srvctl

-

Database,database service database home

Oracle asm instance,disk group, oracle grid infrastructure home

Listener,ONS

-

Suppose the listening is not started from the oracle grid infrastructure home directory. If you install oracle restart on an existing database, listening may be started from the database home directory, in which case run srvctl from the database home directory

To run srvctl

1. Determine from which oracle home directory srvctl should be run

two。 If you plan to run the srvctl command to modify the oracle restart configuration (add,remove,enable,disable, etc.), you can follow these steps:

. In unix and linux, log in to the host where the database is located using the oracle home directory user that installed the srvctl command you determined to run

. Log in to the system using an administrator on windows

Otherwise, log in to the system using any user

3. Open a command window and enter the srvctl command you want to use. To enter commands, make sure that the srvctl program is set up in the path environment modification. Otherwise, enter the srvctl program.

The complete path.

Get srvctl help

The online help documentation for the srvctl tool is available:

To get help from srvctl:

1. Prepare to run srvctl

two。 Enter the following command:

Srvctl

For more detailed help, enter the following command:

Srvctl-h

Enter the following command for help with a specific command:

Srvctl command-h

For example, to get different options for each component type and help input for the add command:

Srvctl add-h

To get specific command input for the component type of a specific component:

Srvctl command object-h

To get help on adding a database service, enter the following command:

Srvctl add service-h

Add components to the oracle restart configuration

In most cases, creating an oracle component on a host that is running oracle restart automatically adds this component to the oracle restart configuration

Here's what happens when you manually add components to the oracle restart configuration using srvctl:

. Install oracle restart after the database has been created

. Use the create database statement to create another database on the same host.

. Create a database service using the dbms_service.create_service procedure

Note: adding a component to the oracle restart configuration is also called registering a component using oracle restart

Adding a component to the oracle restart configuration will not start this component. You must use the srvctl start command to start it.

You can also use the oracle Enterprise Management Database console to add a database or monitor to the oracle restart configuration.

Note: when you manually add a database to the oracle restart configuration, you must set the owner (user) of the oracle grid infrastructure software

Add to the osdba group of the database. This is because the grid infrastructure component must be able to connect to the database in the sysdba role to start and stop the database.

For example, if the user installing grid infrastructure software is grid and the osdba group of the database is dba, then user grid must be a member of the dba group.

Add components using srvctl

When using srvctl to add a component to the oracle restart configuration, you can specify configuration options for that component.

1. Prepare the environment for running srvctl

two。 Enter the following command:

Srvctl add object options

The object here is a component.

Add a database

This example uses db_unique_name=jycs to add a database component. This forced-o option is used to specify the location of the oracle home directory

Oracle@jyrac1 ~] $srvctl add database-d jycs-o / u01/app/oracle/11.2.0/db

Add a database service

Create a new database service name jytest for db_unique_name=jycs 's database and add this database service to the oracle restart configuration

[oracle@jyrac1] $srvctl add service-d jycs-s jytest

Add default listeners

Add a default listener to the oracle restart configuration: (note that the grid_home directory is used when adding listeners

Then you should specify GI_HOME instead of ORACLE_HOME when adding a monitor)

[grid@jyrac1] $srvctl add listener-o / grid/11.2.0/grid/

Now let's verify that the database will start automatically when the host restarts.

[root@jyrac1 ~] # reboot

Broadcast message from root (pts/2) (Wed Jun 4 10:30:32 2014):

The system is going down for reboot NOW!

After the host is rebooted, check and find that the database and listeners are also started automatically by the following command

[root@jyrac1 ~] # ps-ef | grep pmon

Oracle 3451 10 10:32? 00:00:00 ora_pmon_jycs

Root 3563 3530 0 10:32 pts/1 00:00:00 grep pmon

[root@jyrac1 ~] # ps-ef | grep tns

Grid 3438 10 10:32? 00:00:00 / grid/11.2.0/grid/bin/tnslsnr LISTENER-inherit

Root 3565 3530 0 10:33 pts/1 00:00:00 grep tns

[grid@jyrac1] $crs_stat-t

Name Type Target State Host

Ora....ER.lsnr ora....er.type ONLINE ONLINE jyrac1

Ora.cssd ora.cssd.type OFFLINE OFFLINE

Ora.diskmon ora....on.type OFFLINE OFFLINE

Ora.jycs.db ora....se.type ONLINE ONLINE jyrac1

Remove components from the oracle restart configuration

When you delete a component using the method recommended by oracle, the component is automatically removed from the oracle restart configuration. For example, if you use DBCA to delete a database

DBCA removes the database from the oracle restart configuration. Similarly, if you use netca to remove snooping, netca removes snooping from the oracle restart configuration.

If you delete a component using an unrecommended or manual deletion method, you must first use srvctl to remove the component from the oracle restart configuration. Failure to do so may make a mistake.

Remove a component from the oracle restart configuration:

Srvctl remove object [options]

For example, delete a database whose db_unique_name is dbcrm

Srvctl remove database-d dbcrm

Disable or enable oracle restart configuration for a component

You can temporarily disable oracle restart configuration for a component. One reason is when performing maintenance tasks on components. For example, if a component must be repaired, you may want it not to start automatically in the event of a failure or host restart.

You can re-enable management for components when the maintenance task is complete

When you disable a component:

. It will no longer restart automatically

. By relying on components, it will no longer start automatically.

. Cannot start using srvctl

. Any components that depend on this resource will no longer automatically start or restart automatically

Disable or start an automatic restart of a component to do one of the following:

. Disable a component by entering the following command:

Srvctl disable object [options]

Start a component and enter the following command:

Srvctl enable object [options]

For example: disable automatic restart for a database whose db_unique_name is dbcrm

Srvctl disable database-d dbcrm

Disable automatic restart for an asm disk group named recovery

Srvctl disable diskgroup-g recovery

View component status

You can use srvctl to view the running status of components appointed to be managed by oracle restart. Additional information is displayed for some components.

View the status of the component:

Srvctl status object [options]

For example, check the status of a database whose db_unique_name is jycs

[oracle@jyrac1] $srvctl status database-d jycs

Database is running.

View oracle restart configuration information for a component

You can use srvctl to view the oracle restart configuration of any component. Oracle restart maintains different configuration information for each component type. Use the srvctl command

You can get a list of components managed by oracle restart.

View the component configuration:

Srvctl config object options

For example: view a list of all databases managed by oracle restart

[oracle@jyrac1 ~] $srvctl config database

Jycs

View the configuration information for a specific database:

The following example looks at the configuration of a database whose db_unique_name is jycs:

[oracle@jyrac1] $srvctl config database-d jycs

Database unique name: jycs

Database name:

Oracle home: / u01/app/oracle/11.2.0/db

Oracle user: grid

Spfile:

Domain:

Start options: open

Stop options: immediate

Database role: PRIMARY

Management policy: AUTOMATIC

Disk Groups:

Services:

Modify the oracle restart configuration of a component

You can use srvctl to modify the oracle restart configuration of a component. For example, the listener port of the listener when oracle restarts or the server parameter file (SPFILE) indicated by oracle restart when the database is started can be modified.

Modify the oracle restart configuration of a component

Srvctl modify object options

For example, for a database whose db_unique_name is dbcrm, use the following command to change the management policy to manual startup option to nomount:

Srvctl modify database-d dbcrm-y manual-s nomount

Using manual management strategy, the database will not restart automatically when the database host restarts. However, oracle restart will continue to monitor that the database will restart if it fails.

[oracle@jyrac1] $srvctl modify database-h

Modifies the configuration for the database.

Usage: srvctl modify database-d [- n] [- o] [- u] [- m] [- p] [- r {PRIMARY | PHYSICAL_STANDBY | LOGICAL_STANDBY | SNAPSHOT_STANDBY}] [- s] [- t] [- y {AUTOMATIC | MANUAL}] [- a "" |-z]

-d Unique name for the database

-n Database name (DB_NAME), if different from the unique name given by the-d option

-o ORACLE_HOME path

-u Oracle user

-m Domain for database. Must be set if database has DB_DOMAIN set.

-p Server parameter file path

-r Role of the database (primary, physical_standby, logical_standby, snapshot_standby)

-s Startup options for the database. Examples of startup options are open, mount, or nomount.

-t Stop options for the database. Examples of shutdown options are normal, transactional, immediate, or abort.

-y Management policy for the database (AUTOMATIC or MANUAL)

-a "" Comma separated list of disk groups

-z To remove database's dependency upon disk groups

-h Print usage

Manage environment variables in the oracle restart configuration.

The name-value pairs of environment variables can be stored in the oracle restart configuration. If you usually set environment variables before starting the database (except for oracle_home and oracle_sid

You can set other environment variables in the oracle restart configuration. Any number of environment variables can be stored in a single configuration of the following components.

.database instance

. Monitor

.oracle asm instance

When oracle restart starts a component, it first uses the values stored in the component configuration to set the component's environment variables. Although it is possible to use oracle components in this way

To set the environment variable, this function mainly tends to set the operating system environment variable.

Set and cancel environment variables

Use srvctl to set or cancel environment variables for components in the oracle restart configuration.

Set or cancel the environment variable for the component:

. To set the environment modification, use the following command:

Srvctl setenv {asm | database | listener} options

Remove the environment variable from the configuration and enter the following command:

Srvctl unsetenv {asm | database | listener} options

For example, setting database environment variables

Set the NLS_LANG and AIX AIXTHREAD_SCOPE environment variables in the oracle restart configuration for the database whose db_unique_name is dbcrm:

Srvctl setenv database-d dbcrm-t "NLS_LANG=AMERICAN_AMERICA.AL32UTF8,AIXTHREAD_SCOPE=S"

View environment variabl

Use srvctl to view the environment variables of the components in the oracle restart configuration.

View the configuration of environment variables:

Srvctl getenv {database | listener | asm} options

For example, view all the environment variables in the database

View the environment variables in the oracle restart configuration for the database whose db_unique_name is dbcrm:

Srvctl getenv database-d dbcrm

Dbcrm:

NLS_LANG=AMERICAN_AMERICA

AIXTHREAD_SCOPE=S

GCONF_LOCAL_LOCKS=1

For example, look at the specific environment variables of the database

View the NLS_LANG and AIXTHREAD_SCOPE environment variables of the database:

Srvctl getenv database-d dbcrm-t "NLS_LANG,AIXTHREAD_SCOPE"

Dbcrm:

NLS_LANG=AMERICAN_AMERICA

AIXTHREAD_SCOPE=S

Use srvctl to create and delete database services

When using oracle restart to manage databases, oracle recommends using srvctl to create to delete database services. When using srvctl to add a database service

This service is automatically added to the oracle restart configuration, and dependencies between the service and the database are established. So if you start the service when the database does not have

At startup, oracle restart starts the database first.

When you delete a database service using srvctl, the service is also removed from the oracle restart configuration

Use srvctl to create a database service:

Srvctl add service-d db_unique_name-s service_name [options]

For example, create a database service

Create a database service name called crmbatch for the database of db_unique_name for dbcrm

Srvctl add service-d dbcrm-s crmbatch

For example, create a role-based database service

Create a database service called crmbatch and specify its data guard role as physical_standby. Only when the current role of the dbcrm database is a physical standby database

This service will start automatically.

Srvctl add service-d dbcrm-s crmbatch-l PHYSICAL_STANDBY

Use srvctl to delete the database service:

Srvctl remove service-d db_unique_name-s service_name [- f]

The database service will be removed from the oracle restart configuration. If the-f force flag appears, it will be deleted even if the service is running. If there is no-f mark, if the service

An error will be reported when it is running.

Oracle restart-related crsctl commands

The syntax of the crsctl command is:

Crsctl command has

Here command is an abbreviation for commands such as start,stop or enable,disable. The has object indicates that oracle is highly available.

Check displays the status of oracle restart.

[grid@jyrac1 ~] $crsctl check has

CRS-4638: Oracle High Availability Services is online

Config displays oracle restart configuration

CRS-4622: Oracle High Availability Services autostart is enabled.

Disable disables automatic restart of oracle restart

[grid@jyrac1 ~] $crsctl disable has

Enable enables automatic restart of oracle restart

[grid@jyrac1 ~] $crsctl enable has

Start starts oracle restart

[grid@jyrac1 ~] $crsctl start has

Stop stop oracle restart

[grid@jyrac1 ~] $crsctl stop has [- f]

-f option: if any resources managed by oracle restart are still running. Then try to stop these resources. Try to force a stop if the resource cannot be stopped.

Personally, I don't think there is any advantage in using oracle restart and script startup for a single instance.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report