Thursday, August 29, 2024

MongoDB - Performance Tuning in Linux for DBAs

There are some important elements must be considered carefully for tuning database performance.

1. File Systems

  • Using XFS as it generally performs better with MongoDB. 
  • With the WiredTiger storage engine, using XFS is strongly recommended for data bearing nodes to avoid performance issues that may occur when using EXT4 with WiredTiger.
  • Set 'noatime' on MongoDB data volumes in /etc/fstab
2. Swappiness
  • “Swappiness” is a Linux kernel setting that influences the behavior of the Virtual Memory manager. The vm.swappiness setting ranges from 0 to 100: the higher the value, the more strongly it prefers swapping memory pages to disk over dropping pages from RAM
  • Set vm.swappiness to 1, not 0
  • Allocating RAM as much as possible (storage.wiredTiger.engineConfig.cacheSizeGB)
  • Transparent Huge Pages (THP) is a Linux memory management system that reduces the overhead of Translation Lookaside Buffer (TLB) lookups on machines with large amounts of memory by using larger memory pages.
  • However, database workloads often perform poorly with THP enabled, because they tend to have sparse rather than contiguous memory access patterns. When running MongoDB on Linux, THP should be disabled for best performance
  • Avoid overloading the connection resources of a mongod or mongos instance by adjusting the connection pool size to suit your use case.
  • Specify connection pool settings in these locations:
    • The MongoDB URI
    • Your application's MongoClient instance
    • Your application framework's configuration files
  • Some parameters control connections in /etc/mongod.conf file:
    • net.maxIncomingConnections
    • setting parameters with setParameter: option
  • For improved performance, consider separating your database's data, journal, and logs onto different storage devices, based on your application's access and write pattern. 
  • Mount the components as separate filesystems and use symbolic links to map each component's path to the device storing it.
  • For the WiredTiger storage engine, you can also store the indexes on a different storage device by configuring storage.wiredTiger.engineConfig.directoryForIndexes parameter.

PostgreSQL - Upgrade Methods

There are several upgrade database methods, such as:
  • Upgrade with downtime
    • Using pg_dump and pg_restore
    • Using pg_upgrade
      • pg_upgrade (formerly called pg_migrator) allows data stored in PostgreSQL data files to be upgraded to a later PostgreSQL major version without the data dump/restore typically required for major version upgrades, e.g., from 12.14 to 13.10 or from 14.9 to 15.5. It is not required for minor version upgrades, e.g., from 12.7 to 12.8 or from 14.1 to 14.5
      • pg_upgrade supports upgrades from 9.2.X and later to the current major release of PostgreSQL, including snapshot and beta releases
    • Using pg_dumpall
  • Upgrading with no/near zero downtime using logical/trigger based replication
    • PostgreSQL logical replication (v10 and above)
      • Known as transactional replication, the subscriber initially receives a copy of the replicated database object from the publisher and pulls any subsequent changes on the same object as they occur in real-time.
      • The typical use-cases for logical replication are:
        • Sending incremental changes in a single database or a subset of a database to subscribers as they occur.
        • Firing triggers for individual changes as they arrive on the subscriber.
        • Consolidating multiple databases into a single one (for example for analytical purposes).
        • Replicating between different major versions of PostgreSQL.
        • Replicating between PostgreSQL instances on different platforms (for example Linux to Windows)
        • Giving access to replicated data to different groups of users.
        • Sharing a subset of the database between multiple databases.

Wednesday, August 28, 2024

MongoDB - /etc/mongod.conf sample file

[root@mongodb-01 ~]# cat /etc/mongod.conf 
# mongod.conf

# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/

# where to write logging data.
systemLog:
  destination: file
  logAppend: true
  path: /var/log/mongodb/mongod.log

# Where and how to store data.
storage:
  dbPath: /u01/mongoDB/helloWorld
  journal:
    enabled: true
  engine: wiredTiger
  wiredTiger:
    engineConfig:
      journalCompressor: snappy
      cacheSizeGB: 1.5            // Adjust base on physical resource
    collectionConfig:
      blockCompressor: snappy

# how the process runs - Controls how MongoDB is managed as a system process.
processManagement:
  fork: true                              # Enable MongoDB to run as a background daemon.
  pidFilePath: /var/run/mongodb/mongod.pid     # Location of the PID file when running as a service.
  timeZoneInfo: /usr/share/zoneinfo

