Error while setting up DHIS2 2.32.0 on Ubuntu Server

Hello,
I Am trying to setup DHIS2 2.32.0 on my ubuntu instance but am getting errors. My machine has 4GB RAM.
The Postgres DB instance is populated with tables but I still see an ERROR: out of shared memory. I have tried to increase max_locks_per_transaction in the.
How could I solve this error?

SQL State  : 53200
Error Code : 0
Message    : ERROR: out of shared memory
  Hint: You might need to increase max_locks_per_transaction.
Location   : org/hisp/dhis/db/migration/2.32/V2_32_10__Use_bigint_for_id_columns.sql (/home/dhis/tomcat-dhis/file:/home/dhis/tomcat-dhis/webapps/ROOT/WEB-INF/lib/dhis-support-db-migration-2.32.0.jar!/org/hisp/dhis/db/migration/2.32/V2_32_10__Use_bigint_for_id_columns.sql)
Line       : 725
Statement  : alter table smscommands alter column smscommandid type bigint
 (AbstractApplicationContext.java [localhost-startStop-1])
* ERROR 2019-05-21 09:13:02,742 Context initialization failed (ContextLoader.java [localhost-startStop-1])
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.hisp.dhis.security.acl.AclService' defined in URL [jar:file:/home/dhis/tomcat-dhis/webapps/ROOT/WEB-INF/lib/dhis-service-acl-2.32.0.jar!/META-INF/dhis/beans.xml]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.hisp.dhis.schema.SchemaService' defined in URL [jar:file:/home/dhis/tomcat-dhis/webapps/ROOT/WEB-INF/lib/dhis-service-schema-2.32.0.jar!/META-INF/dhis/beans.xml]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.hisp.dhis.schema.PropertyIntrospectorService': Unsatisfied dependency expressed through field 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flyway' defined in URL [jar:file:/home/dhis/tomcat-dhis/webapps/ROOT/WEB-INF/lib/dhis-support-db-migration-2.32.0.jar!/META-INF/dhis/beans.xml]: Invocation of init method failed; nested exception is org.flywaydb.core.internal.command.DbMigrate$FlywayMigrateException: 
Migration V2_32_10__Use_bigint_for_id_columns.sql failed
--------------------------------------------------------
SQL State  : 53200
Error Code : 0
Message    : ERROR: out of shared memory
  Hint: You might need to increase max_locks_per_transaction.
Location   : org/hisp/dhis/db/migration/2.32/V2_32_10__Use_bigint_for_id_columns.sql (/home/dhis/tomcat-dhis/file:/home/dhis/tomcat-dhis/webapps/ROOT/WEB-INF/lib/dhis-support-db-migration-2.32.0.jar!/org/hisp/dhis/db/migration/2.32/V2_32_10__Use_bigint_for_id_columns.sql)
Line       : 725
Statement  : alter table smscommands alter column smscommandid type bigint

	at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749)
	at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:189)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1198)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1100)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:481)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)
	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:443)
	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:325)
	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5068)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5584)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:899)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
	at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1091)
	at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1980)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.hisp.dhis.schema.SchemaService' defined in URL [jar:file:/home/dhis/tomcat-dhis/webapps/ROOT/WEB-INF/lib/dhis-service-schema-2.32.0.jar!/META-INF/dhis/beans.xml]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.hisp.dhis.schema.PropertyIntrospectorService': Unsatisfied dependency expressed through field 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flyway' defined in URL [jar:file:/home/dhis/tomcat-dhis/webapps/ROOT/WEB-INF/lib/dhis-support-db-migration-2.32.0.jar!/META-INF/dhis/beans.xml]: Invocation of init method failed; nested exception is org.flywaydb.core.internal.command.DbMigrate$FlywayMigrateException:
1 Like

Hi,

You have to uncomment and set “max_locks_per_transaction = 1024” in the /etc/postgresql/10/main/postgresql.conf file

Next, you need to restart the service by running “sudo service postgresql restart”

Then stop the tomcat service and start again.

Have you tried them?

1 Like

Hi,
Follow the below steps for proper dhis 2.32 installation on ubuntu system

Install Java 8

sudo apt-get install openjdk-8-jdk

Install PostgreSQL

sudo apt-get install postgresql-10 postgresql-contrib-10 postgresql-10-postgis-2.4
sudo -u postgres createuser -SDRP dhis

Create database & PostGIS extension in PostgreSQL

sudo -u postgres createdb -O dhis dhis2
sudo -u postgres psql -c “create extension postgis;” dhis2
Open /etc/postgresql/10/main/postgresql.conf file and set “max_locks_per_transaction = 1024”
Restart PostgresSQL by command : sudo service postgresql restart

Creating DHIS2 configuration file

sudo -u dhis nano /home/dhis/config/dhis.conf

Copy the below lines in dhis.config

connection.dialect = org.hibernate.dialect.PostgreSQLDialect
connection.driver_class = org.postgresql.Driver
connection.url = jdbc:postgresql:dhis2
connection.username = dhis
connection.password = dhis
connection.schema = update
encryption.password = abcd

Install Tomcat & setup for dhis2

sudo apt-get install tomcat8-user
sudo nano /opt/apache-tomcat-8.5.41/bin/setenv.sh

Copy the lines to setenv.sh:

export JAVA_HOME=’/usr/lib/jvm/java-8-openjdk-amd64/’
export JAVA_OPTS=’-Xmx2048m -Xms1024m’ //Change accordingly
export DHIS2_HOME=’/home/dhis/config’

Copy the dhis.war inside /opt/apache-tomcat-8.5.41/webapps
(You can download it from https://www.dhis2.org/downloads)

Start Tomcat

cd /opt/apache-tomcat-8.5.41/bin
./startup.sh

Access dhis2 web application

http://IP_OF_YOUR_SERVER:8080/dhis

1 Like