Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Ambari: Error while creating database accessor

Highlighted

Ambari: Error while creating database accessor

Contributor

Hello All,

I just finished setting up Ambari 2.5.1. I am using Standalone PostgreSQL 9.6

Setup finished successfully but I am getting error while starting Ambari server.

This is what I see in Linux command line

Ambari Server 'setup' completed successfully.
[kfkadm@******didkfkw ~]$ ambari-server start
Using python /usr/bin/python
Starting ambari-server
Organizing resource files at /var/lib/ambari-server/resources...
Unable to check firewall status when starting without root privileges.
Please do not forget to disable or adjust firewall if needed
Ambari database consistency check started...
Server PID at: /var/run/ambari-server/ambari-server.pid
Server out at: /var/log/ambari-server/ambari-server.out
Server log at: /var/log/ambari-server/ambari-server.log
/usr/bin/sh: line 0: ulimit: open files: cannot modify limit: Operation not permitted
Waiting for server start.........Unable to determine server PID. Retrying...
......Unable to determine server PID. Retrying...
......Unable to determine server PID. Retrying...
ERROR: Exiting with exit code -1.
REASON: Ambari Server java process died with exitcode 1. Check /var/log/ambari-server/ambari-server.out for more information.

This is what I see in ambari-server.out file

Error injecting constructor, java.lang.RuntimeException: Error while creating database accessor
at org.apache.ambari.server.orm.DBAccessorImpl.<init>(DBAccessorImpl.java:85)
at org.apache.ambari.server.orm.DBAccessorImpl.class(DBAccessorImpl.java:73)
while locating org.apache.ambari.server.orm.DBAccessorImpl
while locating org.apache.ambari.server.orm.DBAccessor
for field at org.apache.ambari.server.orm.dao.DaoUtils.dbAccessor(DaoUtils.java:36)
at org.apache.ambari.server.orm.dao.DaoUtils.class(DaoUtils.java:36)
while locating org.apache.ambari.server.orm.dao.DaoUtils
for field at org.apache.ambari.server.orm.dao.UserDAO.daoUtils(UserDAO.java:45)
at org.apache.ambari.server.orm.dao.UserDAO.class(UserDAO.java:45)
while locating org.apache.ambari.server.orm.dao.UserDAO
for field at org.apache.ambari.server.controller.internal.ActiveWidgetLayoutResourceProvider.userDAO(ActiveWidgetLayoutResourceProvider.java:61)
Caused by: java.lang.RuntimeException: Error while creating database accessor
at org.apache.ambari.server.orm.DBAccessorImpl.<init>(DBAccessorImpl.java:118)
at org.apache.ambari.server.orm.DBAccessorImpl$$FastClassByGuice$$86dbc63e.newInstance(<generated>)
at com.google.inject.internal.cglib.reflect.$FastConstructor.newInstance(FastConstructor.java:40)
at com.google.inject.internal.DefaultConstructionProxyFactory$1.newInstance(DefaultConstructionProxyFactory.java:60)
at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:254)
at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1031)
at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
at com.google.inject.Scopes$1$1.get(Scopes.java:65)
at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:40)
at com.google.inject.internal.FactoryProxy.get(FactoryProxy.java:54)
at com.google.inject.internal.SingleFieldInjector.inject(SingleFieldInjector.java:53)
at com.google.inject.internal.MembersInjectorImpl.injectMembers(MembersInjectorImpl.java:110)
at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:94)
at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:254)
at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1031)
at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
at com.google.inject.Scopes$1$1.get(Scopes.java:65)
at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:40)
at com.google.inject.internal.SingleFieldInjector.inject(SingleFieldInjector.java:53)
at com.google.inject.internal.MembersInjectorImpl.injectMembers(MembersInjectorImpl.java:110)
at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:94)
at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:254)
at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1031)
at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
at com.google.inject.Scopes$1$1.get(Scopes.java:65)
at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:40)
at com.google.inject.internal.SingleFieldInjector.inject(SingleFieldInjector.java:53)
at com.google.inject.internal.InjectionRequestProcessor$StaticInjection$1.call(InjectionRequestProcessor.java:116)
at com.google.inject.internal.InjectionRequestProcessor$StaticInjection$1.call(InjectionRequestProcessor.java:110)
at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1024)
at com.google.inject.internal.InjectionRequestProcessor$StaticInjection.injectMembers(InjectionRequestProcessor.java:110)
at com.google.inject.internal.InjectionRequestProcessor.injectMembers(InjectionRequestProcessor.java:78)
at com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:170)
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:109)
at com.google.inject.Guice.createInjector(Guice.java:95)
at com.google.inject.Guice.createInjector(Guice.java:72)
at com.google.inject.Guice.createInjector(Guice.java:62)
at org.apache.ambari.server.controller.AmbariServer.main(AmbariServer.java:992)
Caused by: org.postgresql.util.PSQLException: Connection refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:207)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:64)
at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:138)
at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:29)
at org.postgresql.jdbc3g.AbstractJdbc3gConnection.<init>(AbstractJdbc3gConnection.java:21)
at org.postgresql.jdbc4.AbstractJdbc4Connection.<init>(AbstractJdbc4Connection.java:31)
at org.postgresql.jdbc4.Jdbc4Connection.<init>(Jdbc4Connection.java:24)
at org.postgresql.Driver.makeConnection(Driver.java:410)
at org.postgresql.Driver.connect(Driver.java:280)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at org.apache.ambari.server.orm.DBAccessorImpl.<init>(DBAccessorImpl.java:91)
... 41 more
Caused by: java.net.ConnectException: Connection refused (Connection refused)
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at java.net.Socket.connect(Socket.java:538)
at org.postgresql.core.PGStream.<init>(PGStream.java:60)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:101)
... 52 more

