Recovering from loss of all control files

“Sometimes shit happens”. That’s what I thought when I realized that I had lost all the control files of one of my test databases. Of course, I had no backup because “it’s just a test database”…

Fortunately, I only lost my control files but no datafiles or redo log files. This is a very important point because if you are in this situation, all is not lost!

So today, I will show you how you can recover your Oracle database after the loss of all control files.

Continue reading “Recovering from loss of all control files”

Extract the list of all databases with server and OS version of Oracle Enterprise Manager Cloud Control repository

Today, I’m going to share with you a simple SQL query that will allow you to quickly extract useful information from your OEM repository about your databases:

  • Database name
  • Database version
  • Server name
  • Server OS
  • OS version

The query can be very useful if you need to fill in a new CMDB for example.

Continue reading “Extract the list of all databases with server and OS version of Oracle Enterprise Manager Cloud Control repository”

Get indexes usage for all collections of all databases of your MongoDB instance

One possible area of ​​improvement when you encounter bottlenecks when inserting or updating in MongoDB is to limit the number of indexes on your collections.

Even though indexes are good for queries against collections, they add an extra step when inserting or updating, which may take some time. Given this fact, it may be wise to delete unused indexes.

So, today, I’m going to give you a Mongo shell script that I use to get statistics on indexes usage for all collections on a MongoDB instance and to identify those that are not used.

Continue reading “Get indexes usage for all collections of all databases of your MongoDB instance”

MongoDB sharded cluster topology

Today, I’m going to share with you a bash script that gives you a quick overview of the topology of your MongoDB cluster.

It will give you:

  • The list and status of your mongos
  • The list and status of your config server
  • The list and status of every replica set members present in your cluster (including secondary members and arbiters), plus:
    • The date of the last role change between primary and secondary
    • The apply lag between primary and all secondary members
    • The oplog window
  • The balancer status

You can download the script on my GitHut repository “MyDBAWorld”.

Continue reading “MongoDB sharded cluster topology”

Database Link: ORA-12154: TNS:could not resolve the connect identifier specified

If you are familiar with database links on Oracle database, you may have already encountered the error “ORA-12154: TNS:could not resolve the connect identifier specified“. That is a common error which can be caused by a lot of factors. Today, I’m going to focus on the importance of environment variables to avoid this type of error message (particularly the “TNS_ADMIN” environment variable).

Continue reading “Database Link: ORA-12154: TNS:could not resolve the connect identifier specified”

Replicate a table without primary key or unique key with GoldenGate

Yesterday, I was working on a simple Golden Gate replication between two Oracle databases. Everything worked as expected, the source and target schemas were synchronized and the replication lag was about 0 seconds.

Unfortunately; after a couple of hours, I notice a 2 hours lag on the replicat

After some research on GoldenGate and with some queries on v$session and v$sql, I realize that the lag is due to a 100 million rows table on which there is no primary key or unique key defined.

Important point: I was not allowed to add constraints on the source database!

Continue reading “Replicate a table without primary key or unique key with GoldenGate”

How to deal with MongoDB shell output in your shell scripts – Part 2/2: parsing JSON with jq

If you read my last post, you now know how to get a valid JSON output from your MongoDB shell.

But raw JSON is often useless in your scripts because you have to manipulate it to extract only the information you need.

For this purpose, I personalty use a free tool called “jq“. It is very powerful and has many advanced features. I will only show you some basic concepts that will allow you to simply deal with JSON data in your scripts.

Continue reading “How to deal with MongoDB shell output in your shell scripts – Part 2/2: parsing JSON with jq”

How to deal with MongoDB shell output in your shell scripts – Part 1/2: produce valid JSON output

Today, I will show you how to easily deal with MongoDB shell output in your shell (bash, ksh, …) scripts.

For readybility purpose, this topic will be divided into 2 posts. This part will focus on how to produce valid JSON output from your MongoDB shell using the “–eval” option. Second part will focus on how to use “jq” to manipulate JSON data.

Continue reading “How to deal with MongoDB shell output in your shell scripts – Part 1/2: produce valid JSON output”