Categories
plugin

mongoDB, OCI free tier, Oracle Enterprise Manager 13c

This guide details how mongoDB can be installed on OCI free tier and monitored in the normal manner using AIDEV’s mongoDB monitoring plugin for EM13c.

This approach allows sites to monitor their on-premise and off-premise mongoDB estates alongside their Oracle estate.

It assumes the user has OEM13.2 and above installed with the AIDEV mongoDB monitoring plugin installed.


The AIDEV mongoDB monitoring plugin fully integrates into the Oracle Enterprise Manager 13c frameworks for monitoring, alerting, configuration management, job scheduling and reporting.

graphs, charts and metric data for mongoDB

This example has purposely been kept simple:

  • the OCI compute instance is hosted in a public subnet and requires minimal network security group configuration to get things working.
  • a single mongoDB instance is configured for the purpose of the demo – no replication/sharding is used.
  • no SSL/TLS comms are configured for mongoDB

The example steps in this post can be used as a basis to get things up and running.

For Production environments, the above points can be expanded upon very easily to allow adoption of private subnets, mongoDB HA configuration and SSL/TLS.

Ok, so step 1 is to create the mongoDB compute instance in OCI. MongoDB will be installed on this.

I chose to go with Ubuntu 20.04 Minimal as mongoDB can easily be pulled down through apt-get for simple installation.

As ever, when creating the instance, download the private and public SSH keys from the OCI console and keep these safe. The private key will be required for later use when establishing ssh communication to the host.

create the instance

Once created, we can see the instance details under the Compute->Instances menu in the OCI console:

compute instance details

Next, we need to copy the private SSH key to the OEM 13c agent machine.

It helps to hold this in dedicated directory, protected at the operating system and set with 600 permissions.

[oracle@emcc demo1]$ ls -al
total 4
drwxr-xr-x. 2 oracle oinstall   22 Aug 17 09:51 .
drwxr-xr-x. 3 oracle oinstall   19 Aug 17 07:47 ..
-rw-------. 1 oracle oinstall 1704 Aug 17 09:51 priv.key


Once copied over, we can test login to the host from the OEM agent host:

