Installing Bahmni with limited internet

Continuing the discussion from Bahmni offline local install:

Recently I found myself needing to be able to install Bahmni when offline. This is a pretty common scenario - often an implementer may need to install Bahmni on multiple servers at health facilities that have poor or no internet. Other times perhaps a developer wants to fire up a new Bahmni environment in Vagrant while on an airplane or otherwise disconnected. This latter scenario is where I found myself this past week. And I was totally blocked. When I got a day of decent internet this weekend, I decided to try to put together a process for overcoming this.

At a high level, the process is this:

  • At a time when you have decent internet, install Bahmni as I describe below (this requires downloading approximately 300MB+ of files)

  • In subsequent installs, you can be totally offline and successfully install a new Bahmni environment using the files you gather in the preceeding step

This example uses Vagrant, though the same principles would apply in non-Vagrant-based setups.

  1. Create a working directory on your host (I’m doing this in /usr/local as an example, but you could put this anywhere):

sudo mkdir /usr/local/bahmni sudo chown your_user_name: /usr/local/bahmni

  1. Create a folder within this directory to act as your yum RPM cache. We keep this on the host so as to not lose it within a single VM

mkdir /usr/local/bahmni/yum_cache

  1. Download the version of the Bahmni installer that corresponds to the version of Bahmni you want to install, and put it in the yum_cache folder you created (I couldn’t figure out how else to cache this, it didn’t get cached by default by yum otherwise):

wget https://bahmni-repo.twhosted.com/rpm/bahmni/bahmni-installer-0.80-139.noarch.rpm -P /usr/local/bahmni/yum_cache

  1. Create a parallel folder to contain your first Bahmni implementation instance. Let’s start by setting up the default.

mkdir /usr/local/bahmni/default

  1. Add a Vagrantfile to this folder (/usr/local/bahmni/default/Vagrantfile). Mine looks like the below. The key element here is syncing the yum_cache folder as shown.

-- mode: ruby --

vi: set ft=ruby :

Vagrantfile API/syntax version. Don’t touch unless you know what you’re doing!

VAGRANTFILE_API_VERSION = β€œ2”

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.box = β€œbento/centos-6.7” config.vm.network β€œprivate_network”, ip: β€œ192.168.33.21” config.vm.provider β€œvirtualbox” do |vb| vb.customize [β€œmodifyvm”, :id, β€œβ€“memory”, β€œ3072”, β€œβ€“cpus”, β€œ2”] vb.customize [β€œmodifyvm”, :id, β€œβ€“natdnshostresolver1”, β€œon”] vb.customize [β€œmodifyvm”, :id, β€œβ€“natdnsproxy1”, β€œon”] end config.vm.synced_folder β€œβ€¦/yum_cache/”, β€œ/etc/yum_cache” config.vm.hostname = β€œbahmni” end

  1. Bring this box up (from /usr/local/bahmni/default):

vagrant up vagrant ssh

  1. Now that you are in your new CentOS box, you will need to make sure that YUM caching is appropriately configured. It seems to be disabled by default. I use the following two commands below to edit my yum.conf file to enable repository caching and to change the location of the cached data to the folder mounted from our host that we set up previously. These may not map exactly to your yum.conf file. They are tested to work on the bento/centos-6.7 box indicated above. You can view the contents of /etc/yum.conf to confirm the before/after of these settings. Basically this is just changing the value of the β€œkeepcache” setting to β€œ1” and the value of the β€œcachedir” setting to β€œ/etc/yum_cache”:

sudo sed -i β€œs|keepcache=0|keepcache=1|g” /etc/yum.conf sudo sed -i β€œs|cachedir=/var/cache/yum/$basearch/$releasever|cachedir=/etc/yum_cache|g” /etc/yum.conf

  1. Next step is to use yum to install the bahmni-installer package. Replace the below with the name of the rpm you downloaded in step 3

sudo yum install -y /etc/yum_cache/bahmni-installer-0.80-139.noarch.rpm

  1. You can confirm that RPMs are being cached correctly by running the below command and ensuring it returns appropriate results:

find /etc/yum_cache/ -iname β€˜*.rpm’

  1. Now, let’s try to install Bahmni. (NOTE: if you do not wish to install everything, you can add an inventory file to /etc/bahmni-installer as described here: https://bahmni.atlassian.net/wiki/display/BAH/Install+Bahmni+on+Centos+using+Ansible)

sudo bahmni install {inventory_file_name_if_applicable} {implementation_name_if_applicable}

  1. The above will take some time, especially if you are on a slow connection. You can monitor some of what is happening with:

sudo tail -f /var/log/yum.log sudo tail -f /var/log/bahmni-installer/bahmni-installer.log

  1. When it finishes, you should be able to have a look at your /etc/yum_cache folder and see all of the artifacts. The below shows the contents of what I have after installing bahmni-emr, bahmni-emr-db, and bahmni-reports (and a bit from bahmni-erp, which I started installing by accident):

[vagrant@bahmni yum_cache]$ tree . β”œβ”€β”€ bahmni β”‚ β”œβ”€β”€ a6e9673f4247c34eb5a5248332927e8f4666da4d21a3c81dd9bd751e9b8e3700-primary.sqlite β”‚ β”œβ”€β”€ cachecookie β”‚ β”œβ”€β”€ packages β”‚ β”‚ β”œβ”€β”€ bahmni-emr-0.80-325.noarch.rpm β”‚ β”‚ β”œβ”€β”€ bahmni-reports-0.80-63.noarch.rpm β”‚ β”‚ β”œβ”€β”€ bahmni-web-0.80-325.noarch.rpm β”‚ β”‚ └── openmrs-1.12.0-325.noarch.rpm β”‚ └── repomd.xml β”œβ”€β”€ base β”‚ β”œβ”€β”€ 11bcf3233241e37e1a0e04d2fde8a609215059b5b0319fd660f796d462bbe6a8-primary.sqlite β”‚ β”œβ”€β”€ cachecookie β”‚ β”œβ”€β”€ mirrorlist.txt β”‚ β”œβ”€β”€ packages β”‚ β”‚ β”œβ”€β”€ apr-1.3.9-5.el6_2.x86_64.rpm β”‚ β”‚ β”œβ”€β”€ apr-util-1.3.9-3.el6_0.1.x86_64.rpm β”‚ β”‚ β”œβ”€β”€ apr-util-ldap-1.3.9-3.el6_0.1.x86_64.rpm β”‚ β”‚ β”œβ”€β”€ libaio-0.3.107-10.el6.x86_64.rpm β”‚ β”‚ β”œβ”€β”€ libselinux-python-2.0.94-5.8.el6.x86_64.rpm β”‚ β”‚ β”œβ”€β”€ libyaml-0.1.3-4.el6_6.x86_64.rpm β”‚ β”‚ β”œβ”€β”€ lsof-4.82-5.el6.x86_64.rpm β”‚ β”‚ β”œβ”€β”€ mailcap-2.1.31-2.el6.noarch.rpm β”‚ β”‚ β”œβ”€β”€ mod_wsgi-3.2-7.el6.x86_64.rpm β”‚ β”‚ β”œβ”€β”€ MySQL-python-1.2.3-0.3.c1.1.el6.x86_64.rpm β”‚ β”‚ β”œβ”€β”€ numactl-2.0.9-2.el6.x86_64.rpm β”‚ β”‚ β”œβ”€β”€ perl-DBI-1.609-4.el6.x86_64.rpm β”‚ β”‚ β”œβ”€β”€ python-babel-0.9.4-5.1.el6.noarch.rpm β”‚ β”‚ β”œβ”€β”€ python-crypto-2.0.1-22.el6.x86_64.rpm β”‚ β”‚ β”œβ”€β”€ python-jinja2-2.2.1-2.el6_5.x86_64.rpm β”‚ β”‚ β”œβ”€β”€ python-markupsafe-0.9.2-4.el6.x86_64.rpm β”‚ β”‚ β”œβ”€β”€ python-paramiko-1.7.5-2.1.el6.noarch.rpm β”‚ β”‚ β”œβ”€β”€ python-pyasn1-0.0.12a-1.el6.noarch.rpm β”‚ β”‚ β”œβ”€β”€ python-setuptools-0.6.10-3.el6.noarch.rpm β”‚ β”‚ β”œβ”€β”€ python-simplejson-2.0.9-3.1.el6.x86_64.rpm β”‚ β”‚ β”œβ”€β”€ PyYAML-3.10-3.1.el6.x86_64.rpm β”‚ β”‚ β”œβ”€β”€ tree-1.5.3-3.el6.x86_64.rpm β”‚ β”‚ β”œβ”€β”€ unzip-6.0-2.el6_6.x86_64.rpm β”‚ β”‚ └── yum-utils-1.1.30-30.el6.noarch.rpm β”‚ └── repomd.xml β”œβ”€β”€ epel β”‚ β”œβ”€β”€ 5828a19437bb3bc9c9434b63423833bb7c84dbe8556927bda8de489cce52e81d-primary.sqlite β”‚ β”œβ”€β”€ cachecookie β”‚ β”œβ”€β”€ metalink.xml β”‚ β”œβ”€β”€ packages β”‚ β”‚ β”œβ”€β”€ ansible-1.9.4-1.el6.noarch.rpm β”‚ β”‚ β”œβ”€β”€ htop-1.0.1-2.el6.x86_64.rpm β”‚ β”‚ β”œβ”€β”€ python-crypto2.6-2.6.1-2.el6.x86_64.rpm β”‚ β”‚ β”œβ”€β”€ python-flask-0.9-7.el6.noarch.rpm β”‚ β”‚ β”œβ”€β”€ python-httplib2-0.7.7-1.el6.noarch.rpm β”‚ β”‚ β”œβ”€β”€ python-jinja2-26-2.6-3.el6.noarch.rpm β”‚ β”‚ β”œβ”€β”€ python-keyczar-0.71c-1.el6.noarch.rpm β”‚ β”‚ β”œβ”€β”€ python-pip-7.1.0-1.el6.noarch.rpm β”‚ β”‚ β”œβ”€β”€ python-werkzeug-0.8.3-2.el6.noarch.rpm β”‚ β”‚ └── sshpass-1.05-1.el6.x86_64.rpm β”‚ └── repomd.xml β”œβ”€β”€ extras β”‚ β”œβ”€β”€ a523b7c5e81ec9db2b257c477538ff8616ed7b325add59ea7e56de6ac68b6d85-primary.sqlite β”‚ β”œβ”€β”€ cachecookie β”‚ β”œβ”€β”€ mirrorlist.txt β”‚ β”œβ”€β”€ packages β”‚ β”‚ └── epel-release-6-8.noarch.rpm β”‚ └── repomd.xml β”œβ”€β”€ mysql56-community β”‚ β”œβ”€β”€ 9cb0cda1ce33f0b8d850c47a32f9b59814fc4126-primary.sqlite β”‚ β”œβ”€β”€ cachecookie β”‚ β”œβ”€β”€ packages β”‚ β”‚ β”œβ”€β”€ mysql-community-client-5.6.29-2.el6.x86_64.rpm β”‚ β”‚ β”œβ”€β”€ mysql-community-common-5.6.29-2.el6.x86_64.rpm β”‚ β”‚ β”œβ”€β”€ mysql-community-libs-5.6.29-2.el6.x86_64.rpm β”‚ β”‚ β”œβ”€β”€ mysql-community-libs-compat-5.6.29-2.el6.x86_64.rpm β”‚ β”‚ └── mysql-community-server-5.6.29-2.el6.x86_64.rpm β”‚ └── repomd.xml β”œβ”€β”€ pgdg92 β”‚ β”œβ”€β”€ cachecookie β”‚ β”œβ”€β”€ e1ea4d0603c9668ba388dfe59e2a39ff2ce0b47a4dcb082f70f18f86717ca21e-primary.sqlite β”‚ β”œβ”€β”€ packages β”‚ β”‚ β”œβ”€β”€ postgresql92-libs-9.2.15-1PGDG.rhel6.x86_64.rpm β”‚ β”‚ └── python-psycopg2-2.6.1-1.rhel6.x86_64.rpm β”‚ └── repomd.xml β”œβ”€β”€ timedhosts.txt └── updates β”œβ”€β”€ 0a2f916603e93bcafb0516023677cae95b4c72133958c765a85532ecd71dfe8e-primary.sqlite β”œβ”€β”€ cachecookie β”œβ”€β”€ mirrorlist.txt β”œβ”€β”€ packages β”‚ β”œβ”€β”€ httpd-2.2.15-47.el6.centos.3.x86_64.rpm β”‚ β”œβ”€β”€ httpd-tools-2.2.15-47.el6.centos.3.x86_64.rpm β”‚ β”œβ”€β”€ mod_ssl-2.2.15-47.el6.centos.3.x86_64.rpm β”‚ β”œβ”€β”€ ntp-4.2.6p5-5.el6.centos.4.x86_64.rpm β”‚ β”œβ”€β”€ ntpdate-4.2.6p5-5.el6.centos.4.x86_64.rpm β”‚ β”œβ”€β”€ perl-5.10.1-141.el6_7.1.x86_64.rpm β”‚ β”œβ”€β”€ perl-libs-5.10.1-141.el6_7.1.x86_64.rpm β”‚ β”œβ”€β”€ perl-Module-Pluggable-3.90-141.el6_7.1.x86_64.rpm β”‚ β”œβ”€β”€ perl-Pod-Escapes-1.04-141.el6_7.1.x86_64.rpm β”‚ β”œβ”€β”€ perl-Pod-Simple-3.13-141.el6_7.1.x86_64.rpm β”‚ β”œβ”€β”€ perl-version-0.77-141.el6_7.1.x86_64.rpm β”‚ └── postfix-2.6.6-6.el6_7.1.x86_64.rpm └── repomd.xml

  1. Annoyingly, the Oracle Java install does not cache it’s (sizeable) rpm artifact in the yum cache. It seems to download this into /opt. Others may do the same. In order to account for this, we should copy these rpms into our yum_cache folder so that we have them for later:

sudo mkdir /etc/yum_cache/opt_rpms sudo cp /opt/*.rpm /etc/yum_cache/opt_rpms

  1. Done! Now we should confirm that we can use these artifacts to set up another Bahmni environment from scratch, without having to download them all again from the internet:
  • Exit out of your vagrant box and stop it

vagrant halt

  • Disconnect yourself from the internet (we want this to be a true test)

  • Repeat steps 4-10 above, with a different directory. Before step 10 (eg. before running β€œbahmni install”) copy the artifacts from step 13 back into the opt folder).

sudo cp /etc/yum_cache/opt_rpms/* /opt

  • To prove to yourself that this is really a different instance, you could install a slightly different version, either by using a different inventory file (eg. install only EMR in the first box, and include Lab in the second box), or by using a different configuration (eg. install with the default database in the first box, which contains demo data and content, but install with an empty database in the second box by adjusting your configuration settings at install. See https://bahmni.atlassian.net/wiki/display/BAH/Install+Bahmni+on+Centos+using+Ansible

  • This should succeed and you can repeat this as many times as you need to without downloading the same things over and over again.

@vsingh / @bharatak / @gsluthra - FYI - feel free to adapt any of this for the Bahmni wiki that is useful.

Mike

4 Likes

Thanks Mike. This is very helpful. We will try it out once and make these complete set of rpms available in a particular repo where people can download directly and run for an offline install.

@mseaton: Its awesome of you to have documented these steps!! Thanks a lot. For now, I am going to link to this discussion from the Bahmni Wiki. Once @bharatak / someone from the team has tested these fully, I will document it on the Wiki.

Added a link and a note on this page for reference: https://bahmni.atlassian.net/wiki/display/BAH/Install+Bahmni+on+CentOS

1 Like

@mseaton :

Thanks for documenting the steps. That really helped us…:slight_smile:

We added few more steps to those pointed by you and documented here.