Saturday, 18 October 2025

Steps to Create and Connect to Azure Database for PostgreSQL

Steps to Create and Connect to Azure Database for PostgreSQL

  1. Create PostgreSQL Database in Azure Portal
    • Go to the Azure Portal.
    • Search for and select Azure Database for PostgreSQL servers.
    • Click Create, then select Flexible Server option.








  2. Get Connection Information
    • In the newly created server’s Overview page, copy the Server name and Username; you will need these to connect.
  3. Connect Using pgAdmin
    • Open pgAdmin.
    • Right-click Servers and select Create > Server.
    • Enter a name, e.g., azure-pg-tt.
    • On the Connection tab, enter the copied hostname and username from the Azure Portal.
    • Click Save to connect.


  4. Explore Created Databases
    • Expand the connected server in pgAdmin. You will see 3 databases pre-created by Azure. Do not delete these.
  5. Create a New Database to Use
    • Right-click Databases under your server, select Create > Database.
    • Name your new database, for example, mypgsqldb.
  6. Run SQL Queries on Your Database
    • Select your new database (mypgsqldb) and click the Query Tool icon in pgAdmin.
    • Run the following SQL commands to create a table, insert records, and query data:

sql

CREATE TABLE EMP(id serial PRIMARY KEY, name VARCHAR(50),  Salary INTEGER);

INSERT INTO EMP(id, name, salary) VALUES (1, 'Jon', 15000);

INSERT INTO EMP(id, name, salary) VALUES (2, 'Doe', 15400);

SELECT * FROM EMP;



You are now connected to the PostgreSQL database on Azure !!!!!!

Create a Free SQL Database in Azure and query using query editor

 


How to Create a Free SQL Database in Azure (with Screenshots)

Getting started with SQL databases in the cloud is easy with Microsoft Azure. Follow the step-by-step tutorial below to create your own free Azure SQL Database and run queries using the Azure Portal.


1. Log in to the Azure Portal

Go to https://portal.azure.com/ and sign in with your Microsoft account. On the homepage, you’ll find options like Create a resource, Azure SQL Database, and more.




2. Create a New SQL Database

Click on Azure SQL Database or use the search bar to find it. Click the Create button to start the creation process.




3. Configure Database Basics

Fill out the basic details:

  • Subscription: Choose your Azure subscription.
  • Resource group: Create a new resource group or select an existing one.
  • Database name: Enter a meaningful name.
  • Server: Click "Create new" to set up a SQL server (see next step).

4. Set Up SQL Database Server

In the server creation form, provide:

  • Server name: A unique name.
  • Location: Select the Azure region.
  • Authentication: Set admin login and password.


5. Configure Networking Options

On the networking screen:

  • Set Allow Azure services and resources to access this server to No.
  • Set Add current client IP address to Yes.​



6. Additional Settings: Add Sample Data

On the Additional settings tab, choose Sample under “Use existing data”. This loads the AdventureWorksLT sample database for learning and testing.​




7. Review and Create

Click Review + create at the bottom and let Azure deploy your database.


8. Query the Database

Once deployed, go back to the list of your SQL databases and select the one you’ve just created.2_Create.jpg​

  • Open Query editor (preview).
  • Log in with the credentials you set for your server.


9. Sample Query and Output

Here’s how the query and results look in the Azure Portal’s Query Editor :​

sql

SELECT * FROM [SalesLT].[Customer]



You’ll see a result table with columns such as CustomerID, NameStyle, Title, and FirstName.


Sunday, 21 September 2025

Oracle database To Configure Data Guard Physical Standby is on the way .........................................

 New post




DGMGRL> show configuration;

Configuration - PRIMARY_ORADB

  Protection Mode: MaxPerformance

  Members:

  oradb    - Primary database

    oradbsby - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:

SUCCESS   (status updated 13 seconds ago)


ORA-01102: cannot mount database in EXCLUSIVE mode

