Posts

Showing posts from 2020

initdb in PostgreSQL

  Initdb is used to create a new PostgreSQL database cluster refer to the PostgreSQL documentation for more information.  https://www.postgresql.org/docs/9.5/app-initdb.html Syntax:  initdb -D <directory location> Steps to create a new database cluster: 1. Create a required directory and make sure it has proper permissions and ownership mkdir -p /u02/client1 -bash-4.2$ ls -ld /u02/client1 drwx------. 15 postgres postgres 4096 Dec 28 20:06 /u02/client1 2. Create the new database cluster using initdb -bash-4.2$ initdb -D /u02/client1 The files belonging to this database system will be owned by user "postgres". This user must also own the server process. The database cluster will be initialized with locale "en_US.UTF-8". The default database encoding has accordingly been set to "UTF8". The default text search configuration will be set to "english". fixing permissions on existing directory /u02/client1 ... ok creating subdirectories ... ok sele...

Devops

Maven Maven is an Open Source, Java-based build tool and developed by Apache. Maven is a powerful project management tool that is based on POM (project object model).  It is used for project build, dependency, and documentation. Different build tools: Java           -> ANT/Maveen/Gradle .Net            -> Nant/MS Build Python      -> PyBuilder Ruby          -> Rake Using Jave can be developed 3 different types of applications: a) Standalone Applications: Types of packages: jar (Java Archive) Examples: .java  .class .jar b) Web Applications Types of packages: war (Web Archive) Examples: Java Code + Web content (Html, CSS, JS, Images) - static contents c) Enterprise Applications Types of packages: ear (Enterprise Archive) Examples: How to run the java class "welcome.java"? Step-1: compile the .java file using javac javac welcome.java .jav files are human-readable forma...

Shell Scripting

                                        Basic Shell Scripting Basic Linux commands: File descriptors <, >, >>, 1>, 2>, 2>&1, &> <   Defaults to a success output >    Write the output to a new file if doesn't exist and if the file exists it truncates or overwrite the       content of the file and write the new content to the file. >> Write the output to a file if doesn't exist and if the file exists it appends the output into it. 1>   Success output  2>   Error output STD INPUT/OUTPUT options:   1>file_name 2>file_name       -> Success and error output into same or different file_name 1>file_name 2>&1             ->  Error out will be stored where you success output stores &>f...

Upgrade MongoDB cluster from 3.4 to 3.6 on Linux environment

This document using a "rolling" upgrade to minimize downtime by upgrading the members individually while the other members are available Starting in MongoDB 3.6, mongod and mongos instances bind to localhost by default. Remote clients, including other members of the replica set, cannot connect to an instance bound only to localhost. To override and bind to other ip addresses, use the net.bindIp configuration file setting or the --bind_ip command-line option to specify a list of ip addresses. The upgrade process will require that you specify the net.bindIp setting (or --bind_ip), if your replica set members are run on different hosts or if you wish remote clients to connect to your replica set. Read Concern Majority:    Starting in MongoDB 3.6, MongoDB enables support for "majority" read concern by default. For MongoDB 3.6.1 - 3.6.x, you can disable read concern "majority" to prevent the storage cache pressure from immobilizing a deployment with a primary-s...

rs.stepDown() in MongoDB replication

It instructs the primary of the replica set to become a secondary. After the primary steps down,the eligible secondaries will hold an election for primary. Generally, the rs.stepDown() does not immediately step down the primary. If no electable secondaries are up to date with the primary, the primary waits up to secondaryCatchUpPeriodSecs (by default 10 seconds)  for a secondary to catch up. Once an electable secondary is available, the method steps down the priamry.  Once stepped down, the original primary becomes a secondary and is ineligible from becoming primary again for the remainder of time specified by stepDownSecs. The rs.stepDown() method attempts to terminate long-running user's operations that block the primary from stepping down, such as an index build, a write operation, or a map-reduce job. Syntax: rs.stepDown(stepDownSecs, secondaryCatchUpPeriodSecs)

Default MongoDB Ports

27017 -> The default port for mongod and mongos instances. You can change this port with --port option 27018 -> The default port for mongod when running with --shardsvr command-line option or the                  shardsvr value for the clusterRole setting in a configuration file. 27019 -> The default port for mongod when running with --configsvr command-line option                  or the configsvr value for the clusterRole setting in a configuration file.

MongoDB Profiler

Generally, When data grows with any type of database, we see performance issues. The workaround would be simply rewriting the problematic query or analyze/optimize the database schema could make drastic performance improvements. MongoDB provides a couple features to analyze the performance of problematic queries or overall database performance issues and that would help DBAs, like Query Profiler, Mongostat, Mongotop and good logging support.  Configure or Enable the MongoDB Profiler The internal collection "systems.profile", which stores all the profiler related information into it and you can queried anytime like another collection.  Profiler has 3 levels of profiling Level 0, Level 1 and Level2. By default the profiler level is set to Level 0. Level 0 -> Profiler will not log any data. Level 1 -> Profiler will log only slow operations above some threshold. Level 2 -> Profiler will log all the operations.

Remove Shards from the existing Sharded cluster