[oracle@emcc demo1]$ ssh -i priv.key ubuntu@140.238.65.109
The authenticity of host '140.238.65.109 (140.238.65.109)' can't be established.
ECDSA key fingerprint is SHA256:MhBXAr9p8oqBymgUHZjofh9t443lxgV+VskIEJSu0G8.
ECDSA key fingerprint is MD5:f4:54:ce:3c:b0:77:8e:da:68:18:95:30:63:bf:be:8b.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '140.238.65.109' (ECDSA) to the list of known hosts.
Welcome to Ubuntu 20.04 LTS (GNU/Linux 5.4.0-1015-oracle x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

This system has been minimized by removing packages and content that are
not required on a system that users do not log into.

To restore this content, you can run the 'unminimize' command.

0 updates can be installed immediately.
0 of these updates are security updates.


The list of available updates is more than a week old.
To check for new updates run: sudo apt update

The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

ubuntu@mongodb-demo1:~$

Ok, so comms are working and we are now logged on to the OCI mongoDB host.

Jump to root and follow the steps listed at https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/ to install mongoDB, namely:

ubuntu@mongodb-demo1:~$ sudo su -

First, import the MongoDB public GPG Key

root@mongodb-demo1:~# wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -
OK

Then create a list file for MongoDB:

root@mongodb-demo1:~# echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list
deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse

We then reload local package database:

root@mongodb-demo1:~# sudo apt-get update
Get:1 http://security.ubuntu.com/ubuntu focal-security InRelease [107 kB]
Ign:2 https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 InRelease                                                                
Get:3 https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 Release [5389 B]                            
Get:4 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages [159 kB]
Get:5 http://uk-london-1-ad-3.clouds.archive.ubuntu.com/ubuntu focal InRelease [265 kB]
Get:6 http://security.ubuntu.com/ubuntu focal-security/main Translation-en [57.4 kB]
Get:7 http://security.ubuntu.com/ubuntu focal-security/restricted amd64 Packages [29.2 kB]
Get:8 http://security.ubuntu.com/ubuntu focal-security/restricted Translation-en [7732 B]
Get:9 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages [53.1 kB]
Get:10 http://security.ubuntu.com/ubuntu focal-security/universe Translation-en [27.1 kB]
Get:11 http://security.ubuntu.com/ubuntu focal-security/multiverse amd64 Packages [1172 B]
Get:12 http://security.ubuntu.com/ubuntu focal-security/multiverse Translation-en [540 B]
Get:13 https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 Release.gpg [801 B]
Get:14 https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4/multiverse amd64 Packages [3596 B]
Get:15 https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4/multiverse arm64 Packages [3017 B]
Get:16 http://uk-london-1-ad-3.clouds.archive.ubuntu.com/ubuntu focal-updates InRelease [111 kB]
Get:17 http://uk-london-1-ad-3.clouds.archive.ubuntu.com/ubuntu focal-backports InRelease [98.3 kB]
Get:18 http://uk-london-1-ad-3.clouds.archive.ubuntu.com/ubuntu focal/main amd64 Packages [970 kB]
Get:19 http://uk-london-1-ad-3.clouds.archive.ubuntu.com/ubuntu focal/main Translation-en [506 kB]
Get:20 http://uk-london-1-ad-3.clouds.archive.ubuntu.com/ubuntu focal/restricted amd64 Packages [22.0 kB]
Get:21 http://uk-london-1-ad-3.clouds.archive.ubuntu.com/ubuntu focal/restricted Translation-en [6212 B]
Get:22 http://uk-london-1-ad-3.clouds.archive.ubuntu.com/ubuntu focal/universe amd64 Packages [8628 kB]
Get:23 http://uk-london-1-ad-3.clouds.archive.ubuntu.com/ubuntu focal/universe Translation-en [5124 kB]
Get:24 http://uk-london-1-ad-3.clouds.archive.ubuntu.com/ubuntu focal/multiverse amd64 Packages [144 kB]
Get:25 http://uk-london-1-ad-3.clouds.archive.ubuntu.com/ubuntu focal/multiverse Translation-en [104 kB]
Get:26 http://uk-london-1-ad-3.clouds.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [324 kB]
Get:27 http://uk-london-1-ad-3.clouds.archive.ubuntu.com/ubuntu focal-updates/main Translation-en [122 kB]
Get:28 http://uk-london-1-ad-3.clouds.archive.ubuntu.com/ubuntu focal-updates/restricted amd64 Packages [29.3 kB]
Get:29 http://uk-london-1-ad-3.clouds.archive.ubuntu.com/ubuntu focal-updates/restricted Translation-en [7768 B]
Get:30 http://uk-london-1-ad-3.clouds.archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [155 kB]
Get:31 http://uk-london-1-ad-3.clouds.archive.ubuntu.com/ubuntu focal-updates/universe Translation-en [77.1 kB]
Get:32 http://uk-london-1-ad-3.clouds.archive.ubuntu.com/ubuntu focal-updates/multiverse amd64 Packages [11.6 kB]
Get:33 http://uk-london-1-ad-3.clouds.archive.ubuntu.com/ubuntu focal-updates/multiverse Translation-en [3892 B]
Get:34 http://uk-london-1-ad-3.clouds.archive.ubuntu.com/ubuntu focal-backports/universe amd64 Packages [3092 B]
Get:35 http://uk-london-1-ad-3.clouds.archive.ubuntu.com/ubuntu focal-backports/universe Translation-en [1448 B]
Fetched 17.2 MB in 9s (1981 kB/s)                                                                                                                                                             
Reading package lists... Done

Next, install the latest stable mongoDB version:

root@mongodb-demo1:~# sudo apt-get install -y mongodb-org
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  mongodb-database-tools mongodb-org-database-tools-extra mongodb-org-mongos mongodb-org-server mongodb-org-shell mongodb-org-tools
The following NEW packages will be installed:
  mongodb-database-tools mongodb-org mongodb-org-database-tools-extra mongodb-org-mongos mongodb-org-server mongodb-org-shell mongodb-org-tools
0 upgraded, 7 newly installed, 0 to remove and 70 not upgraded.
Need to get 104 MB of archives.
After this operation, 200 MB of additional disk space will be used.
Get:1 https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4/multiverse amd64 mongodb-database-tools amd64 100.1.1 [54.4 MB]
Get:2 https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4/multiverse amd64 mongodb-org-shell amd64 4.4.0 [13.2 MB]                                                                      
Get:3 https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4/multiverse amd64 mongodb-org-server amd64 4.4.0 [20.3 MB]                                                                     
Get:4 https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4/multiverse amd64 mongodb-org-mongos amd64 4.4.0 [15.7 MB]                                                                     
Get:5 https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4/multiverse amd64 mongodb-org-database-tools-extra amd64 4.4.0 [5612 B]                                                        
Get:6 https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4/multiverse amd64 mongodb-org-tools amd64 4.4.0 [2888 B]                                                                       
Get:7 https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4/multiverse amd64 mongodb-org amd64 4.4.0 [3516 B]                                                                             
Fetched 104 MB in 18s (5682 kB/s)                                                                                                                                                             
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package mongodb-database-tools.
(Reading database ... 53497 files and directories currently installed.)
Preparing to unpack .../0-mongodb-database-tools_100.1.1_amd64.deb ...
Unpacking mongodb-database-tools (100.1.1) ...
Selecting previously unselected package mongodb-org-shell.
Preparing to unpack .../1-mongodb-org-shell_4.4.0_amd64.deb ...
Unpacking mongodb-org-shell (4.4.0) ...
Selecting previously unselected package mongodb-org-server.
Preparing to unpack .../2-mongodb-org-server_4.4.0_amd64.deb ...
Unpacking mongodb-org-server (4.4.0) ...
Selecting previously unselected package mongodb-org-mongos.
Preparing to unpack .../3-mongodb-org-mongos_4.4.0_amd64.deb ...
Unpacking mongodb-org-mongos (4.4.0) ...
Selecting previously unselected package mongodb-org-database-tools-extra.
Preparing to unpack .../4-mongodb-org-database-tools-extra_4.4.0_amd64.deb ...
Unpacking mongodb-org-database-tools-extra (4.4.0) ...
Selecting previously unselected package mongodb-org-tools.
Preparing to unpack .../5-mongodb-org-tools_4.4.0_amd64.deb ...
Unpacking mongodb-org-tools (4.4.0) ...
Selecting previously unselected package mongodb-org.
Preparing to unpack .../6-mongodb-org_4.4.0_amd64.deb ...
Unpacking mongodb-org (4.4.0) ...
Setting up mongodb-org-server (4.4.0) ...
Adding system user `mongodb' (UID 110) ...
Adding new user `mongodb' (UID 110) with group `nogroup' ...
Not creating home directory `/home/mongodb'.
Adding group `mongodb' (GID 112) ...
Done.
Adding user `mongodb' to group `mongodb' ...
Adding user mongodb to group mongodb
Done.
Setting up mongodb-org-shell (4.4.0) ...
Setting up mongodb-database-tools (100.1.1) ...
Setting up mongodb-org-mongos (4.4.0) ...
Setting up mongodb-org-database-tools-extra (4.4.0) ...
Setting up mongodb-org-tools (4.4.0) ...
Setting up mongodb-org (4.4.0) ...
root@mongodb-demo1:~#

Finally, prevent apt-get upgrades of mongoDB:

root@mongodb-demo1:~# echo "mongodb-org hold" | sudo dpkg --set-selections
root@mongodb-demo1:~# echo "mongodb-org-server hold" | sudo dpkg --set-selections
root@mongodb-demo1:~# echo "mongodb-org-shell hold" | sudo dpkg --set-selections
root@mongodb-demo1:~# echo "mongodb-org-mongos hold" | sudo dpkg --set-selections
root@mongodb-demo1:~# echo "mongodb-org-tools hold" | sudo dpkg --set-selections

As we are running a minimal image of Ubuntu, we need to manually install vim (required for vi functionality):

root@mongodb-demo1:/bin# apt-get install vim
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libasound2 libasound2-data libcanberra0 libltdl7 libogg0 libpython3.8 libpython3.8-minimal libpython3.8-stdlib libtdb1 libvorbis0a libvorbisfile3 python3.8 python3.8-minimal vim-common
  vim-runtime
Suggested packages:
  libasound2-plugins alsa-utils libcanberra-gtk0 libcanberra-pulse python3.8-venv python3.8-doc binutils binfmt-support ctags vim-doc vim-scripts
The following NEW packages will be installed:
  libasound2 libasound2-data libcanberra0 libltdl7 libogg0 libpython3.8 libtdb1 libvorbis0a libvorbisfile3 vim vim-common vim-runtime
The following packages will be upgraded:
  libpython3.8-minimal libpython3.8-stdlib python3.8 python3.8-minimal
4 upgraded, 12 newly installed, 0 to remove and 66 not upgraded.
Need to get 14.0 MB of archives.
After this operation, 42.9 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://uk-london-1-ad-3.clouds.archive.ubuntu.com/ubuntu focal-updates/main amd64 python3.8 amd64 3.8.2-1ubuntu1.2 [364 kB]
Get:2 http://uk-london-1-ad-3.clouds.archive.ubuntu.com/ubuntu focal-updates/main amd64 libpython3.8-stdlib amd64 3.8.2-1ubuntu1.2 [1665 kB]
Get:3 http://uk-london-1-ad-3.clouds.archive.ubuntu.com/ubuntu focal-updates/main amd64 python3.8-minimal amd64 3.8.2-1ubuntu1.2 [1896 kB]
Get:4 http://uk-london-1-ad-3.clouds.archive.ubuntu.com/ubuntu focal-updates/main amd64 libpython3.8-minimal amd64 3.8.2-1ubuntu1.2 [705 kB]
Get:5 http://uk-london-1-ad-3.clouds.archive.ubuntu.com/ubuntu focal/main amd64 vim-common all 2:8.1.2269-1ubuntu5 [85.1 kB]                                                                  
Get:6 http://uk-london-1-ad-3.clouds.archive.ubuntu.com/ubuntu focal-updates/main amd64 libasound2-data all 1.2.2-2.1ubuntu1 [19.1 kB]                                                        
Get:7 http://uk-london-1-ad-3.clouds.archive.ubuntu.com/ubuntu focal-updates/main amd64 libasound2 amd64 1.2.2-2.1ubuntu1 [328 kB]                                                            
Get:8 http://uk-london-1-ad-3.clouds.archive.ubuntu.com/ubuntu focal/main amd64 libltdl7 amd64 2.4.6-14 [38.5 kB]                                                                             
Get:9 http://uk-london-1-ad-3.clouds.archive.ubuntu.com/ubuntu focal/main amd64 libtdb1 amd64 1.4.2-3build1 [44.1 kB]                                                                         
Get:10 http://uk-london-1-ad-3.clouds.archive.ubuntu.com/ubuntu focal/main amd64 libogg0 amd64 1.3.4-0ubuntu1 [24.0 kB]                                                                       
Get:11 http://uk-london-1-ad-3.clouds.archive.ubuntu.com/ubuntu focal/main amd64 libvorbis0a amd64 1.3.6-2ubuntu1 [87.0 kB]                                                                   
Get:12 http://uk-london-1-ad-3.clouds.archive.ubuntu.com/ubuntu focal/main amd64 libvorbisfile3 amd64 1.3.6-2ubuntu1 [16.1 kB]                                                                
Get:13 http://uk-london-1-ad-3.clouds.archive.ubuntu.com/ubuntu focal/main amd64 libcanberra0 amd64 0.30-7ubuntu1 [38.1 kB]                                                                   
Get:14 http://uk-london-1-ad-3.clouds.archive.ubuntu.com/ubuntu focal-updates/main amd64 libpython3.8 amd64 3.8.2-1ubuntu1.2 [1620 kB]                                                        
Get:15 http://uk-london-1-ad-3.clouds.archive.ubuntu.com/ubuntu focal/main amd64 vim-runtime all 2:8.1.2269-1ubuntu5 [5873 kB]                                                                
Get:16 http://uk-london-1-ad-3.clouds.archive.ubuntu.com/ubuntu focal/main amd64 vim amd64 2:8.1.2269-1ubuntu5 [1238 kB]                                                                      
Fetched 14.0 MB in 19s (728 kB/s)                                                                                                                                                             
debconf: delaying package configuration, since apt-utils is not installed
(Reading database ... 53544 files and directories currently installed.)
Preparing to unpack .../00-python3.8_3.8.2-1ubuntu1.2_amd64.deb ...
Unpacking python3.8 (3.8.2-1ubuntu1.2) over (3.8.2-1ubuntu1.1) ...
Preparing to unpack .../01-libpython3.8-stdlib_3.8.2-1ubuntu1.2_amd64.deb ...
Unpacking libpython3.8-stdlib:amd64 (3.8.2-1ubuntu1.2) over (3.8.2-1ubuntu1.1) ...
Preparing to unpack .../02-python3.8-minimal_3.8.2-1ubuntu1.2_amd64.deb ...
Unpacking python3.8-minimal (3.8.2-1ubuntu1.2) over (3.8.2-1ubuntu1.1) ...
Preparing to unpack .../03-libpython3.8-minimal_3.8.2-1ubuntu1.2_amd64.deb ...
Unpacking libpython3.8-minimal:amd64 (3.8.2-1ubuntu1.2) over (3.8.2-1ubuntu1.1) ...
Selecting previously unselected package vim-common.
Preparing to unpack .../04-vim-common_2%3a8.1.2269-1ubuntu5_all.deb ...
Unpacking vim-common (2:8.1.2269-1ubuntu5) ...
Selecting previously unselected package libasound2-data.
Preparing to unpack .../05-libasound2-data_1.2.2-2.1ubuntu1_all.deb ...
Unpacking libasound2-data (1.2.2-2.1ubuntu1) ...
Selecting previously unselected package libasound2:amd64.
Preparing to unpack .../06-libasound2_1.2.2-2.1ubuntu1_amd64.deb ...
Unpacking libasound2:amd64 (1.2.2-2.1ubuntu1) ...
Selecting previously unselected package libltdl7:amd64.
Preparing to unpack .../07-libltdl7_2.4.6-14_amd64.deb ...
Unpacking libltdl7:amd64 (2.4.6-14) ...
Selecting previously unselected package libtdb1:amd64.
Preparing to unpack .../08-libtdb1_1.4.2-3build1_amd64.deb ...
Unpacking libtdb1:amd64 (1.4.2-3build1) ...
Selecting previously unselected package libogg0:amd64.
Preparing to unpack .../09-libogg0_1.3.4-0ubuntu1_amd64.deb ...
Unpacking libogg0:amd64 (1.3.4-0ubuntu1) ...
Selecting previously unselected package libvorbis0a:amd64.
Preparing to unpack .../10-libvorbis0a_1.3.6-2ubuntu1_amd64.deb ...
Unpacking libvorbis0a:amd64 (1.3.6-2ubuntu1) ...
Selecting previously unselected package libvorbisfile3:amd64.
Preparing to unpack .../11-libvorbisfile3_1.3.6-2ubuntu1_amd64.deb ...
Unpacking libvorbisfile3:amd64 (1.3.6-2ubuntu1) ...
Selecting previously unselected package libcanberra0:amd64.
Preparing to unpack .../12-libcanberra0_0.30-7ubuntu1_amd64.deb ...
Unpacking libcanberra0:amd64 (0.30-7ubuntu1) ...
Selecting previously unselected package libpython3.8:amd64.
Preparing to unpack .../13-libpython3.8_3.8.2-1ubuntu1.2_amd64.deb ...
Unpacking libpython3.8:amd64 (3.8.2-1ubuntu1.2) ...
Selecting previously unselected package vim-runtime.
Preparing to unpack .../14-vim-runtime_2%3a8.1.2269-1ubuntu5_all.deb ...
Adding 'diversion of /usr/share/vim/vim81/doc/help.txt to /usr/share/vim/vim81/doc/help.txt.vim-tiny by vim-runtime'
Adding 'diversion of /usr/share/vim/vim81/doc/tags to /usr/share/vim/vim81/doc/tags.vim-tiny by vim-runtime'
Unpacking vim-runtime (2:8.1.2269-1ubuntu5) ...
Selecting previously unselected package vim.
Preparing to unpack .../15-vim_2%3a8.1.2269-1ubuntu5_amd64.deb ...
Unpacking vim (2:8.1.2269-1ubuntu5) ...
Setting up libpython3.8-minimal:amd64 (3.8.2-1ubuntu1.2) ...
Setting up libogg0:amd64 (1.3.4-0ubuntu1) ...
Setting up libtdb1:amd64 (1.4.2-3build1) ...
Setting up libasound2-data (1.2.2-2.1ubuntu1) ...
Setting up vim-common (2:8.1.2269-1ubuntu5) ...
Setting up libvorbis0a:amd64 (1.3.6-2ubuntu1) ...
Setting up libltdl7:amd64 (2.4.6-14) ...
Setting up python3.8-minimal (3.8.2-1ubuntu1.2) ...
Setting up libasound2:amd64 (1.2.2-2.1ubuntu1) ...
Setting up vim-runtime (2:8.1.2269-1ubuntu5) ...
Setting up libpython3.8-stdlib:amd64 (3.8.2-1ubuntu1.2) ...
Setting up python3.8 (3.8.2-1ubuntu1.2) ...
Setting up libvorbisfile3:amd64 (1.3.6-2ubuntu1) ...
Setting up libpython3.8:amd64 (3.8.2-1ubuntu1.2) ...
Setting up libcanberra0:amd64 (0.30-7ubuntu1) ...
Setting up vim (2:8.1.2269-1ubuntu5) ...
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vim (vim) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vimdiff (vimdiff) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/rvim (rvim) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/rview (rview) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vi (vi) in auto mode
update-alternatives: warning: skip creation of /usr/share/man/da/man1/vi.1.gz because associated file /usr/share/man/da/man1/vim.1.gz (of link group vi) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/de/man1/vi.1.gz because associated file /usr/share/man/de/man1/vim.1.gz (of link group vi) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/fr/man1/vi.1.gz because associated file /usr/share/man/fr/man1/vim.1.gz (of link group vi) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/it/man1/vi.1.gz because associated file /usr/share/man/it/man1/vim.1.gz (of link group vi) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/ja/man1/vi.1.gz because associated file /usr/share/man/ja/man1/vim.1.gz (of link group vi) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/pl/man1/vi.1.gz because associated file /usr/share/man/pl/man1/vim.1.gz (of link group vi) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/ru/man1/vi.1.gz because associated file /usr/share/man/ru/man1/vim.1.gz (of link group vi) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/man1/vi.1.gz because associated file /usr/share/man/man1/vim.1.gz (of link group vi) doesn't exist
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/view (view) in auto mode
update-alternatives: warning: skip creation of /usr/share/man/da/man1/view.1.gz because associated file /usr/share/man/da/man1/vim.1.gz (of link group view) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/de/man1/view.1.gz because associated file /usr/share/man/de/man1/vim.1.gz (of link group view) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/fr/man1/view.1.gz because associated file /usr/share/man/fr/man1/vim.1.gz (of link group view) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/it/man1/view.1.gz because associated file /usr/share/man/it/man1/vim.1.gz (of link group view) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/ja/man1/view.1.gz because associated file /usr/share/man/ja/man1/vim.1.gz (of link group view) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/pl/man1/view.1.gz because associated file /usr/share/man/pl/man1/vim.1.gz (of link group view) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/ru/man1/view.1.gz because associated file /usr/share/man/ru/man1/vim.1.gz (of link group view) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/man1/view.1.gz because associated file /usr/share/man/man1/vim.1.gz (of link group view) doesn't exist
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/ex (ex) in auto mode
update-alternatives: warning: skip creation of /usr/share/man/da/man1/ex.1.gz because associated file /usr/share/man/da/man1/vim.1.gz (of link group ex) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/de/man1/ex.1.gz because associated file /usr/share/man/de/man1/vim.1.gz (of link group ex) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/fr/man1/ex.1.gz because associated file /usr/share/man/fr/man1/vim.1.gz (of link group ex) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/it/man1/ex.1.gz because associated file /usr/share/man/it/man1/vim.1.gz (of link group ex) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/ja/man1/ex.1.gz because associated file /usr/share/man/ja/man1/vim.1.gz (of link group ex) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/pl/man1/ex.1.gz because associated file /usr/share/man/pl/man1/vim.1.gz (of link group ex) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/ru/man1/ex.1.gz because associated file /usr/share/man/ru/man1/vim.1.gz (of link group ex) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/man1/ex.1.gz because associated file /usr/share/man/man1/vim.1.gz (of link group ex) doesn't exist
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/editor (editor) in auto mode
update-alternatives: warning: skip creation of /usr/share/man/da/man1/editor.1.gz because associated file /usr/share/man/da/man1/vim.1.gz (of link group editor) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/de/man1/editor.1.gz because associated file /usr/share/man/de/man1/vim.1.gz (of link group editor) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/fr/man1/editor.1.gz because associated file /usr/share/man/fr/man1/vim.1.gz (of link group editor) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/it/man1/editor.1.gz because associated file /usr/share/man/it/man1/vim.1.gz (of link group editor) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/ja/man1/editor.1.gz because associated file /usr/share/man/ja/man1/vim.1.gz (of link group editor) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/pl/man1/editor.1.gz because associated file /usr/share/man/pl/man1/vim.1.gz (of link group editor) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/ru/man1/editor.1.gz because associated file /usr/share/man/ru/man1/vim.1.gz (of link group editor) doesn't exist
update-alternatives: warning: skip creation of /usr/share/man/man1/editor.1.gz because associated file /usr/share/man/man1/vim.1.gz (of link group editor) doesn't exist
Processing triggers for libc-bin (2.31-0ubuntu9) ...
Processing triggers for mime-support (3.64ubuntu1) ...

Ok, we now have mongoDB installed.

First of all, let’s start it:

root@mongodb-demo1:~# systemctl start mongod

And check it’s status:

root@mongodb-demo1:~# systemctl status mongod
● mongod.service - MongoDB Database Server
     Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset: enabled)
     Active: active (running) since Mon 2020-08-17 14:02:21 UTC; 7s ago
       Docs: https://docs.mongodb.org/manual
   Main PID: 2554 (mongod)
     Memory: 68.1M
     CGroup: /system.slice/mongod.service
             └─2554 /usr/bin/mongod --config /etc/mongod.conf