Saturday, August 24, 2024

13.5.0 Enterprise Manager Cloud Control - Patching RU22 from Base version

Overview of the Enterprise Manager Proactive Patch Program (Doc ID 822485.1)

 

List of patches:

  • OMS – RU 22
    • Patch 36335368: 13.5.0 Enterprise Manager Cloud Control Base Platform Monthly Release Update (RU) 22
    • Patch 19999993: OMSPatcher patch of version 13.9.5.20.0 for Enterprise Manager Cloud Control 13.5.0.0.0
    • Patch 28186730: OPATCH 13.9.4.2.15 FOR EM 13.5 AND FMW/WLS 12.2.1.4.0 and 14.1.1.0.0
    • Patch 35430934: MERGE REQUEST ON TOP OF 12.2.1.4.0 FOR BUGS 32720458 33607709
    • Patch 34153238: HTTPS PROXY CONFIGURATION IS NOT USED WHEN PROTOCOL IS CONFIGURED TO TCP
    • Patch 31657681: THREADS CONTEND FOR LOCK IN LOADFILEBASEDKEYSTORE WHEN OPENING TLS/SSL ENABLED JDBC CONNECTIONS
  • Agent – RU 22
    • Patch 36335371: Oracle Enterprise Manager 13c Release 5 Update 22 ( 13.5.0.22 ) for Oracle Management Agent
    • Patch 33355570: AgentPatcher release of version 13.9.5.8.0 for Enterprise Manager Cloud Control Agent 13.5.0.0.0

Notes:

  • Backup Database and Application before Patching
  • Apply OMS RU 22 before applying Agent RU 22
  • Apply OMSPatcher and OPatch the latest version before applying OMS RU 22
  • Apply Oracle Database to the latest version of Oracle Database 19c before applying OMS RU 22

Main steps:

  • Apply Oracle Database to the latest version of Oracle Database 19c
  • Apply OMSPatcher and Opatch to the latest version
  • Apply OMS RU 22
  • Apply Agent RU 22

 

Friday, August 23, 2024

13.5.0 Enterprise Manager Cloud Control - Holistic Patch for Oracle Management Service - July 2024

Holistic Patching in Enterprise Manager is a method of applying all stack patch bundle for a given CPU released by Oracle for WebLogic and its components. Applying all SPB,CPU patches on OMS is a downtime patching activity and requires maintenance window. 

NoteThere is no dependency between OMS RU Patch to Holistic Patch.

A. Current System Information

1. Database version

[oracle@monitor-db ~]$ opatch lspatches

36233263;Database Release Update : 19.23.0.0.240416 (36233263)

29585399;OCW RELEASE UPDATE 19.3.0.0.0 (29585399) 

OPatch succeeded.

2. OMS version

[oracle@monitor-app ~]$ . oms_env

[oracle@monitor-app ~]$ omspatcher lspatches

oracle.sysman.db.oms.plugin/13.5.1.0.0            Plugin              36335368            36329033            Oracle Enterprise Manager for Oracle Database 13c Release 5 Plug-in Update 22 (13.5.1.22) for Oracle Management Service

oracle.sysman.cfw.oms.plugin/13.5.1.0.0           Plugin              36335368            36329231            Oracle Enterprise Manager for Cloud Framework 13c Release 5 Plug-in Update 22 (13.5.1.22) for Oracle Management Service

oracle.sysman.xa.oms.plugin/13.5.1.0.0            Plugin              36335368            36329152            Oracle Enterprise Manager for Exadata 13c Release 5 Plug-in Update 22 (13.5.1.22) for Oracle Management Service

oracle.sysman.top.oms/13.5.0.0.0                  Core                36335368            36329009            Oracle Enterprise Manager 13c Release 5 Platform Update 22 (13.5.0.22) for Oracle Management Service

oracle.sysman.si.oms.plugin/13.5.1.0.0            Plugin              36335368            36329196            Oracle Enterprise Manager for Systems Infrastructure 13c Release 5 Plug-in Update 22 (13.5.1.22) for Oracle Management Service

oracle.sysman.emas.oms.plugin/13.5.1.0.0          Plugin              36335368            36329020            Oracle Enterprise Manager for Fusion Middleware 13c Release 5 Plug-in Update 22 (13.5.1.22) for Oracle Management Service