How do I resolve this error?

7 REPLIES 7
Highlighted

Re: Ambari: Error while creating database accessor

@M R

To resolve this issue, ensure the following:

  • There is enough space on the device running postgresql.
  • The postgresql service is running.
# service postgresql status 
# netstat -ntpl | grep 5432
If not, start the postgresql service and then try to start ambari-server again.
Highlighted

Re: Ambari: Error while creating database accessor

Contributor

@Sridhar Reddy

Thanks for replying. This is what I see

[kfkadm@*********** ~]$ service postgresql status
Redirecting to /bin/systemctl status postgresql.service
● postgresql.service
Loaded: not-found (Reason: No such file or directory)
Active: inactive (dead)


[kfkadm@********** ~]$ sudo systemctl status postgresql-9.6
[sudo] password for kfkadm:
● postgresql-9.6.service - PostgreSQL 9.6 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql-9.6.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2017-09-14 15:46:05 EDT; 15h ago
Main PID: 7428 (postmaster)
CGroup: /system.slice/postgresql-9.6.service
├─7428 /usr/pgsql-9.6/bin/postmaster -D /var/lib/pgsql/9.6/data/
├─7429 postgres: logger process
├─7431 postgres: checkpointer process
├─7432 postgres: writer process
├─7433 postgres: wal writer process
├─7434 postgres: autovacuum launcher process
└─7435 postgres: stats collector process

Sep 14 15:46:05 ******* systemd[1]: Starting PostgreSQL 9.6 database server...
Sep 14 15:46:05 ********** postmaster[7428]: < 2017-09-14 15:46:05.333 EDT > LOG: redirecting log output to loggi...ocess
Sep 14 15:46:05 ************* postmaster[7428]: < 2017-09-14 15:46:05.333 EDT > HINT: Future log output will appear ...log".
Sep 14 15:46:05 ************* systemd[1]: Started PostgreSQL 9.6 database server.
Hint: Some lines were ellipsized, use -l to show in full.

[kfkadm@********** ~]$ netstat -ntpl | grep 5432
(No info could be read for "-p": geteuid()=30009 but you should be root.)
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN -
tcp6 0 0 ::1:5432 :::* LISTEN -

Highlighted

Re: Ambari: Error while creating database accessor

Mentor

@M R

During the ambari server setup