Aug 17 14:02:21 mongodb-demo1 systemd[1]: Started MongoDB Database Server.

We can now connect to mongoDB and create the monitoring account and role required by the AIDEV mongoDB plugin:

root@mongodb-demo1:~# mongo
MongoDB shell version v4.4.0
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("eb85874b-3b2f-42d0-bc3d-81022c80e8d6") }
MongoDB server version: 4.4.0
---
The server generated these startup warnings when booting: 
        2020-08-17T14:02:21.710+00:00: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine. See http://dochub.mongodb.org/core/prodnotes-filesystem
        2020-08-17T14:02:23.946+00:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
---
>

Switch to admin:

> use admin
switched to db admin

Create the required role:

> db.createRole({role: "emRole",privileges: [{ resource: { db: "admin", collection: "system.users" }, actions: [ "find" ] }, { resource: { db: "admin", collection: "system.roles" }, actions: [ "find" ] },{ resource: { db: "local", collection: "oplog.rs" }, actions: [ "find" ] }],roles: [ { role: "clusterMonitor", db: "admin" },{ role: "read", db: "local" }]})
{
	"role" : "emRole",
	"privileges" : [
		{
			"resource" : {
				"db" : "admin",
				"collection" : "system.users"
			},
			"actions" : [
				"find"
			]
		},
		{
			"resource" : {
				"db" : "admin",
				"collection" : "system.roles"
			},
			"actions" : [
				"find"
			]
		},
		{
			"resource" : {
				"db" : "local",
				"collection" : "oplog.rs"
			},
			"actions" : [
				"find"
			]
		}
	],
	"roles" : [
		{
			"role" : "clusterMonitor",
			"db" : "admin"
		},
		{
			"role" : "read",
			"db" : "local"
		}
	]
}
> 

