BRIGHT DBA

ORACLE DBA – Tips and Techniques

Skip to content
  • Me
  • TrainingFree
  • Services
  • Oracle
        • DB-Install
          • Install Oracle AI Database 26ai
          • Install 19c GUI
          • Install 19c in silent mode
          • Install 18c
          • Install 12.2 Database Binaries in silent mode
          • Install Oracle Software in silent mode 11gR2
          • Install 10g
          • Deinstall Oracle 11gR2 Database binaries
          • Deinstall Oracle 18c Database Binaries
          • Oracle 19c Deinstall
          • Uninstall Oracle Client on Windows
        • DBA Monitor
          • DBA Sheet v7.0 popular
          • OS-DB-Commands
          • Database-Scripts
          • Generate INSERT statements from the SELECT query
          • Generate INSERT statements to a flat file using a PL/SQL query
        • Patching
          • Patch Terminology
          • Apply Patch RU on Database 19c
          • 18c DB Patching
          • 18c DB Patching - Youtube
          • Apply RU on DATABASE 12.2 (CDB/PDB)
          • ROLLBACK RU from DATABASE 12.2
          • Apply DB PSU on Standby
        • DB-Upgrade
          • Upgrade DB using DBUA from 11.2.0.4 to 12.2.0.1
          • Upgrade DB Manually 11.2.0.4 to 12.2.0.1
          • Upgrade Oracle Database from 12.2.0.1 to 19c using DBUA
          • Upgrade Oracle Database Manually from 12.2.0.1 to 19c
          • Rolling Upgrade With an Existing Physical Standby Database
          • Upgrade TIMEZONE Version
          • Upgrade Database to 12.2 with Physical Standby
        • Tuning
          • Oracle Tuning Stage 1
            • Statistics
            • Oracle Histograms
            • Export/Import schema statistics
            • CONTROL MANAGEMENT PACK ACCESS
            • Generate Explain Plan
            • SQL Query is really hanged or not
          • Oracle Tuning Stage 2
            • STATSPACK
            • ASH
            • AWR
            • Colored SQL_ID
            • SYSAUX Tablespace
          • Oracle Tuning Stage 3
            • Troubleshooting Long Running Queries popular
            • SQL Tuning Advisor
            • SQLT
              • How to Install SQLT
              • How to Run SQLT
              • How to Create Custom SQL Profile
              • Uninstall SQLT
            • Tracing
            • TRCA – Trace Analyzer
          • FF Analysis (Advanced Troubleshooting) - Internal Only
            • Fire-Fighting Analysis (Ongoing / Live Issues)
              • Explain Plan Analysis
              • Top SQL Analysis
              • 10046 Trace Analysis
              • 10053 Trace Analysis
            • Forensic Analysis (RCA – Completed Issues)
        • DB-Admin
          • Oracle Container Database (CDB)
            • CREATE NEW PDB BY CLONING AN EXISTING PDB
            • CREATE PDB USING DBCA
            • CREATE PDB USING SEED
            • DROP PDB MANUALLY
            • STARTUP/SHUTDOWN CDB AND PDB
            • Convert Non-CDB to PDB with DBMS_PDB
            • SCHEMA REFRESH FROM 11G TO 12C PDB
          • Non-CDB
            • Store DB credentials in Oracle Wallet
            • Create database -DBCA silent mode
            • Drop Database
            • Delete database -DBCA silent mode
            • DBT-06103 The port (1,522) is already used - DBCA
            • Create DB 19C – DBCA-GUI
            • Create DB 19C – DBCA-SILENT
            • CREATE NON-CDB ON ORACLE 12C IN SILENT MODE
            • Configure OEM Express 12c
            • Create Non-CDB on Oracle 12c using DBCA (GUI)
            • How to Change MAX_STRING_SIZE on Physical Standby Environment
            • How to change SQL  prompt to show connected user and database name
            • Enable Archivelog
            • Change Archive Dest
            • How to Recover Loss of DATA – (Without a Backup!)
            • Configure OEM DBConsole manually
            • Proxy User
            • Database Link
            • DBMS_SCHEDULER
            • Enable/Disable JOBS during Maintenance
            • ORA-00054
            • Blocking Sessions
            • Create Service using DBMS_SERVICE
            • Error TNS-12543
          • Under Edit
        • Backup & Recovery
          • How to Recover Loss of DATA – (Without a Backup!)
          • BACKUP ORACLE HOME AND INVENTORY
          • SCHEMA REFRESH FROM 11G TO 12C PDB
          • RMAN-CATALOG
          • RMAN Database Restore RAC – RAC
          • RMAN Database Restore ASM – ASM
          • RMAN Database Restore from ASM to File System
          • RMAN ACTIVE DUPLICATION ASM TO ASM
          • Backup Based RMAN Duplicate Database
        • HA
          • CONFIGURATION
            • Active Dataguard on Non-ASM
            • Active Dataguard on ASM
            • Convert Physical Standby Database to Snapshot Standby Database
            • Convert Snapshot Standby database to Physical Standby database
            • Configure Cascading Standby Database
            • DG Broker Configuration
            • DG Broker Error – ORA-16714
            • Disable DG Broker
            • 12.2 Active Dataguard in CDB on Non-ASM
            • Create Physical Standby using RMAN Backup Without Duplicate Command
            • Create Physical Standby using RMAN Backup with Duplicate Command
            • 12c DG Broker Configuration
            • Enable Real-Time Apply
            • Refresh Standby Database using RMAN Incremental SCN Backup
            • Resetlogs on Primary where Standby in place
            • Drop SRL
          • SWITCHOVER
            • Switchover Manual No-Broker
            • Switchover with Broker
          • FAILOVER
            • Failover with Broker(No Flashback)
            • Failover with No Broker (No Flashback)
            • Failover with Broker using Flashback
            • Failover with No Broker using Flashback
  • ExaData
    • Oracle Exadata – Overview
    • Exadata DB Server (Compute Node)
    • Exadata Storage Server (Cell Node)
    • ExaData infi Network
    • Exadata Part Replacement Runbook
    • CellCLI Commands
  • RAC
        • RAC Install
          • Create users, groups and Paths for Oracle RAC
          • RAC Install 11.2.0.3
          • Upgrade GI to 11.2.0.4
          • Downgrade GI to 11.2.0.3
          • root.sh failed with ORA-29783 on RAC
          • Delete Node
          • Add Node
          • Delete Node without remove software
          • Add Node Back which was DELETED without remove software
        • ASM
          • Configure UDEV Rules for Oracle ASM
          • Configure ASMLib for Oracle ASM
          • Move ASM Spfile to diff. DiskGroup
          • ASM Commands
          • Instantiating disk: failed
          • CSSD won’t start automatically
          • Create ACFS File System on RAC
        • RAC Admin
          • How to take OCR backup on 11.2.0.4
          • Cluster Name
          • Move/Relocate OCR
          • Restore loss of all VOTE disk
          • Cluster Startup issues
          • Add SCAN
        • RAC Standby 12.2
        • RAC Tools
          • CLUVFY
          • OSWatcher
  • GG
    • GoldenGate Installation
    • Unidirectional DML Replication
    • Zero Downtime Migration
    • DDL Replication
    • GoldenGate 12C Installation
    • Integrated Capture
    • Oracle GoldenGate Heterogeneous Replication
    • Credential Store
    • ADD NEW TABLE TO AN EXISTING GOLDENGATE CONFIGURATION
    • Install Oracle GoldenGate 19C for Database 12C
    • Install Oracle GoldenGate 19C for Database 19C
  • OEM
    • Install OEM 13.2
    • Install OEM 13.3
    • Add Targets Manually on EM Cloud Control 13c
    • Upgrade OMSPatcher
    • Apply Patch on OMS 13.1
    • Apply Patch on Agent 13.1
  • PostgreSQLNew
        • PostgreSQL Installation & Basics
          • PostgreSQL Versions & Features
          • Install PostgreSQL 13 Using Source Code (Offline Method)
          • Install PostgreSQL 15 using yum Repository on Linux
          • Install PostgreSQL 17.4 from Source code (Offline Method)
          • Install PostgreSQL 17.6 using RPM Packages (Offline Method)
          • Install PostgreSQL 17 client (dnf Method)
          • Uninstall PostgreSQL 17(RPM Method)
          • Uninstall PostgreSQL 17(Source Method)
          • Uninstall PostgreSQL 17 client (dnf Method)
          • How to Set cluster_name in PostgreSQL
          • Create a Second PostgreSQL Instance on the Same Linux Server
          • How to START/STOP PostgreSQL 13 on Linux
          • Types of Shutdown in PostgreSQL
        • PostgreSQL DBA Interview QuestionsNew
          • Beginner Level
          • Intermediate Level
          • Advanced Level
        • PostgreSQL DBA ScriptsNew
        • PostgreSQL Storage & Architecture
          • PostgreSQL Architecture
          • initdb – PostgreSQL Cluster Initialization
          • How SELECT, INSERT, UPDATE, and DELETE Work Internally in PostgreSQL
          • Physical Database Directory Layout on Disk
          • PostgreSQL vs Oracle Terminology
          • PostgreSQL Tablespace Internals
          • Change Data Directory
          • WAL Files
          • Change pg_wal path
          • PostgreSQL Tablespace
        • PostgreSQL Database, User Management & Security
          • Create Database in PostgreSQL v1.0
          • Databases in PostgreSQL v2.0
          • PostgreSQL User Management - version 1.0
          • PostgreSQL User & Role Management - version 2.0
          • Host-Based Authentication in PostgreSQL (pg_hba conf)
          • Identity Mapping in PostgreSQL (pg_ident.conf)
        • Backup & Recovery
          • Enable Archive Mode
          • Disable ARCHIVELOG
          • Backup & Restore using PostgreSQL COPY
          • Logical - pg_dump and pg_restore (Backup & Restore)
          • Logical - pg_dumpall (Backup & Restore)
          • Physical - pg_basebackup (Backup and Restore)
          • Backup & Restore to Another Host (No Archive Mode)
          • Backup & Restore on Same Host
          • Restore PostgreSQL to New Host using pg_basebackup + WAL Archives
          • PostgreSQL PITR – Point in Time Recovery
        • High Availability
          • Streaming Replication
          • Manual Failover - Streaming Replication
          • Synchronous Replication
        • Replication Manager (repmgr)
          • PostgreSQL HA Setup with REPMGR + Automatic Failover
        • Patroni HA
          • etcd Cluster Setup
          • Patroni and Postgres
          • Haproxy (Load Balancer)
          • Keepalived VIP
        • Oracle to PostgreSQL via ora2pg
        • EDB Postgres
  • SQL Server
        • SQL Server Installation & Basics
          • SQL Server Basics
          • Install Microsoft SQL Server Express 2014
          • Install Only SQL Server Management Studio
          • Create Database using GUI
          • Enable TCP/IP Connection
          • Allow Remote Connection
        • SQL Server Security & User Management
          • Authentication Method
          • Create a new domain user account in Windows
          • Create Windows Authentication Login
          • Create SQL Server Authenticated Login in SQL Server
          • Create Windows Group Authentication Login in SQL Server
        • SQL Server Backup & Recovery
          • SQL Server – Recovery Models
          • Database Backup-FULL-DIFFERENTIAL-TLOG
          • Restore Database without Tail-log Backup
          • Restore Database with Tail-log Backup
        • SQL Server High Availability
          • Log Shipping (SQL Server 2022)
          • Windows Server 2022 Failover Cluster
          • Setup 4 Node Always On Availability Group
          • Who is NT AUTHORITY\SYSTEM?
          • Add Database to Existing AG using Backup and Restore
          • Manual Failover (Planned)
          • Automatic Failover (Unplanned)
  • MySQL
    • Install MySQL 8 on Linux 7 Using RPM Packages
    • Create MySQL Database
    • Create New User Account in MySQL
    • Grant Privileges in MySQL
    • Create Roles in MySQL
    • How To Backup MySQL Database Using mysqldump
    • How to Restore Database from Single MySQL Database Backup
    • How to Restore A Single Database From A Backup File Which Contains Multiple Databases
    • How To Restore Single Table From Full Database Backup in MySQL
    • How To Configure MySQL Master-Slave Replication?
  • DB2
    • Install DB2 V10.5 using GUI
    • DB2 STOP and START
    • DB2 Troubleshooting Guide
  • DevOps
    • Install and Configure Git on Linux 9
    • How to Install Jenkins on Linux
    • Install Docker on Linux
    • Docker Cheat Sheet

