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

No comments:

Post a Comment