The ORA-01102 error "cannot mount database in EXCLUSIVE mode" occurs when an Oracle instance tries to mount the database in exclusive mode but another instance has already mounted the database either exclusively or in parallel mode.

1. Shutdown any other instances that may have the database mounted:

SHUTDOWN IMMEDIATE;

2. Kill any remaining Oracle background or shadow processes related to the database using OS commands:

kill -9 <process_ids>

[oracle@muthu ~]$ ps -ef|grep pmon

oracle    1821     1  0 16:40 ?        00:00:00 ora_pmon_oradbsby

oracle    2750     1  0 16:41 ?        00:00:00 ora_pmon_oradb

oracle    2936  2626  0 16:42 pts/0    00:00:00 grep --color=auto pmon

[oracle@muthu ~]$ kill -9 2750

[oracle@muthu ~]$ kill -9 1821

3. Check and remove the stale lock file lk<SID> in the $ORACLE_HOME/dbs directory if it exists.

4. Remove any leftover shared memory segments and semaphores related to the Oracle SID.

5. In RAC, verify the cluster_database parameter is set to TRUE for all instances.

6. After cleaning up, start the database again:

STARTUP MOUNT;

This error is mostly about ensuring no conflicting instance is holding the database open and cleaning up orphaned processes or locks so the instance can mount the database exclusively without conflict.

Saturday, 20 September 2025

To recover the lost logs in oracle database

***

Oracle Database Recovery and Backup Task Documentation

This document describes the steps performed for deleting redo log files, performing an RMAN point-in-time recovery, and backing up the database with archived logs in an Oracle 12c environment with a multitenant container database (CDB) and pluggable database (PDB).

***

Environment and Initial Setup

- Oracle Database version: 12c Release 12.2.0.1.0 (64-bit Enterprise Edition)
- Working with Container Database (CDB) and Pluggable Database (PDB1)
- OS user: oracle
- Date and time of operations: Sep 20, 2025, around 18:30 to 18:50 +04 timezone

***

Step 1: Switch Container and Create Table

1. Set container to PDB1:
SQL> alter session set container=PDB1;

Session altered.

2. Verify PDB status:SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         3 PDB1                           READ WRITE NO

3. Create a simple table named `emp` with columns `id` (int) and `name` (varchar(100)):
SQL> create table emp(id int,name varchar(100));

Table created.

4. Insert one row into the `emp` table:
SQL> insert into emp values (1,'Muthu');

1 row created.

SQL> commit;

Commit complete.

5. Validate the data insertion:
SQL> select * from emp;

        ID        NAME
--------------------------------------------------------------------------------
         1         Muthu

6. Check the current System Change Number (SCN):

SQL> select current_scn from v$database;

CURRENT_SCN
-----------
    2779187

7. Confirm the current date/time from the OS shell:
SQL> !date
Sat Sep 20 18:32:15 +04 2025

***

Step 2: List and Remove Redo Log Files

1. List redo log members (files):

SQL> select member from v$logfile;

MEMBER
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/oradb/redo03.log
/u01/app/oracle/oradata/oradb/redo02.log
/u01/app/oracle/oradata/oradb/redo01.log

2. List the contents of Oracle data directory:
SQL> !ls -lrt /u01/app/oracle/oradata/oradb/
total 2498756
drwxr-x---. 2 oracle oinstall      4096 Sep  4  2020 pdbseed
drwxr-x---. 2 oracle oinstall       104 Sep  4  2020 pdb1
-rw-r-----. 1 oracle oinstall 142614528 Sep 20 18:20 temp01.dbf
-rw-r-----. 1 oracle oinstall 209715712 Sep 20 18:36 redo01.log
-rw-r-----. 1 oracle oinstall 209715712 Sep 20 18:37 redo02.log
-rw-r-----. 1 oracle oinstall 849354752 Sep 20 18:37 system01.dbf
-rw-r-----. 1 oracle oinstall 639639552 Sep 20 18:37 sysaux01.dbf
-rw-r-----. 1 oracle oinstall 283123712 Sep 20 18:37 undotbs01.dbf
-rw-r-----. 1 oracle oinstall   5251072 Sep 20 18:37 users01.dbf
-rw-r-----  1 oracle oinstall 209715712 Sep 20 18:37 redo03.log
-rw-r-----. 1 oracle oinstall  18726912 Sep 20 18:38 control01.ctl

