Oracle Data Guard In A Cloud - Part I
A Linux Primer
As I always say: this blog is about sharing what I learn through my immensely satisfying struggles. Now when I am ready to pen down that means I am on to something. Quite precisely, recently I learned how to stand up an Oracle Active Data Guard in Amazon cloud. That also on a linux environment.
You will see tons of articles that spells out how to build an active data guard in bits and pieces. In fact, you will also see some published articles that says “Oracle Data Guard in minutes” or “Oracle Data Guard in 10 easy steps”. Yeah, all great for basic environments. Believe me, when I went through these articles it was not as easy as being portrayed.
In this series I will walk you through each step for building the active data guard and also share the troubles I experienced along the way.
Before we begin here are few suggestions,assumptions and facts.
Suggestions
- If you are not a linux admin then please get a hold of someone on your team who is a linux admin.It will make your life easier.
- If you are just starting with the linux environment then get yourself familiarized with some of the most common linux commands like,
- How to copy files between directories
- How to copy files between different machines
- How to change file permissions
- How to change directory permissions
- How to change users
- How to run .sh files (executable script files)
- Play with the environment and practice these commands.
Assumptions
- You have 3 linux boxes running in Amazon cloud.
- You have configured security groups for these servers in the cloud.
- You have ASM configured and ASM disks attached to these servers. I pinged a really cool linux admin on my team to do this for me.
- You have installed Oracle Binaries and configured a sample database on the primary server. We will replicate this sample database.
- All servers are running on the same network.
- Port 1521 is open between these servers. Contact your network admin to put an ACL rule for the firewall to allow a two way communication over this port.
- As mentioned in the Oracle docs: Oracle user must be a member of oinstall and dba groups.
- Primary and secondary server are identical. i.e. file system structure, Oracle binaries, Oracle patches etc..
Facts
- I am on the Amazon Cloud.
- I am not running an Oracle RAC. Entire series is based on a single node Oracle database configured with an Active Data Guard running in a Maximum Availability mode.
- I am using Oracle 11g.
- I am a newbie to Linux environment. Therefore, all linux gurus or DBAs with linux expertise reprimand me if you see a silly mistake on the linux front. All ears.
- I am a front end developer. Don’t get me wrong: I love databases but I am really passionate about building applications using open source stack. I build REST APIs using NodeJS and SLIM framework. I write front end applications using jQuery, Angular, ExtJs and any JS library that interests me. Now you’d say: I have no business writing this series since I am not a DBA. I hear you young gunz. But like I said: databases have always fascinated me and so here is to my love for the databases.
Before we begin...
We will be using 3 servers in the cloud.
- Primary Server for our primary database
- Secondary Server for our physical standby database
- Observer to observe our active data guard environment
Now let's look at db_unique_name and service_name for primary and standby databases.Remember this: db_unique_name must be unique for each server. For primary server we set db_unique_name to cssdev and for secondary server we set db_unique_name to cssdg1.
Primary Server
- Host name: primary_server
- db_unique_name = 'cssdev'
- service_name = 'cssdev'
Secondary Server (standby)
- Host name: standby_server
- db_unique_name = 'cssdg1'
- service_name = 'cssdg1'
Observer
- Host name: ob_server
Note: In a real world, host names are usually cryptic like: RAPCRYP001 or RAPMDG321...but for simplicity I am naming my servers as primary_server, standby_server and ob_server.
And here is what we will learn from this series...
- How to prepare a primary & secondary servers for Active Data Guard
- How to copy backups from ASM to ASM
- Learn how to configure redo log transport
- Configure Oracle Data Guard Broker
- Perform switchovers using Oracle Data Guard Broker
- Configure Data Guard Observer
- Configure environment for seamless applications
Linux Primer
I just admitted that I am a newbie to Linux, then why am I writing a Linux primer? Well, my intention here is to show you few repetitive commands I have used throughout this series.
How to copy files between directories?
[root@server] > cp file1.ora /your_directory/
How to rename a file?
[root@server] > mv file1.ora file2.ora
How to change users?
Assuming I am the root user and want to change to user oracle.
[root@server] > sudo -i
[root@server] > su - oracle
[oracle@server] >
How to change file permissions?
Use chmod to modify the file permission and chown to change the ownership of the files or directories. Sure there are different switches to be used with these commands. For example, I want to assign “Read and Execute” permissions on a file to all users. For that I will use,
[root@server] > chmod 755 file1.ora
There are various octal codes to be used for assigning permissions. A simple google search will find plenty of articles explaining what these octal codes mean and how to utilize them.
How to change an ownership of a file or a directory?
Use chown command to modify ownership of a given object. Let’s say we want to change an owner for file1.ora to oracle.
[root@server] > chown oracle file1.ora;
Now what about a directory and all files under that directory? Easy, just use a switch -R.
[root@server] > chown -R oracle /u01/ora_scripts;
Command above will change ownership of ora_scripts directory and all files under that directory to user Oracle.
How to run an executable file?
We will create scripts to connect to SQL prompt, ASM prompt etc..These script files are given a .sh extension. Let’s say we want to get to SQLPLUS prompt. I will run the sqlplus.sh script to put myself on a SQL prompt.
[oracle@primary_server ora_scripts] > ./sqlplus.sh
Pay attention to “./” used in the command above. It tells the linux command line to execute the script.
Enough! Now go practice these commands and I will see you in the next article. In the next article we will prepare utility scripts which will make our life easier, well a lot easier.
See you then.
Hi, I am Ritesh Patel. I live in a beautiful town surrounded by the mountains. C&O Canal is few miles away. State parks are only a distance away & bike trails galore. It is home sweet home Frederick, MD. A passionate developer. Love to cook. Enjoy playing "Bollywood Tunes" on my harmonica. Apart from that just a normal guy.