Create the required OEM user:

> db.createUser({user: "em_monitor",pwd: "password",roles: [ { role: "emRole", db: "admin" } ]})
Successfully added user: {
	"user" : "em_monitor",
	"roles" : [
		{
			"role" : "emRole",
			"db" : "admin"
		}
	]
}


> exit
bye

We now need to reconfigure mongoDB to allow remote connections, enable authorization and force use of a non-default port:

root@mgo1:~# vi /etc/mongod.conf

Changes made:

net:
  port: 27099
  bindIp: 0.0.0.0

security:
  authorization: enabled

We can now restart mongoDB:

root@mongodb-demo1:/bin# systemctl restart mongod


root@mongodb-demo1:/bin# systemctl status mongod
● mongod.service - MongoDB Database Server
     Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor preset: enabled)
     Active: active (running) since Mon 2020-08-17 14:26:32 UTC; 7s ago
       Docs: https://docs.mongodb.org/manual
   Main PID: 3188 (mongod)
     Memory: 160.2M
     CGroup: /system.slice/mongod.service
             └─3188 /usr/bin/mongod --config /etc/mongod.conf

Aug 17 14:26:32 mongodb-demo1 systemd[1]: mongod.service: Succeeded.
Aug 17 14:26:32 mongodb-demo1 systemd[1]: Stopped MongoDB Database Server.
Aug 17 14:26:32 mongodb-demo1 systemd[1]: Started MongoDB Database Server.

