ambari-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (AMBARI-22766) ambari-server setup with internal database may not work on centos 7
Date Thu, 11 Jan 2018 19:31:00 GMT

    [ https://issues.apache.org/jira/browse/AMBARI-22766?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16322815#comment-16322815
] 

ASF GitHub Bot commented on AMBARI-22766:
-----------------------------------------

hapylestat closed pull request #95: [AMBARI-22766] ambari-server setup with internal database
may not work on centos 7 (dgrinenko)
URL: https://github.com/apache/ambari/pull/95
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/ambari-common/src/main/python/ambari_commons/os_check.py b/ambari-common/src/main/python/ambari_commons/os_check.py
index 04165848508..b2b227408ac 100644
--- a/ambari-common/src/main/python/ambari_commons/os_check.py
+++ b/ambari-common/src/main/python/ambari_commons/os_check.py
@@ -164,6 +164,8 @@ def __getattr__(cls, name):
 class OSConst:
   __metaclass__ = OS_CONST_TYPE
 
+  systemd_redhat_os_major_versions = ["7"]
+
 
 class OSCheck:
 
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 2ac5325b7e0..036a542d87b 100644
--- a/ambari-server/src/main/python/ambari_server/dbConfiguration_linux.py
+++ b/ambari-server/src/main/python/ambari_server/dbConfiguration_linux.py
@@ -355,19 +355,27 @@ class PGConfig(LinuxDBMSConfig):
   PG_ERROR_BLOCKED = "is being accessed by other users"
   PG_STATUS_RUNNING = None
   PG_STATUS_STOPPED = "stopped"
-  SERVICE_CMD = "/usr/bin/env service"
   PG_SERVICE_NAME = "postgresql"
   PG_HBA_DIR = None
 
-  PG_ST_CMD = "%s %s status" % (SERVICE_CMD, PG_SERVICE_NAME)
-  if os.path.isfile("/usr/bin/postgresql-setup"):
-      PG_INITDB_CMD = "/usr/bin/postgresql-setup initdb"
+  if OSCheck.is_redhat_family() and OSCheck.get_os_major_version() in OSConst.systemd_redhat_os_major_versions:
+    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)
   else:
-      PG_INITDB_CMD = "%s %s initdb" % (SERVICE_CMD, PG_SERVICE_NAME)
+    SERVICE_CMD = "/usr/bin/env service"
+    PG_ST_CMD = "%s %s status" % (SERVICE_CMD, PG_SERVICE_NAME)
+    if os.path.isfile("/usr/bin/postgresql-setup"):
+        PG_INITDB_CMD = "/usr/bin/postgresql-setup initdb"
+    else:
+        PG_INITDB_CMD = "%s %s initdb" % (SERVICE_CMD, PG_SERVICE_NAME)
 
-  PG_START_CMD = AMBARI_SUDO_BINARY + " %s %s start" % (SERVICE_CMD, PG_SERVICE_NAME)
-  PG_RESTART_CMD = AMBARI_SUDO_BINARY + " %s %s restart" % (SERVICE_CMD, PG_SERVICE_NAME)
-  PG_HBA_RELOAD_CMD = AMBARI_SUDO_BINARY + " %s %s reload" % (SERVICE_CMD, PG_SERVICE_NAME)
+    PG_START_CMD = AMBARI_SUDO_BINARY + " %s %s start" % (SERVICE_CMD, PG_SERVICE_NAME)
+    PG_RESTART_CMD = AMBARI_SUDO_BINARY + " %s %s restart" % (SERVICE_CMD, PG_SERVICE_NAME)
+    PG_HBA_RELOAD_CMD = AMBARI_SUDO_BINARY + " %s %s reload" % (SERVICE_CMD, PG_SERVICE_NAME)
 
   PG_HBA_CONF_FILE = None
   PG_HBA_CONF_FILE_BACKUP = None
@@ -611,7 +619,7 @@ def _get_postgre_status():
     retcode, out, err = run_os_command(PGConfig.PG_ST_CMD)
     # on RHEL and SUSE PG_ST_COMD returns RC 0 for running and 3 for stoppped
     if retcode == 0:
-      if out.strip() == "Running clusters:":
+      if out.strip() == "Running clusters:" or "active: inactive" in out.lower():
         pg_status = PGConfig.PG_STATUS_STOPPED
       else:
         pg_status = PGConfig.PG_STATUS_RUNNING


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> ambari-server setup with internal database may not work on centos 7
> -------------------------------------------------------------------
>
>                 Key: AMBARI-22766
>                 URL: https://issues.apache.org/jira/browse/AMBARI-22766
>             Project: Ambari
>          Issue Type: Bug
>          Components: ambari-server
>    Affects Versions: trunk
>            Reporter: Dmytro Grinenko
>            Assignee: Dmytro Grinenko
>            Priority: Critical
>             Fix For: trunk
>
>
> it may happened so, that centos7 image will not have "service" command at all.
> {code}
> Default properties detected. Using built-in database.
> INFO: Loading properties from /etc/ambari-server/conf/ambari.properties
> INFO: Adjusting filesystem permissions
> INFO: Loading properties from /etc/ambari-server/conf/ambari.properties
> Configuring ambari database...
> Checking PostgreSQL...
> INFO: about to run command: /usr/bin/env service postgresql status
> Running initdb: This may take up to a minute.
> INFO: about to run command: /usr/bin/postgresql-setup initdb
> About to start PostgreSQL
> INFO: about to run command: /usr/bin/env service postgresql status
> ERROR: Exiting with exit code 127.
> REASON: Unable to start PostgreSQL server. Exiting
> [root@node-test0 /]# service postgresql status
> bash: service: command not found
> [root@node-test0 /]# service postgresql status
> bash: service: command not found
> [root@node-test0 /]# service postgresql status
> bash: service: command not found
> [root@node-test0 /]# service postgresql status
> bash: service: command not found
> [root@node-test0 /]# service postgresql status
> bash: service: command not found
> {code}
> *Background:*
> This caused due to centos 7 using systemd by default and switched to use of {{systemctl}}
command instead of {{service}}. Since that, service command exist only in backward compatibility
context and r optional. Currently optional package, which provides this package called {{initscripts}}
> Currently, everything ok r with standalone centos 7 image and it includes this package
installed by default. However docker image centos/centos:7 doesn't provide this package by
default, and systemd enabled image centos/systemd:latest use {{systemctl}} without installed
{{initscripts}}: https://github.com/CentOS/sig-cloud-instance-images/issues/28
> *Summary:*
> Due to {{service}} command going to be deprecated, we need consider to switch fully to
{{systemctl}} replacement for systemd enabled images



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message