3. Remove all redo log files from directory:

SQL> !rm /u01/app/oracle/oradata/oradb/redo*

4. Confirm redo log files removal by listing directory again:

SQL> !ls -lrt /u01/app/oracle/oradata/oradb/
total 1884344
drwxr-x---. 2 oracle oinstall      4096 Sep  4  2020 pdbseed
drwxr-x---. 2 oracle oinstall       104 Sep  4  2020 pdb1
-rw-r-----. 1 oracle oinstall 142614528 Sep 20 18:20 temp01.dbf
-rw-r-----. 1 oracle oinstall 849354752 Sep 20 18:37 system01.dbf
-rw-r-----. 1 oracle oinstall 639639552 Sep 20 18:37 sysaux01.dbf
-rw-r-----. 1 oracle oinstall 283123712 Sep 20 18:37 undotbs01.dbf
-rw-r-----. 1 oracle oinstall   5251072 Sep 20 18:37 users01.dbf
-rw-r-----. 1 oracle oinstall  18726912 Sep 20 18:38 control01.ctl

***

Step 3: Shutdown Database and Mount for Recovery

1. Shutdown the database immediately:
SQL> shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup mount;
ORACLE instance started.

Total System Global Area  801112064 bytes
Fixed Size                  8797872 bytes
Variable Size             423625040 bytes
Database Buffers          360710144 bytes
Redo Buffers                7979008 bytes
Database mounted.
SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

***

Step 4: RMAN Point-in-Time Recovery to a Specific Sequence

1. Start RMAN and connect to target database:

[oracle@muthu trace]$ rman target /

Recovery Manager: Release 12.2.0.1.0 - Production on Sat Sep 20 18:40:06 2025

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

connected to target database: ORADB (DBID=2803495960, not open)

2. Run recovery commands:
RMAN> run
{
set until sequence 3;
restore database;
recover database;
alter database open resetlogs;
}2> 3> 4> 5> 6> 7>

executing command: SET until clause
Starting restore at 20-SEP-2025 18:40:21
using target database control file instead of recovery catalog
flashing back control file to SCN 2780743
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 device type=DISK

skipping datafile 5; already restored to file /u01/app/oracle/oradata/oradb/pdbseed/system01.dbf
skipping datafile 6; already restored to file /u01/app/oracle/oradata/oradb/pdbseed/sysaux01.dbf
skipping datafile 8; already restored to file /u01/app/oracle/oradata/oradb/pdbseed/undotbs01.dbf
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/oradb/system01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/oradb/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/oradb/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00007 to /u01/app/oracle/oradata/oradb/users01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fra/oradb/ORADB/backupset/2025_09_20/o1_mf_nnndf_TAG20250920T183632_ndxgzjpn_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oracle/fra/oradb/ORADB/backupset/2025_09_20/o1_mf_nnndf_TAG20250920T183632_ndxgzjpn_.bkp tag=TAG20250920T183632

starting media recovery

archived log for thread 1 with sequence 1 is already on disk as file /u01/app/oracle/fra/oradb/ORADB/archivelog/2025_09_20/o1_mf_1_1_ndxgz7r8_.arc
archived log for thread 1 with sequence 2 is already on disk as file /u01/app/oracle/fra/oradb/ORADB/archivelog/2025_09_20/o1_mf_1_2_ndxh0h3t_.arc
archived log file name=/u01/app/oracle/fra/oradb/ORADB/archivelog/2025_09_20/o1_mf_1_1_ndxgz7r8_.arc thread=1 sequence=1
archived log file name=/u01/app/oracle/fra/oradb/ORADB/archivelog/2025_09_20/o1_mf_1_2_ndxh0h3t_.arc thread=1 sequence=2
media recovery complete, elapsed time: 00:00:01
Finished recover at 20-SEP-2025 18:40:53