The first thing to test is that the mongoDB OCI VM can connect to mongoDB on the OCI public IP address.

We can obtain the public IP address for the compute instance from it’s home page in the OCI console:

public IP

On the mongoDB host we can test connectivity using the mongo client installed above:

root@mongodb-demo1:/bin# mongo --host 140.238.65.109 --port 27099
MongoDB shell version v4.4.0
connecting to: mongodb://140.238.65.109:27099/?compressors=disabled&gssapiServiceName=mongodb
Error: couldn't connect to server 140.238.65.109:27099, connection attempt failed: SocketException: Error connecting to 140.238.65.109:27099 :: caused by :: No route to host :
connect@src/mongo/shell/mongo.js:362:17
@(connect):2:6
exception: connect failed
exiting with code 1

This error is expected due to a known issue with Ubuntu on OCI. The fix is detailed in MOS Doc ID 2394271.1:

Run the fix:

root@mgo1:/etc# iptables -I INPUT 5 -p tcp --dport 27099 -j ACCEPT

root@mgo1:/etc# iptables-save | sudo tee /etc/iptables/rules.v4

Test again:

root@mongodb-demo1:/home/ubuntu# mongo --host 140.238.65.109 --port 27099
MongoDB shell version v4.4.0
connecting to: mongodb://140.238.65.109:27099/?compressors=disabled&gssapiServiceName=mongodb
Error: couldn't connect to server 140.238.65.109:27099, connection attempt failed: SocketException: Error connecting to 140.238.65.109:27099 :: caused by :: Connection timed out :
connect@src/mongo/shell/mongo.js:362:17
@(connect):2:6
exception: connect failed
exiting with code 1

