Sunday, 26 January 2025

SRVCTL useful commands

**General Syntax**


srvctl <command> <object> [-flags] [options]


**Command:** The action to be performed, such as start, stop, add, remove, etc.

**Object:** The target component (e.g., database, instance, listener, service).

**Flags/Options:** Additional parameters to specify details like names, paths, or instances.


**Commonly Used Objects:**


* **Database:** Manage Oracle databases in a cluster.

* **Instance:** Manage individual database instances.

* **Service:** Manage database services.

* **Listener:** Manage Oracle listeners.

* **ASM:** Manage Automatic Storage Management (ASM) instances.

* **Nodeapps:** Manage node applications like VIPs and GSD.


**Common Commands:**


1. **add:** Add an object.

2. **remove:** Remove an object.

3. **modify:** Modify an existing object.

4. **start:** Start an object.

5. **stop:** Stop an object.

6. **status:** Check the status of an object.

7. **enable/disable:** Enable or disable an object.


**Srvctl Commands with Examples:**


**Database Management:**


1. **Start a database:**


srvctl start database -d mydb


**-d:** Specifies the database name.


2. **Stop a database:**


srvctl stop database -d mydb


3. **Check the status of a database:**


srvctl status database -d mydb


**Output example:**


Instance mydb1 is running on node1

Instance mydb2 is running on node2


4. **Add a database:**


srvctl add database -d mydb -o /u01/app/oracle/product/19.0.0/dbhome_1


**-o:** Specifies the Oracle home directory.


5. **Remove a database:**


srvctl remove database -d mydb


**Service Management:**


1. **Add a service:**


```bash

srvctl add service -d mydb -s myservice -r mydb1,mydb2

```


   - **-s:** Service name

   - **-r:** Preferred instances for the service


2. **Start a service:**


```bash

srvctl start service -d mydb -s myservice

```


3. **Stop a service:**


```bash

srvctl stop service -d mydb -s myservice

```


4. **Check the status of a service:**


```bash

srvctl status service -d mydb -s myservice

```


**Listener Management:**


1. **Start a listener:**


```bash

srvctl start listener -n node1

```


   - **-n:** Specifies the node name


2. **Stop a listener:**


```bash

srvctl stop listener -n node1

```


3. **Check the status of a listener:**


```bash

srvctl status listener -n node1

```


**ASM Management:**


1. **Start the ASM instance:**


```bash

srvctl start asm -n node1

```


2. **Stop the ASM instance:**


```bash

srvctl stop asm -n node1

```


3. **Check the status of ASM:**


```bash

srvctl status asm -n node1

```


**Node Applications Management:**


1. **Start VIP (Virtual IP):**


```bash

srvctl start vip -n node1

```


2. **Stop VIP:**


```bash

srvctl stop vip -n node1

```


3. **Check the status of node applications:**


```bash

srvctl status nodeapps -n node1

```


**Useful Tips:**


1. **Logging:** Use -v for verbose output to troubleshoot issues.


```bash

srvctl start database -d mydb -v

```


2. **List all databases in a cluster:**


```bash

srvctl config database

```


3. **Check Clusterware version:**


```bash

srvctl -version

```


4. **Debugging:** Use -debug for detailed debug logs.


```bash

srvctl start database -d mydb -debug

Wednesday, 20 November 2024

Enable Archive log on Oracle Database.

 RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of backup command at 11/20/2024 13:23:08
RMAN-06149: cannot BACKUP DATABASE in NOARCHIVELOG mode

Check the archive log status. Currently Database is in No archive log mode.

SQL> archive log list
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            C:\oracle\app\product\12.2.0\dbhome_1\RDBMS
Oldest online log sequence     314 
Current log sequence           316

Step 1 : Shutdown the database (Immediate/normal)

SQL> shut immediate;

Database closed.
Database dismounted.
ORACLE instance shut down.

Step 2 : Start in mount state

SQL> startup mount;
Total System Global Area 1.0234E+10 bytes
Fixed Size                 12296368 bytes
Variable Size            2281705296 bytes
Database Buffers         7918845952 bytes
Redo Buffers               21254144 bytes
Database mounted.

Step 3 : set where your archive logs needs to be stored.

SQL> sho parameter log_archive_dest_1

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_1                   string

SQL> alter system set log_archive_dest_1="LOCATION=C:\oracle\app\fast_recovery_area\ORCL" scope=both;

System altered.

---- Crosscheck.

SQL> sho parameter log_archive_dest_1

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_1                   string      LOCATION=C:\oracle\app\fast_recovery_area\ORCL

SQL> archive log list
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            C:\oracle\app\fast_recovery_area\ORCL
Oldest online log sequence     316
Current log sequence           318

Step 4 : Alter Database Archivelog

SQL> alter database archivelog;

Database altered.

SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            C:\oracle\app\fast_recovery_area\ORCL
Oldest online log sequence     316
Next log sequence to archive   318
Current log sequence           318

Step 5 : Open the database

SQL> alter database open;

Database altered.

Rerun RMAN backup :

C:\Users\param>rman target /

Recovery Manager: Release 12.2.0.1.0 - Production on Wed Nov 20 14:38:39 2024

Copyright (c) 1982, 2017, Oracle and/or its affiliates.  All rights reserved.

connected to target database: ORCL (DBID=1654956044)

RMAN> backup database plus archivelog;


Starting backup at 20-NOV-24
current log archived
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1590 device type=DISK
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=318 RECID=1 STAMP=1185547178
channel ORA_DISK_1: starting piece 1 at 20-NOV-24
channel ORA_DISK_1: finished piece 1 at 20-NOV-24
piece handle=C:\ORACLE\APP\PRODUCT\12.2.0\DBHOME_1\DATABASE\013AK0TB_1_1 tag=TAG20241120T143939 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 20-NOV-24

Starting backup at 20-NOV-24
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00003 name=C:\ORACLE\APP\ORADATA\ORCL\SYSAUX01.DBF
input datafile file number=00001 name=C:\ORACLE\APP\ORADATA\ORCL\SYSTEM01.DBF
input datafile file number=00005 name=C:\ORACLE\APP\ORADATA\ORCL\UNDOTBS01.DBF
input datafile file number=00007 name=C:\ORACLE\APP\ORADATA\ORCL\USERS01.DBF
channel ORA_DISK_1: starting piece 1 at 20-NOV-24
channel ORA_DISK_1: finished piece 1 at 20-NOV-24
piece handle=C:\ORACLE\APP\PRODUCT\12.2.0\DBHOME_1\DATABASE\023AK0TC_1_1 tag=TAG20241120T143940 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
Finished backup at 20-NOV-24

Starting backup at 20-NOV-24
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=319 RECID=2 STAMP=1185547187
channel ORA_DISK_1: starting piece 1 at 20-NOV-24
channel ORA_DISK_1: finished piece 1 at 20-NOV-24
piece handle=C:\ORACLE\APP\PRODUCT\12.2.0\DBHOME_1\DATABASE\033AK0TK_1_1 tag=TAG20241120T143948 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 20-NOV-24

Starting Control File and SPFILE Autobackup at 20-NOV-24
piece handle=C:\ORACLE\APP\PRODUCT\12.2.0\DBHOME_1\DATABASE\C-1654956044-20241120-00 comment=NONE
Finished Control File and SPFILE Autobackup at 20-NOV-24