Important points to be considered  before removing the shard from the existing shard cluster Make sure that the shard data is migrated to the other shards successfully. Make sure the balancer is enabled before you run the remove shard. Step-1: find the shard name to be removed  To find the name of the shard, connect to mongos instance.  db.adminCommand( { listShards: 1 } ) Output: mongos> db.adminCommand( { listShards: 1 } ) { "shards" : [ { "_id" : "replicaset1", "host" : "replicaset1/mysql8.localdomain:27011,mysql8.localdomain:27012,mysql8.localdomain:27013", "state" : 1 }, { "_id" : "replicaset2", "host" : "replicaset2/mysql8.localdomain:27021,mysql8.localdomain:27022,mysql8.localdomain:27023", "state" : 1 }, { "_id" : "replicaset3", "host" : "replicaset3/mysql8.localdomain:27031,mysql8.lo...

Configure Delayed, hidden member and Arbiter in MongoDB

Steps to Configure Delayed, hidden member and Arbiter in MongoDB To configure replication please follow the below link. https://ferozmdba.blogspot.com/2020/07/mongodb-replication-and-sharding.html Points to remember Hidden member will always be a priority "0" Delayed member will be a hidden member and priority "0" member When you consider a hidden one, make sure that priority is also "0" When configuring a delayed on, make sure that it has priority "0" as well as it is hidden. Steps to make replica as hidden var config=rs.conf() config.members[3].priority=0; config.members[3].hidden=true; rs.reconfig(config); Steps to configure slave Delayed var config=rs.conf() config.members[4].slaveDelay=3600 rs.reconfig(config);

Steps to configure replica set priority in MongoDB

 Configure replica set priority in MongoDB T o configure replication please follow the below link. https://ferozmdba.blogspot.com/2020/07/mongodb-replication-and-sharding.html 1. Add a few more mongo instances, since we have 3 mongo instances running on ports 27107,27108 and 27109. So add two more instances. mkdir -p /home/replica04 mkdir -p /home/replica05 2. start the 3 mongod server mongod --dbpath /home/replica04 --port 27107 --logpath /home/logs/replica04_log --logappend --fork --bind_ip_all -replSet replicaset01 mongod --dbpath /home/replica05 --port 27108 --logpath /home/logs/replica05_log --logappend --fork --bind_ip_all -replSet replicaset01 3. connect to primary mongod db and run the below commands var config=rs.conf() config.members[1].priority=6;  --- it sets the highest priority config.members[3].priority=0;  ---- this will never become primary whenever there is a primary replica crashes (because now (its bacame as a hidden member) rs.reconfig(config);  ...

Configure Shard/Sharding mongodb

Steps to configure Sharding in MongoDB on Linux 1. Configure 9 different servers mongod --dbpath /home/replica11 --port 27011 --logpath /home/replica11/rep11.log --logappend --fork --bind_ip_all --replSet replicaset1 --shardsvr mongod --dbpath /home/replica12 --port 27012 --logpath /home/replica12/rep12.log --logappend --fork --bind_ip_all --replSet replicaset1 --shardsvr mongod --dbpath /home/replica13 --port 27013 --logpath /home/replica13/rep13.log --logappend --fork --bind_ip_all --replSet replicaset1 --shardsvr mongod --dbpath /home/replica21 --port 27021 --logpath /home/replica21/rep21.log --logappend --fork --bind_ip_all --replSet replicaset2 --shardsvr mongod --dbpath /home/replica22 --port 27022 --logpath /home/replica22/rep22.log --logappend --fork --bind_ip_all --replSet replicaset2 --shardsvr mongod --dbpath /home/replica23 --port 27023 --logpath /home/replica23/rep23.log --logappend --fork --bind_ip_all --replSet replicaset2 --shardsvr mongod --dbpath /home/replica31 -...

Migrate the data from one disk to another or Add new disk and remove old disk in oracle ASM

old disk: DATA_DISK New disk: DATA12_DISK Step-1: check what disks are allocate to the diskgroup . oraenv +ASM1 sqlplus / as sysasm set linesize 300 set pagesize 1000 set colsep | col name for a15 col PATH for a44 col HEADER_STATUS for a10 col MODE_STATUS for a10 col DN for 9999 col STATE for a10 col LABEL for a25 select group_number,name from v$asm_diskgroup order by name; select        a.GROUP_NUMBER gn,       b.name,       a.DISK_NUMBER DN,       a.PATH,       a.MOUNT_STATUS M_Status,       a.HEADER_STATUS H_Status,       a.MODE_STATUS,       a.STATE,       a.OS_MB,       a.TOTAL_MB,       a.FREE_MB from         v$asm_disk A,        v$asm_diskgroup B        Where A.group_number=B.group_number(+)         and a.GROUP_NUMBER = ...

Oracle DBA Interview Questions and Answers

---- RMAN ---- backup strategy --------------- We are using tape backup every Sunday - Level 0 backup (full) from Monday to sat - incremental backup every 1 hour - archive log backup Hot vs cold backup ------------------- what is difference --> what is the benefit cold backup does not required recovery - because it is a consistent backup hot backup needs recovery -- because during backup time data will modify restore vs recovery -------------------- restore - restoring datafile from secondary backup location to primary location like from tape to disk recovery- applying archivelogs - doing this it make database into consistent state scenario -------- 1. If datafile SCN is higher than the other datafiles - what is the reason and how you do recovery 2. If i have 2 system datafiles, one of the datafile is lost (someone removed from OS level) can you bring the database in mount state? 1. How to check backups are failed? - V$RMAN_BACKUP_JOB_DETAILS 2. How to resolve backu...