This different error is also expected as the OCI VCN security list is not allowing the connection attempt.

To resolve this, we need to set up an Ingress rule to port 27099 for the public IP of the OCI VM:

ingress rule in OCI

We can now test again from the mongoDB host:

root@mongodb-demo1:/home/ubuntu# mongo --host 140.238.65.109 --port 27099
MongoDB shell version v4.4.0
connecting to: mongodb://140.238.65.109:27099/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("c23be5a6-f510-4fb3-8c4d-512b7db13693") }
MongoDB server version: 4.4.0
>

Ok, success – we are now connected.

We can now test authentication as the new em_monitor account by using this session:

> use admin
switched to db admin	

> db.auth('em_monitor','password')
1

> show dbs
admin   0.000GB
config  0.000GB
local   0.000GB
>

At this stage we have tested remote connectivity to mongoDB from the public IP of the mongoDB host in OCI.

We need to set up similar rule in the network security group for the OEM agent host – this will allow the OEM agent to connect to mongoDB.

Next, we need to test the agent host to OCI mongo host connectivity:

First of all, log on to OEM agent host as the agent OS owner.

Change to the mongoDB plugin scripts directory within the agent side plugin.

For example,

cd /u01/app/oracle/agent/agent_13.4.0.0.0/plugins/aidev.mongo.xdbs.agent.plugin_13.2.0.2.0/scripts