Identity Mapping in PostgreSQL (pg_ident.conf)

Identity Mapping in PostgreSQL (pg_ident.conf)

Table of Contents


1. What is pg_ident.conf?
2. File Format & Configuration
3. Simple 1:1 Mapping
4. Simple Mapping (Many-to-One)
5. Certificate-Based Mapping
6. Complete Workflow: Setup, Configure & Test

1. What is pg_ident.conf?

pg_ident.conf defines user name maps — rules that translate externally authenticated identities (OS logins, certificate CNs, Kerberos principals, etc.) into PostgreSQL roles. By default, no mapping is configured, use pg_ident.conf when the external identity should not match the PostgreSQL role name exactly (e.g., mapping OS user rajesh to database role app_readonly).

  • When to use: Peer, ident, gss, sspi, cert, and radius authentication methods.
  • When NOT to use: Password-based methods (md5, scram-sha-256) ignore this file entirely.
  • Key point: A map has no effect until referenced by name from pg_hba.conf using map=MAPNAME.

Where are the files? Check with:

postgres=# SHOW hba_file;
             hba_file
----------------------------------
 /pgData/pgsql17/data/pg_hba.conf
(1 row)

postgres=# SHOW ident_file;
             ident_file
------------------------------------
 /pgData/pgsql17/data/pg_ident.conf