3. Agent version

[oracle@monitor-app ~]$ . agent_env

[oracle@monitor-app ~]$ agentpatcher lspatches

oracle.sysman.si.agent.plugin/13.5.1.0.0          Plugin              36335371            36335417            Oracle Enterprise Manager for Systems Infrastructure 13c Release 5 Plug-in Update 22 (13.5.1.22) for Oracle Management Agent

oracle.sysman.top.agent/13.5.0.0.0                Core                36335371            36335374            Oracle Enterprise Manager 13c Release 5 Platform Update 22 (13.5.0.22) for Oracle Management Agent

4. OMSPatcher version

[oracle@monitor-app ~]$ . oms_env

[oracle@monitor-app ~]$ omspatcher version

OMSPatcher Version: 13.9.5.20.0

OPlan Version: 12.2.0.1.16

OsysModel build: Tue Apr 28 18:16:31 PDT 2020 

OMSPatcher succeeded. 

13.5.0 Enterprise Manager Cloud Control Base Platform Monthly Release Update (RU) 23 - July 2024

Ref: 13.5.0 Enterprise Manager Cloud Control Base Platform Monthly Release Update (RU) 23 (Doc ID 3040236.1)

A. System Information

👉Database version
[oracle@monitor-db ~]$ opatch lspatches
36233263;Database Release Update : 19.23.0.0.240416 (36233263)
29585399;OCW RELEASE UPDATE 19.3.0.0.0 (29585399)

OPatch succeeded.

👉OMS version
[oracle@monitor-app ~]$ . oms_env
[oracle@monitor-app ~]$ omspatcher lspatches


oracle.sysman.db.oms.plugin/13.5.1.0.0            Plugin              36335368            36329033            Oracle Enterprise Manager for Oracle Database 13c Release 5 Plug-in Update 22 (13.5.1.22) for Oracle Management Service

oracle.sysman.cfw.oms.plugin/13.5.1.0.0           Plugin              36335368            36329231            Oracle Enterprise Manager for Cloud Framework 13c Release 5 Plug-in Update 22 (13.5.1.22) for Oracle Management Service

oracle.sysman.xa.oms.plugin/13.5.1.0.0            Plugin              36335368            36329152            Oracle Enterprise Manager for Exadata 13c Release 5 Plug-in Update 22 (13.5.1.22) for Oracle Management Service

oracle.sysman.top.oms/13.5.0.0.0                  Core                36335368            36329009            Oracle Enterprise Manager 13c Release 5 Platform Update 22 (13.5.0.22) for Oracle Management Service

oracle.sysman.si.oms.plugin/13.5.1.0.0            Plugin              36335368            36329196            Oracle Enterprise Manager for Systems Infrastructure 13c Release 5 Plug-in Update 22 (13.5.1.22) for Oracle Management Service

oracle.sysman.emas.oms.plugin/13.5.1.0.0          Plugin              36335368            36329020            Oracle Enterprise Manager for Fusion Middleware 13c Release 5 Plug-in Update 22 (13.5.1.22) for Oracle Management Service

👉Agent version
[oracle@monitor-app ~]$ . agent_env 
[oracle@monitor-app ~]$ agentpatcher lspatches


oracle.sysman.si.agent.plugin/13.5.1.0.0          Plugin              36335371            36335417            Oracle Enterprise Manager for Systems Infrastructure 13c Release 5 Plug-in Update 22 (13.5.1.22) for Oracle Management Agent

oracle.sysman.top.agent/13.5.0.0.0                Core                36335371            36335374            Oracle Enterprise Manager 13c Release 5 Platform Update 22 (13.5.0.22) for Oracle Management Agent

👉OMSPatcher & OPatch version
[oracle@monitor-app ~]$ . oms_env 
[oracle@monitor-app ~]$ omspatcher version

OMSPatcher Version: 13.9.5.21.0
OPlan Version: 12.2.0.1.16
OsysModel build: Tue Apr 28 18:16:31 PDT 2020

OMSPatcher succeeded.

[oracle@monitor-app ~]$ opatch version
OPatch Version: 13.9.4.2.16

OPatch succeeded.

Ref
  • 13.5: How To Upgrade Enterprise Manager 13.5 Cloud Control OMSPatcher Utility to the Latest Version (Doc ID 2809842.1)
  • EM 13c: How To Upgrade Enterprise Manager 13.4 Cloud Control OMSPatcher Utility to the Latest Version (Doc ID 2646080.1)