The AIDEV mongoDB plugin comes bundled with a connection tester utility, held in this location.

This utility can be used to test connectivity to mongoDB from the agent host.

To configure the utility, edit the script connection_tester.sh and amend the variables accordingly:

[oracle@emcc scripts]$ vi connection_tester.sh


#!/bin/bash
# script to test connectivity for a mongoDB target
# one input param - the metric name
#
# Copyright aidev apr 15
#
# V1.1
# V2.0 updated for new mongodb driver versions (Jan 2020)

# 1. place this script in the mongoDB scripts directory within the agent home. cd to this location

# 2. edit the following vars to suit your environment

export MGO_SSL=FALSE
export MGO_SSLSTORE=NONE
export MGO_JARLOC=/home/oracle/mongojars
export JAVA_HOME=/u01/app/oracle/agent/agent_13.4.0.0.0/oracle_common/jdk/jre
export dir=`pwd`
export CLASSPATH=`pwd`:$CLASSPATH
export MGO_PORT=27099
export MGO_HOST=140.238.65.109
export MGO_PASSWORD=password
export MGO_USERNAME=em_monitor


# 3. run the script as follows:
# 
# test the response metric
# sh ./connection_tester.sh  response

$JAVA_HOME/bin/java -cp "$dir:$MGO_JARLOC/mongodb-driver-3.11.2.jar:$MGO_JARLOC/mongodb-driver-core-3.11.2.jar:$MGO_JARLOC/json-20190722.jar:$MGO_JARLOC/bson-3.11.2.jar" connect_test response