(1 row)

postgres=#

2. File Format & Configuration

pg_ident.conf has three whitespace-separated columns per line: ()

# MAPNAME                SYSTEM-USERNAME            PG-USERNAME 
 Label (any name)        OS USERNAME                PostgreSQL (user or role)
  • MAPNAME: A label you choose, referenced later in pg_hba.conf.
  • SYSTEM-USERNAME: The external identity (OS username, certificate CN, etc.).
  • PG-USERNAME: The PostgreSQL role to map to.
  • Entries are evaluated top-to-bottom, first match wins.

Reference the map in pg_hba.conf: (Example)

# TYPE     DATABASE   USER      ADDRESS         METHOD    OPTIONS
local      all        all                       peer      map=demo_map
hostssl    all        all       0.0.0.0/0       cert      map=demo_map

Reload configuration without restart:

SELECT pg_reload_conf();    <---- from psql 
# OR
pg_ctl reload -D $PGDATA <---- As postgres os user # OR systemctl reload postgresql <---- As root os user

3. Simple 1:1 Mapping

Map an OS user to a PostgreSQL role with a one-to-one relationship:

# MAPNAME                   SYSTEM-USERNAME            PG-USERNAME
demo_map                    rajesh                     rajesh

4. Simple Mapping (Many-to-One)

