def configure(self, env):
    import params
    env.set_params(params)

    # init the database, the ':' makes the command always return 0 in case the database has
    # already been initialized when the postgresql server colocates with ambari server
    Execute(format("service {postgresql_daemon_name} initdb || :"))

    # update the configuration files
    self.update_pghda_conf(env)
    self.update_postgresql_conf(env)

    # Reload the settings and start the postgresql server for the changes to take effect
    # Note: Don't restart the postgresql server because when Ambari server and the hive metastore on the same machine,
    # they will share the same postgresql server instance. Restarting the postgresql database may cause the ambari server database connection lost
    postgresql_service(postgresql_daemon_name=params.postgresql_daemon_name, action = 'reload')

    # ensure the postgresql server is started because the add hive metastore user requires the server is running.
    self.start(env)

    # create the database and hive_metastore_user
    File(params.postgresql_adduser_path,
         mode=0755,
         content=StaticFile(format("{postgresql_adduser_file}"))
    )

    cmd = format("bash -x {postgresql_adduser_path} {postgresql_daemon_name} {hive_metastore_user_name} {hive_metastore_user_passwd!p} {db_name}")

    Execute(cmd,
            tries=3,
            try_sleep=5,
            path='/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin'
    )
Example #2
0
    def stop(self, env):
        import params
        env.set_params(params)

        postgresql_service(
            postgresql_daemon_name=params.postgresql_daemon_name,
            action='stop')
Example #3
0
    def configure(self, env):
        import params
        env.set_params(params)

        # init the database, the ':' makes the command always return 0 in case the database has
        # already been initialized when the postgresql server colocates with ambari server
        Execute(format("service {postgresql_daemon_name} initdb || :"))

        # update the configuration files
        self.update_pghda_conf(env)
        self.update_postgresql_conf(env)

        # Reload the settings and start the postgresql server for the changes to take effect
        # Note: Don't restart the postgresql server because when Ambari server and the hive metastore on the same machine,
        # they will share the same postgresql server instance. Restarting the postgresql database may cause the ambari server database connection lost
        postgresql_service(
            postgresql_daemon_name=params.postgresql_daemon_name,
            action='reload')

        # ensure the postgresql server is started because the add hive metastore user requires the server is running.
        self.start(env)

        # create the database and hive_metastore_user
        File(params.postgresql_adduser_path,
             mode=0755,
             content=StaticFile(format("{postgresql_adduser_file}")))

        cmd = format(
            "bash -x {postgresql_adduser_path} {postgresql_daemon_name} {hive_metastore_user_name} {hive_metastore_user_passwd!p} {db_name}"
        )

        Execute(cmd,
                tries=3,
                try_sleep=5,
                path='/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin')
 def status(self, env):
   import status_params
   postgresql_service(postgresql_daemon_name=status_params.postgresql_daemon_name, action = 'status')
  def stop(self, env):
    import params
    env.set_params(params)

    postgresql_service(postgresql_daemon_name=params.postgresql_daemon_name, action = 'stop')
Example #6
0
 def status(self, env):
     import status_params
     postgresql_service(
         postgresql_daemon_name=status_params.postgresql_daemon_name,
         action='status')