Next, run the script to test connectivity from the OEM agent host to mongoDB on OCI.

Ensure the returned output indicates em_result=1, as detailed below:

[oracle@emcc scripts]$ sh ./connection_tester.sh 
Aug 17, 2020 10:46:40 AM com.mongodb.diagnostics.logging.JULLogger log
INFO: Cluster created with settings {hosts=[140.238.65.109:27099], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
Aug 17, 2020 10:46:40 AM com.mongodb.diagnostics.logging.JULLogger log
INFO: Cluster description not yet available. Waiting for 30000 ms before timing out
Aug 17, 2020 10:46:40 AM com.mongodb.diagnostics.logging.JULLogger log
INFO: Opened connection [connectionId{localValue:1, serverValue:5}] to 140.238.65.109:27099
Aug 17, 2020 10:46:40 AM com.mongodb.diagnostics.logging.JULLogger log
INFO: Monitor thread successfully connected to server with description ServerDescription{address=140.238.65.109:27099, type=STANDALONE, state=CONNECTED, ok=true, version=ServerVersion{versionList=[4, 4, 0]}, minWireVersion=0, maxWireVersion=9, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=30, roundTripTimeNanos=50795429}
Aug 17, 2020 10:46:40 AM com.mongodb.diagnostics.logging.JULLogger log
INFO: Opened connection [connectionId{localValue:2, serverValue:6}] to 140.238.65.109:27099
em_result=1
Aug 17, 2020 10:46:40 AM com.mongodb.diagnostics.logging.JULLogger log
INFO: Closed connection [connectionId{localValue:2, serverValue:6}] to 140.238.65.109:27099 because the pool has been closed.

Ok, as we have now proven connectivity works between on-premise OEM and mongoDB on OCI, we can now add in the mongoDB target into OEM.

Screenshots have been included in this example however, for a more comprehensive guide to this process, please follow the AIDEV documentation.

Add in the target:

The target should almost immediately show as being up in OEM:

After a few minutes, the mongoDB target home screen will show various charts for the target. This indicates that metric collection is functioning normally:

We can also verify through All Metrics in OEM that metric collection is working:


Subscribe to receive notification of updates to our blog posts…


AIDEV have the following plugins available and listed on the Oracle Extensibility Exchange:

  • mongoDB
  • SSL certificate
  • REDIS data store
  • HBASE
  • NGiNX

For more information on our OEM plugins or how we can create plugins for your applications, reach out to us.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s