Statement processed

RMAN>


***

Step 5: Validate Recovery and Backup
[oracle@muthu trace]$ sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Sat Sep 20 18:44:09 2025

Copyright (c) 1982, 2016, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL>  select name,open_mode from v$database;

NAME      OPEN_MODE
--------- --------------------
ORADB     READ WRITE

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 PDB1                           READ WRITE NO

SQL> alter session set container=PDB1;

Session altered.

SQL> select current_scn from v$database;

CURRENT_SCN
-----------
    2782820

SQL> !date
Sat Sep 20 18:44:28 +04 2025


SQL> select * from emp;

        ID        NAME
--------------------------------------------------------------------------------
         1         Muthu
[oracle@muthu trace]$ rman target /

Recovery Manager: Release 12.2.0.1.0 - Production on Sat Sep 20 18:47:20 2025

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

connected to target database: ORADB

RMAN> backup database plus archivelog;

Finished Control File and SPFILE Autobackup at 20-SEP-2025 18:48:26

Thursday, 14 August 2025

Changing the hostname in Linux

(adsbygoogle = window.adsbygoogle || []).push({});
Changing the hostname in Linux depends on your distribution and whether you're using **systemd** (most modern distros do).

1. Check Current Hostname

[root@test ~]# hostnamectl status
   Static hostname: test.localdomain
         Icon name: computer-vm
           Chassis: vm
[root@test ~]# date
Thu Aug 14 15:53:54 +04 2025
[root@test ~]# uptime
 15:53:56 up 1 min,  1 user,  load average: 2.46, 0.70, 0.24
 
2. Change Hostname (Permanent)

Using `hostnamectl` (Recommended for systemd-based systems like Ubuntu, CentOS 7+, RHEL 7+, Debian 9+)

sudo hostnamectl set-hostname new-hostname
[root@test ~]# hostnamectl set-hostname muthu.org


> Replace `new-hostname` with your desired name.

3. Update `/etc/hosts`

Edit the file:

sudo nano /etc/hosts

[root@test ~] vi /etc/hosts

Find the line like:

127.0.1.1    old-hostname

And change it to:

127.0.1.1    new-hostname

This ensures local name resolution works properly.

4. Reboot or Re-login

Although the change is immediate, some services may require a reboot:
sudo reboot

[root@test ~]# reboot

Wednesday, 13 August 2025

##Viewing Alert Logs in Oracle Cloud Infrastructure (OCI) for Oracle Autonomous Databases

### Limited OS Access
For Oracle Autonomous Databases, direct access to the underlying operating system is restricted. Therefore, alert log monitoring must be done through SQL views and the OCI Console.


### SQL-Based Alert Log Access

#### Deprecated View
- **`V$DIAG_ALERT_EXT`**: Previously used to query alert logs directly via SQL.
- **Status**: **Removed** in recent Oracle ADB updates.

#### Replacement View
- **`V$CLIENT_ERRORS`**: Introduced as the new method to access alert log-related error data.
- **Purpose**: Displays XML-based error logs, including client connection issues and user errors like `ORA-4021`.

### Current Limitations of `V$CLIENT_ERRORS`

- **Session Dependency**: The view only shows error data **while the session is active**.
- **Post-Session Visibility**: If a session is terminated (e.g., killed due to resource limits), its error data **is no longer visible** in the view.
- **User Experience**: This behavior is understandably frustrating, as it limits post-mortem diagnostics.

### Enhancement in Progress

Oracle is actively working on enhancing `V$CLIENT_ERRORS` to improve its usability and persistence of error data beyond session lifetime. No official release date has been announced yet, but updates are expected soon.

we will keep posted about any recent update

Sample Text

Sample text