You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ao...@apache.org on 2018/08/17 09:56:03 UTC

[ambari] branch trunk updated: AMBARI-24495. ambari-server setup fails with postgresql >= 9.3 (aonishuk)

This is an automated email from the ASF dual-hosted git repository.

aonishuk pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 0d3cf9c  AMBARI-24495. ambari-server setup fails with postgresql >= 9.3  (aonishuk)
0d3cf9c is described below

commit 0d3cf9c38cf6ba4c0ed943af7df7b57619e1f0c2
Author: Andrew Onishuk <ao...@hortonworks.com>
AuthorDate: Fri Aug 17 08:55:25 2018 +0300

    AMBARI-24495. ambari-server setup fails with postgresql >= 9.3  (aonishuk)
---
 .../main/python/ambari_server/dbConfiguration_linux.py  | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/ambari-server/src/main/python/ambari_server/dbConfiguration_linux.py b/ambari-server/src/main/python/ambari_server/dbConfiguration_linux.py
index e1d31e4..722b134 100644
--- a/ambari-server/src/main/python/ambari_server/dbConfiguration_linux.py
+++ b/ambari-server/src/main/python/ambari_server/dbConfiguration_linux.py
@@ -362,9 +362,24 @@ class PGConfig(LinuxDBMSConfig):
   PG_HBA_DIR = None
 
   if OSCheck.is_redhat_family() and OSCheck.get_os_major_version() in OSConst.systemd_redhat_os_major_versions:
+    if os.path.isfile("/usr/bin/postgresql-setup"):
+      PG_INITDB_CMD = "/usr/bin/postgresql-setup initdb"
+    else:
+      versioned_script_path = glob.glob("/usr/pgsql-*/bin/postgresql*-setup")
+      # versioned version of psql
+      if versioned_script_path:
+        PG_INITDB_CMD = "{0} initdb".format(versioned_script_path[0])
+
+        psql_service_file = glob.glob("/usr/lib/systemd/system/postgresql-*.service")
+        if psql_service_file:
+          psql_service_file_name = os.path.basename(psql_service_file[0])
+          PG_SERVICE_NAME = psql_service_file_name[:-8] # remove .service
+      else:
+        raise FatalException(1, "Cannot find postgresql-setup script.")
+
     SERVICE_CMD = "/usr/bin/env systemctl"
     PG_ST_CMD = "%s status %s" % (SERVICE_CMD, PG_SERVICE_NAME)
-    PG_INITDB_CMD = "/usr/bin/postgresql-setup initdb"
+
     PG_START_CMD = AMBARI_SUDO_BINARY + " %s start %s" % (SERVICE_CMD, PG_SERVICE_NAME)
     PG_RESTART_CMD = AMBARI_SUDO_BINARY + " %s restart %s" % (SERVICE_CMD, PG_SERVICE_NAME)
     PG_HBA_RELOAD_CMD = AMBARI_SUDO_BINARY + " %s reload %s" % (SERVICE_CMD, PG_SERVICE_NAME)