Many-to-one mapping: Multiple identities map to the same role (useful for shared service accounts)

# MAPNAME                SYSTEM-USERNAME                 PG-USERNAME
demo_map                 amit                            app_readonly
demo_map                 priya                           app_readonly
demo_map                 sandeep                         app_readonly
demo_map                 anjali                          app_readonly

Combined with log_connections = on, you retain an audit trail of which identity initiated each connection.

5. Certificate-Based Mapping

pg_ident.conf works with client certificate authentication by matching against the certificate’s Common Name (CN) instead of OS username:

# pg_hba.conf
# TYPE      DATABASE   USER      ADDRESS         METHOD    OPTIONS
hostssl    all         all       0.0.0.0/0       cert      clientcert=verify-full map=demo_map

# pg_ident.conf
# MAPNAME                SYSTEM-USERNAME                 PG-USERNAME
 demo_map                  app-client-01                      app_service

6. Complete Workflow: Setup, Configure & Test

-- 1. Create the OS user
[root@pgdb02 ~]# useradd rajesh
[root@pgdb02 ~]# id rajesh
uid=1003(rajesh) gid=1003(rajesh) groups=1003(rajesh)
[root@pgdb02 ~]#

[root@pgdb02 ~]# useradd ravi
[root@pgdb02 ~]# id ravi
uid=1004(ravi) gid=1004(ravi) groups=1004(ravi)
[root@pgdb02 ~]#
-- 2. Create the PostgreSQL role