# ambari-server setup 
..... 
.... 
Enter advanced database configuration [y/n] (n)? y 
Configuring database... 
============================================================================== 
Choose one of the following options: 
[1] - PostgreSQL (Embedded) 
[2] - Oracle 
[3] - MySQL / MariaDB 
[4] - PostgreSQL 
[5] - Microsoft SQL Server (Tech Preview) 
[6] - SQL Anywhere 
[7] - BDB 
============================================================================== 
Enter choice (1): 4 
Hostname (localhost): 
Port (xxxx): 
Database name (ambari):xxxx 
Username (ambari):xxxxx 
Enter Database Password (bigdata): 
Re-enter password: 
Configuring ambari database...

Did you choose option 4 and entered the values you'd previously configured for your standalone PostgresDB?

Highlighted

Re: Ambari: Error while creating database accessor

Contributor


@Geoffrey Shelton Okot Thanks for replying. Yes. I chose option 4 and then provided values I had configured for standalone PostgreDB

Highlighted

Re: Ambari: Error while creating database accessor

Super Mentor

@M R

As you are using your own "Postgres" instance and we see that it is running fine as well. So i am suspecting that you might not have created the Ambari Database inside the Postgres which is needed if we want to use Non Default Database with Ambari.

.

Please refer to the following doc to verify if you have created the ambari database schema and users properly or not?

https://docs.hortonworks.com/HDPDocuments/Ambari-2.5.1.0/bk_ambari-administration/content/using_amba...

.

If you have followed the doc then you should be able to connect to ambari DB on your postgres as following:

# psql -U ambari ambari
Password for user ambari: bigdata
psql (9.5.5)
Type "help" for help.
ambari=>

.

Also please check the "ambari.properties" JDBC properties are correct and desired or not?

# grep 'jdbc' /etc/ambari-server/conf/ambari.properties 
server.jdbc.hostname=standaloneambari.example.com
server.jdbc.driver=org.postgresql.Driver
server.jdbc.rca.user.name=ambari
server.jdbc.user.passwd=/etc/ambari-server/conf/password.dat
server.jdbc.database=postgres
server.jdbc.database_name=ambari
server.jdbc.rca.url=jdbc:postgresql://standaloneambari.example.com:5432/ambari
server.jdbc.rca.driver=org.postgresql.Driver
server.jdbc.port=5432
server.jdbc.rca.user.passwd=/etc/ambari-server/conf/password.dat
server.jdbc.user.name=ambari
server.jdbc.postgres.schema=ambari
server.jdbc.url=jdbc:postgresql://standaloneambari.example.com:5432/ambari

.

Above will show the configured Postgres DB hostname & Port and ambari Schema .... those should be available and accessible. Password can be seen in the following file for verification:

# cat /etc/ambari-server/conf/password.dat
bigdata

.

Highlighted

Re: Ambari: Error while creating database accessor

Contributor

I am able to connect to ambari DB

sudo su postgres
bash-4.2$ psql -U ambari -d ambari
could not change directory to "/home/kfkadm": Permission denied
Password for user ambari:
psql (9.6.5)
Type "help" for help.

ambari=>

ambari.properties are mostly same except for the ones in bold below:

server.jdbc.connection-pool=internal ( This one is extra in my setup)
server.jdbc.database=postgres
server.jdbc.database_name=ambari
server.jdbc.driver=org.postgresql.Driver
server.jdbc.hostname=localhost ( This one is pointing to local host instead of server name)
server.jdbc.port=5432
server.jdbc.postgres.schema=ambarischema
server.jdbc.rca.driver=org.postgresql.Driver
server.jdbc.rca.url=jdbc:postgresql://*******:5432/ambari
server.jdbc.rca.user.name=ambari
server.jdbc.rca.user.passwd=/etc/ambari-server/conf/password.dat
server.jdbc.url=jdbc:postgresql://**********:5432/ambari
server.jdbc.user.name=ambari
server.jdbc.user.passwd=/etc/ambari-server/conf/password.dat

I can see correct password at /etc/ambari-server/conf/password.dat

Re: Ambari: Error while creating database accessor

Contributor

Need to follow below check list

1) Make sure you are providing the right jdbc database URL

2) Database server is up and running

3) Check the database should accessable from Ambari system with the required user credentials

Don't have an account?
Coming from Hortonworks? Activate your account here