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.
- 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
- 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
- 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
- Create a parallel folder to contain your first Bahmni implementation instance. Letβs start by setting up the default.
mkdir /usr/local/bahmni/default
- 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
- Bring this box up (from /usr/local/bahmni/default):
vagrant up vagrant ssh
- 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
- 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
- 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β
- 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}
- 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
- 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
- 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
- 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