The documents that CLSA Team sent you will
contain instructions to create DB connections. Those are great, but there is a
potential issue - you will have a problem if your VM’s IP changes.
This will happen if you changed your
network settings or connect through another network. If you cannot guarantee
that you would be in the same network throughout the whole exam, or cannot
confirm that your IP will not change, it is better to follow the instruction
below instead.
- Update PostgreSQL Default Settings
- Update Host-Based Authentication Default Settings
Update PostgreSQL Default Settings
Sadly, if you are unfamiliar with UNIX,
trying to do this would be a mission impossible for you. I will try my best to
give you step-by-step instruction and guidance. When you startup the VM, you
will get the following screen once the VM is started:
Figure 7: VM Screen After Startup
Login using the following:
Login Name: root
Password: install
Once you have logged in, you will see the
following "Last login:" info as follows:
Figure 8: Command Prompt After Login
If your mouse is ‘locked’ in the VM, look for
this image at the bottom of the VM dialog and press the command shown there.
In my case, it is to press the “Ctrl” and “Alt” key together.
|
I am using Oracle Virtual Box, you are free to
use VMWare. However, the free version of the VMWare is VMWare Player, which
does not allow you to do snapshot! Therefore, I do not recommend you to use
VMWare for the exam!
|
There are 2 files that you need to modify:
postgresql.conf
pg_hba.conf
|
The provided document mentioned that those are
in the following location:
/var/lib/pgsql/9.3/data/
|
Sadly, the provided instruction has not
been updated to reflect the actual path in the VM… ☹
That is why, I had told you to prepare all
these as earlier as possible. If you do, you could at least be able to send an
email to ask them.
Nevertheless, it is always better to equip
yourself with more knowledge, including knowledge that is beyond Pega itself.
In this case, some UNIX commands.
The best way out of this is to use the "find" command to look for the file, as follows:
find / -name "postgresql.conf"
|
The following is the screenshot:
Figure 9: New Location for the DB
Configuration Files
From the output, you can see that the file
is now located in:
/var/lib/pgsql/9.4/data
|
Obviously, the database had been upgraded,
but the instructions had not! I sincerely hope that they would have updated it
by now.
The next thing is to open that file and
edit it. Depending on your preference, you can choose whatever editor you like
to edit the file. I am from “old school”, so I prefer to use “vi” to edit.
Another reason for me to stick to the vi
Editor is that this tool is almost guaranteed to be in all variances of UNIX.
The command to edit the 1st file
is as follows:
vi /var/lib/pgsql/9.4/data/postgresql.conf
|
The following is the screenshot:
Figure 10: Command to Edit "postgresql.conf" File
After you have pressed [Enter], make sure
you can see something like the following:
Figure 11: Initial "postgresql.conf"File
If you do not see something like the above,
you might have typed the wrong name, and created a new file instead. To exit
this, press the 5 key sequences below:
[Esc][Esc][:][q][!]
This will bring you back to the command
prompt. You can press the [UP] & [DOWN] arrow keys to review the earlier commands
and then use your [LEFT] & [RIGHT] arrow keys to move back and forth along
the command line and edit it accordingly.
|
Pressing the [Esc] key twice is generally not
necessary, but it is always a best practice when using vi. The problem with
vi is that some commands depends on the current context, so by pressing [Esc]
twice, you are always back to the “base” command context.
|
vi Editor is very powerful, but this book is
not a primer for that, you can always google for more commands and tricks,
however, I will teach you to use the most basic commands, in its simplest form
because you job is to pass CLSA, not to be an UNIX expert!
|
The next step is to edit the relevant
section of this file.
Press [Esc][Esc], followed by the down
arrow to scroll the file, until you see the “CONNECTIONS AND AUTHENTICATION”
section as shown below.
Figure 12: Connections and Authentication Section of PostgreSQL.conf
vi also has command for you to find a text in
the current file, you can always google for the command!
|
The Circled part is the area that you
should change. Basically, it is just to remove the “#” in front of that line,
which basically uncomment that line and make the statement: listen_addresses = '*' in force.
To delete the “#”, move your mouse to the
given character and press the “x” key ONCE. Which will delete that character.
The next tricky thing is to save this file.
In vi, do the following 6 key sequences:
[Esc][Esc][:][w][q][!]
|
Recall:
To exit without saving:
[Esc][Esc][:][q][!]
To exit with saving:
[Esc][Esc][:][w][q][!]
The difference is just the [w] key in the
sequence.
|
Back at the command prompt, to validate
that you have indeed made that change, you can use the UNIX “cat” command.
To do that, when you are back at the
command prompt, press the [UP] arrow. This will show you the earlier “vi”
command with the file that you just edited.
Using the [LEFT] arrow, move to the “vi”
command and change it to “cat”, but before you press [ENTER], go back to the
end of the command and add in: “| grep listen_addresses”
The command that you need to execute to
check the changes is as follows:
cat /var/lib/pgsql/9.3/data/postgresql.conf
| grep listen_addresses
|
The following is the screenshot of the
output:
Figure 13: Check That postgresql.conf File Is Updated
Take note that the echo from the command
shows that the new “listen_addresses” line does not have the “#” anymore.
Alternatively, you can use the same vi command
to open the file, scroll down and look at the changes to confirm.
|
The next task is to edit the 2nd
file.
Update Host-Based Authentication Default
Settings
The host-based authentication is
represented in the pg_hba.conf file.
Many tips are given when edited the 1st
file, thus I am not going to repeat those again. You should edit the 1st
file before this. Not that it matters, but you should be familiar with the tips
first. Please note that I do not want to treat you like babies, but I still
have to treat you like my students.
The pg_hba.conf is located in the same
location as the earlier postgresql.conf.
Use a text editor (I am using vi in my
example), and open the file, you should see the following:
Figure 14: Sample pg_hba.conf File
Use the [DOWN] arrow to scroll through the
file, until you see something like the following:
Figure 15: Section of the pg_hba.conf to Edit
For each of the column in the diagram
above, you are supposed to enter a value. In this situation, you need to add a
whole new line, as follows:
Host all all 0.0.0.0/0 trust
|
You can use [TAB] key to separate and align
them nicely (although not necessary). The modified section will look like the
following:
Figure 16: Sample Updated pg_hba.conf
Save the edited file, confirm the changes
are in effect and exit the editor.
If you need further help on editing the file,
confirming the changes or exiting the vi editor, please refer to instruction
on editing the 1st file.
|
I like to indicate where I had edited the
file, which is why you are seeing the line “# Added by XXX” above.
|
Once you have edited both files, restart
the VM.
To restart the VM, you could just power it
off by closing its window, or if you prefer a more proper and managed way, to
ensure there is no corrupted file, you can enter the following command at the
command prompt and press [ENTER]:
sudo shutdown -h now
|
The screen will show the shutdown progress as
follows:
Figure 17: VM Shutdown Screen
In the next chapter, you will setup a client to connect to it.
No comments:
Post a Comment