Introduction
18 months ago, I wrote an article about creating a virtual machine for MarkLogic, using Virtual Box and CentOS 6. The article is still of some interest, and the background information it contains is still relevant, but I thought it was time to write an updated version of it, based on CentOS 7. Especially now that CentOS is a platform fully supported by MarkLogic.
The ingredients
Before baking the virtual box, let's gather all the ingredients:
- Virtual Box: go to http://virtualbox.org, follow the downloads link and download the corresponding package or installer for your platform.
-
CentOS: got to the CentOS downloads page at http://centos.org/download/, and click on the
Minimal ISO
button. That page lists different ways of downloading the latest CentOS 7 Minimal ISO image. As of today, the latest minimal image file isCentOS-7-x86_64-Minimal-1511.iso
, corresponding to the minimal disk image for CentOS 7, revision 1511, for the Intel 64 bits processors. - MarkLogic: download the RPM package for MarkLogic, for Red Hat 7, from: http://developer.marklogic.com/products.
The box
First, you need to install Virtual Box. Just follow the instructions for your platform.
Important: You also need to make sure you have a host-only network adapter. This
has to be done only once, and is done at the Virtual Box preferences level (as opposed
to the
preferences for one specific virtual machine). In the global Virtual Box preferences,
in the
"Network
" tab, ensure there is one "Host-only network
". If not, create one,
It should automatically get the name "vboxnet0
". If not, then adapt the name used in
the rest of this article.
Once in Virtual Box, click on the button "New
". Give a name to the box, e.g.
"marklogic-8
", and choose the type "Linux
", and version "Red Hat (64
bit)
". In the next screen, chose the memory to allocate to the virtual box. The more the
better, but on my laptop, I found that 2 GB was enough for simple tests. You can put
more if
you can afford it.
In the next screen, keep the default setting, "Create a virtual hard drive now
",
and continue. Then keep the default again, "VDI (VirtualBox Disk Image)
", and again
keep "Dynamically allocated
". In the next screen, you have to set the disk size. It
depends of course on the space available on your physical machine, and on what you
plan to do
with your MarkLogic instance. If you do not plan to make any data intensive tests,
16 or 32 GB
should be enough. Fortunately, the space is dynamically allocated, so you will not
waste any
space you do not actually use. Then keep the default name for the HD file, and continue.
The box is now created. Before starting it, select it on the left hand-side panel
in the
Virtual Box Manager window, then double-click on "Network
". Go to the tab
Adapter 2
and enable it (tick the box Enable Network Adapter
). Select
Host-only Adapter
in the drop-down list for Attached to
. And click OK.
Note: If there is no name selected in the second drop-down list, make sure you
created the host-only adapter as explained above.
Now double-click on "Storage
" for the virtual box, as you just did for
"Network
". Select the line "Empty
" under "Controller: IDE
", and
click on the small DVD icon, to select the CentOS ISO file to downloaded. The disk
image will
be mounted as if the DVD was inserted in the physical tray.
You can now start the machine (select it on the left-hand side panel, and click start).
The OS
Your brand-new virtual machine is now booting on the CentOS install disk. You will
now follow
the CentOS installer to install an OS on your machine. In the menu, select "Install
CentOS 7
".
Note that starting from there, the mouse and keyboard can be captured by the
virtual machine. Even Alt-Tab
on Windows and Linux and Cmd-Tab
on Mac, used
to switch between applications, does not work. This is very annoying. In order for
the host
OS to get control back, you must hit the Host key, which is indicated in the
bottom-right corner (by default, it is the left Cmd
key on Mac, only the one on the
left of the space bar).
Simply select the language and keyboard, then on the following screen set the date, time and timezone correctly. Note that in some screens, the "OK" or "Continue" button is located in the top-left corner, which sometimes makes it hard to find.
Click on "Installation destination
" and click "Done
" directly. That will
use the default option, which is to use the entire (virtual) disk for the installation.
This
is still a required step, to be sure the user validates erasing the disk with this
new CentOS
installation.
Before starting the installation, make sure you go to the "Network
" screen, and you
switch on both Ethernet connections (named enp0s3
and enp0s8
). This will
ensure the network is up and running everytime you start up the virtual machine.
Optionally,
you can set the network name of the machine on the same screen.
Now you can click on "Begin installation
". During the base system installation, you
can set the root password, and create a user account (make sure to check the Make this
user administrator
checkbox, so you can use sudo
with it.
Log in as root, using the password you just set up in the installer. Execute the
command
"yum install net-tools
", then "ifconfig
", and write down the IP of your
machine (in the enp0s8
section, line inet
). In my case, this is
192.168.56.101
. If you cannot see it, then most likely you forgot to enable
enp0s8
in the CentOS installer, and you can do it manually with ifup enp0s8
.
From your host machine, open a terminal, and ping your machine with ping
192.168.56.101
, to see if it responds. You can also connect remotely with ssh
root@192.168.56.101
. For now on, you can log out from the console on the virtual box,
let it run in the background, and connect from your host terminal via SSH (which integrates
better with your host OS, e.g. let you use copy and paste). If you cannot see the
IP address
for inet
, double-check that you have "ONBOOT=yes
" for both files
ifcfg-enp0s3
and ifcfg-enp0s8
in /etc/sysconfig/network-scripts/
.
Note that if ssh says WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!
, it is becasue
the RSA key has changed for the same IP. This happends if you threw away a virtual
box and
installed a new one. It might reuse the same IP, but it is a new machine, with a
new
certificate. This is normal and might be ignored (well, not exactly; to be able to
use ssh,
you need to open ~/.ssh/known_hosts
and remove the line corresponding to the IP of
the virtual machine).
Then update your system. The following commands will open all ports (this is a dev box, remember), update the packages in your system, and install the packages needed to install and run MarkLogic:
[root@ml ~]# systemctl stop firewalld [root@ml ~]# systemctl disable firewalld [root@ml ~]# yum update [root@ml ~]# yum install gcc kernel-devel [root@ml ~]# halt # reboot [root@ml ~]# yum groupinstall 'Development Tools' [root@ml ~]# yum install gdb glibc glibc.i686 lsb cyrus-sasl
And voilĂ ! Your virtual machine is ready to install MarkLogic...
MarkLogic
First, you have to copy the MarkLogic RPM package from the host terminal to your virtual box. Note: do not forget the colon character (the ':') at the end of the IP address:
$ scp MarkLogic-RH7-8.0-4.2.x86_64.rpm root@192.168.56.101:
Then to install MarkLogic itself, this is very simple. Execute both following commands from the guest system (that is, through SSH):
[root@ml ~]# rpm -i MarkLogic-RH7-8.0-4.2.x86_64.rpm [root@ml ~]# /etc/init.d/MarkLogic start
MarkLogic should now be installed and running. You can confirm it by going to http://192.168.56.101:8001/. You should see the admin console, asking you a few more questions to finish the install process. But starting here, the rest is a traditional MarkLogic story...
A very last point though. I usually add a mapping to the file /etc/hosts
(on the
host system), with a line like "192.168.56.101 ml
". With such a line, you can then
use the following URL for instance to access the MarkLogic admin interface on your
virtual
box: http://ml:8001/.
Enjoy!
Extras
Update: This is an update posted on Jan. 19, 2017.
This section contains some notes I found handy for working with CentOS. If you want to upgrade the version of Git installed on the VM (e.g. if you use the Git client "Magit" on Emacs, which requires a most recent version), you can use the following commands (shamelessly stolen from this page):
[root@ml ~]# yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel [root@ml ~]# yum install wget gcc perl-ExtUtils-MakeMaker [root@ml ~]# yum remove git [root@ml ~]# cd /usr/src [root@ml ~]# wget https://www.kernel.org/pub/software/scm/git/git-2.11.0.tar.gz [root@ml ~]# tar xzf git-2.11.0.tar.gz [root@ml ~]# cd git-2.11.0 [root@ml ~]# make prefix=/usr/local all [root@ml ~]# make prefix=/usr/local install [root@ml ~]# git --version
The last command should display: git version 2.11.0
.
Posted by Florent Georges, on 2016-03-27T19:31:00, tag: marklogic.