postgres=# CREATE USER rajesh;
CREATE ROLE
postgres=#

postgres=# CREATE USER ravi;
CREATE ROLE
postgres=#
*** mapped user rajesh only, user ravi not mapped on pg_ident.conf. Please note this.

-- 3. Add mapping to pg_ident.conf

# MAPNAME            SYSTEM-USERNAME                  PG-USERNAME
demo_map             rajesh                           rajesh

-- 4. Add rule to pg_hba.conf
# TYPE     DATABASE   USER      ADDRESS         METHOD    OPTIONS
local      all        all                       peer      map=demo_map
-- 5. Reload configuration
[postgres@pgdb02 ~]$ pg_ctl reload -D /pgData/pgsql17/data/
server signaled
[postgres@pgdb02 ~]$
-- 6. Test successful connection

[root@pgdb02 ~]# su - rajesh
[rajesh@pgdb02 ~]$ id
uid=1003(rajesh) gid=1003(rajesh) groups=1003(rajesh)
[rajesh@pgdb02 ~]$

[rajesh@pgdb02 ~]$ psql -d postgres
psql (17.10)
Type "help" for help.

postgres=> \c
You are now connected to database "postgres" as user "rajesh".
postgres=>
postgres=> SELECT current_user, session_user;
 current_user | session_user
--------------+--------------
 rajesh       | rajesh
(1 row)

postgres=>

2026-07-08 15:11:59.936 +08 [4662] LOG: connection received: host=[local]
2026-07-08 15:11:59.939 +08 [4662] LOG: connection authenticated: identity="rajesh" method=peer (/pgData/pgsql17/data/pg_hba.conf:132)
2026-07-08 15:11:59.939 +08 [4662] LOG: connection authorized: user=rajesh database=postgres application_name=psql

-- 7. Test failure case (unmapped user - ravi)

[root@pgdb02 ~]# su - ravi
[ravi@pgdb02 ~]$ id
uid=1004(ravi) gid=1004(ravi) groups=1004(ravi) 
[ravi@pgdb02 ~]$
[ravi@pgdb02 ~]$ psql -d postgres
psql: error: connection to server on socket "/run/postgresql/.s.PGSQL.5432" failed: FATAL: Peer authentication failed for user "ravi"
[ravi@pgdb02 ~]$

2026-07-08 15:12:43.890 +08 [4704] LOG: connection received: host=[local]
2026-07-08 15:12:43.893 +08 [4704] LOG: connection authenticated: identity="ravi" method=peer (/pgData/pgsql17/data/pg_hba.conf:132)
2026-07-08 15:12:43.893 +08 [4704] LOG: no match in usermap "demo_map" for user "ravi" authenticated as "ravi"
2026-07-08 15:12:43.894 +08 [4704] FATAL: Peer authentication failed for user "ravi"
2026-07-08 15:12:43.894 +08 [4704] DETAIL: Connection matched file "/pgData/pgsql17/data/pg_hba.conf" line 132: " local all all peer map=demo_map"
Caution: Your use of any information or materials on this website is entirely at your own risk. It is provided for educational purposes only. It has been tested internally, however, we do not guarantee that it will work for you. Ensure that you run it in your test environment before using.
Thank you
Rajasekhar Amudala
Email: br8dba@gmail.com
LinkedIn: linkedin.com/in/rajasekhar-amudala