Wednesday, August 14, 2024

MongoDB - Percona Backup for MongoDB

Percona Backup for MongoDB (PBM) is an open source and distributed solution for consistent backups and restores of MongoDB sharded clusters and replica sets to a specific point in time.

Architecture
Percona Backup for MongoDB consists of the following components:
  • pbm-agent is a process running on every mongod node within the cluster or within a replica set that performs backup and restore operations.
  • pbm CLI is a command-line utility that instructs pbm-agents to perform an operation.
  • PBM Control collections are special collections in MongoDB that store the configuration data and backup states. Both pbm CLI and pbm-agent use PBM Control collections to check backup status in MongoDB and communicate with each other.
  • Remote backup storage is where Percona Backup for MongoDB saves backups. It can be either an S3 compatible storage or a filesystem-type storage.
The following diagram illustrates how Percona Backup for MongoDB components communicate with MongoDB.




1. Installation
  • Install percona-release
    • $ sudo yum install -y https://repo.percona.com/yum/percona-release-latest.noarch.rpm
  • Enable the repository
    • $ sudo percona-release enable pbm release
  • Install Percona Backup for MongoDB packages
    • $ sudo yum install percona-backup-mongodb
[root@mongodb-01 ~]# ls -l /etc | grep pbm
-rw-r-----   1 root         root           3626 May 15 17:10 pbm-conf-reference.yml
-rw-r-----   1 mongod       mongod           91 Aug 14 10:56 pbm-storage.conf

2. Configuration

👀Create user for backup on Primary Node

use admin

db.getSiblingDB("admin").createRole({ "role": "pbmAnyAction",
      "privileges": [
         { "resource": { "anyResource": true },
           "actions": [ "anyAction" ]
         }
      ],
      "roles": []
   });
   
db.getSiblingDB("admin").createUser({user: "p4backup",
       "pwd": "Password789",
       "roles" : [
          { "db" : "admin", "role" : "readWrite", "collection": "" },
          { "db" : "admin", "role" : "backup" },
          { "db" : "admin", "role" : "clusterMonitor" },
          { "db" : "admin", "role" : "restore" },
          { "db" : "admin", "role" : "pbmAnyAction" }
       ]
    });  

Tuesday, August 06, 2024

MongoDB - Replication

Preparation
1. Install mongodb on all nodes
2. Configuring /etc/hosts on nodes
[root@mongodb-xxx ~]# cat /etc/hosts 
192.168.56.87  mongodb-01.taolaoxibup.com               mongodb-01
192.168.56.88  mongodb-02.taolaoxibup.com               mongodb-02
192.168.56.89  mongodb-slave.taolaoxibup.com           mongodb-slave
192.168.56.90  mongodb-arbiter.taolaoxibup.com         mongodb-arbiter    // an arbiter
 
3. Configuring /etc/mongod.conf on all nodes
[root@mongodb-xxx ~]# vi /etc/mongod.conf 
...

# network interfaces
net:
  port: 27017
  bindIp: mongodb-01  # Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting.            // Update right value for each mongos instances

replication:
  replSetName: "rs0"
...

[root@mongodb-xxx ~]# systemctl restart mongod.service 

Configuration

1. On Primary Node
- Initiate the replica set
  • rs.initiate()
  • rs.status()
  • rs.conf()
- Add Members to a Replica Set
  • rs.add({host: "mongodb-02:27017"})
  • rs.add({host: "mongodb-slave:27017"})
- Verify configuration
  • rs.status()
  • rs.conf()
  • rs.hello()
  • db.isMaster()
2. On Secondary node - Verify configuration
  • rs.status()
  • rs.conf()
  • rs.hello()
  • db.isMaster()
3. Add Members to a Replica Set
  • Start new mongod instance
    • mongod --port 27018 --dbpath /u01/mongoDB/saigon --replSet rs0 --bind_ip 0.0.0.0
    • OR nohup mongod --port 27018 --dbpath /u01/mongoDB/saigon --replSet replOMNI --bind_ip_all > 27018_$HOSTNAME.log 2>&1 &
  • On Primary node, add new member to replica set
    • rs.add("mongodb-01:27018")
  • Verify configuration
    • rs.status()
    • rs.conf()
    • db.isMaster()