Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

how to auto start zookeeper when machine is restart

avatar
Explorer

how to auto start zookeeper when machine is restart

i can't auto start use zookeeper when ambari-server is 2.5.1.0

thanks. the DB is postgresql

11 REPLIES 11

avatar
Explorer

avatar
Master Mentor

@qiancai zhou

In Ambari 2.5 it is very easy to achieve the Zookeeper or other component auto restart setting from UI itself.

Admin UI --> Admin (Drop Down) --> Service Auto Start

17491-auto-start-zookeeper.png

.

avatar
Explorer

yes i set it ,but can't auto start ..

avatar
Master Mentor

@qiancai zhou

Enabling auto-start for a service causes the ambari-agent to attempt re-starting service components in a stopped state without manual effort by a user. Auto-Start Services is enabled by default, butonlythe Ambari Metrics Collector component is set to auto-start by default. Reference: https://docs.hortonworks.com/HDPDocuments/Ambari-2.5.0.3/bk_ambari-operations/content/ch07s04.html

- So if the auto start is not happening (evev after enabling the "Zookeeper Server " AutoStart Enabled button then you should see some messages in the "/var/log/ambari-agent.log" file because it is agents responsibility to do that.

Please share the ""/var/log/ambari-agent.log" file with us. Also please share the zookeeper Log file.

.

avatar
Explorer

i see the zookeeper.log,nothing in it .

the ambari-agent.log is update.

in ambari-agent.log only hts_server status is startd the other is installed.

thanks.ambari-agent.zip

avatar
Explorer
@Jay SenSharma

in the web api

http://test.test:8080/api/v1/clusters/testtest/components/ZOOKEEPER_SERVER

{
  "href" : "http://test.test:8080/api/v1/clusters/testtest/components/ZOOKEEPER_SERVER",
  "ServiceComponentInfo" : {
    "category" : "MASTER",
    "cluster_name" : "testtest",
    "component_name" : "ZOOKEEPER_SERVER",
    "display_name" : "ZooKeeper Server",
    "init_count" : 0,
    "install_failed_count" : 0,
    "installed_count" : 1,
    "recovery_enabled" : "true",
    "service_name" : "ZOOKEEPER",
    "started_count" : 0,
    "state" : "INSTALLED",
    "total_count" : 1,
    "unknown_count" : 0
  },
  "host_components" : [
    {
      "href" : "http://test.test:8080/api/v1/clusters/testtest/hosts/test.test/host_components/ZOOKEEPER_SERVER",
      "HostRoles" : {
        "cluster_name" : "testtest",
        "component_name" : "ZOOKEEPER_SERVER",
        "host_name" : "test.test"
      }
    }
  ]
}

avatar
Master Mentor

@qiancai zhou

Are you Manually stopping (gracefully) the Zookeeper? (In this case ambari will assume normal scenario)

You need to kill (Crash it) the Zookeeper Server to test this feature and then see you get the following kind of output:

# ambari-agent  --version
2.5.1.0

# kill -9 `cat /var/run/zookeeper/zookeeper_server.pid`

.

ambari-agent.log

INFO 2017-06-23 07:15:24,216 RecoveryManager.py:185 - current status is set to INSTALLED for ZOOKEEPER_SERVER
INFO 2017-06-23 07:15:24,216 RecoveryManager.py:255 - ZOOKEEPER_SERVER needs recovery, desired = STARTED, and current = INSTALLED.
INFO 2017-06-23 07:15:29,197 RecoveryManager.py:255 - ZOOKEEPER_SERVER needs recovery, desired = STARTED, and current = INSTALLED.
INFO 2017-06-23 07:15:29,198 RecoveryManager.py:834 - START command cannot be computed as details are not received from Server.
.
.
INFO 2017-06-23 07:15:39,572 RecoveryManager.py:255 - ZOOKEEPER_SERVER needs recovery, desired = STARTED, and current = INSTALLED.
INFO 2017-06-23 07:15:39,572 RecoveryManager.py:834 - START command cannot be computed as details are not received from Server.
INFO 2017-06-23 07:15:50,463 RecoveryManager.py:255 - ZOOKEEPER_SERVER needs recovery, desired = STARTED, and current = INSTALLED.
INFO 2017-06-23 07:15:50,463 RecoveryManager.py:834 - START command cannot be computed as details are not received from Server.
INFO 2017-06-23 07:16:01,346 RecoveryManager.py:255 - ZOOKEEPER_SERVER needs recovery, desired = STARTED, and current = INSTALLED.
INFO 2017-06-23 07:16:01,346 RecoveryManager.py:834 - START command cannot be computed as details are not received from Server.
INFO 2017-06-23 07:16:21,789 Controller.py:258 - Adding 20 status commands. Heartbeat id = 1282597
.
.
.
INFO 2017-06-23 07:16:23,510 Controller.py:407 - Adding recovery command START for component ZOOKEEPER_SERVER
INFO 2017-06-23 07:16:23,511 Controller.py:249 - Adding 1 commands. Heartbeat id = 1282598
INFO 2017-06-23 07:16:23,511 ActionQueue.py:113 - Adding AUTO_EXECUTION_COMMAND for role ZOOKEEPER_SERVER for service ZOOKEEPER of cluster plain_ambari to the queue.
INFO 2017-06-23 07:16:23,715 RecoveryManager.py:255 - ZOOKEEPER_SERVER needs recovery, desired = STARTED, and current = INSTALLED.
INFO 2017-06-23 07:16:23,891 ActionQueue.py:238 - Executing command with id = 1-0, taskId = 1497010157 for role = ZOOKEEPER_SERVER of cluster plain_ambari.
INFO 2017-06-23 07:16:23,892 ActionQueue.py:279 - Command execution metadata - taskId = 1497010157, retry enabled = False, max retry duration (sec) = 0, log_output = True
INFO 2017-06-23 07:16:26,078 ActionQueue.py:324 - Quit retrying for command with taskId = 1497010157. Status: COMPLETED, retryAble: False, retryDuration (sec): -1, last delay (sec): 1
INFO 2017-06-23 07:16:26,078 ActionQueue.py:339 - Command with taskId = 1497010157 completed successfully!
INFO 2017-06-23 07:16:26,079 RecoveryManager.py:185 - current status is set to STARTED for ZOOKEEPER_SERVER
INFO 2017-06-23 07:16:26,080 ActionQueue.py:390 - After EXECUTION_COMMAND (START), with taskId=1497010157, current state of ZOOKEEPER_SERVER to STARTED

.

avatar
Explorer

@Jay SenSharma

yes , i stop zookeeper by ambari-server and not start ?

when this can't auto start when system boot ?

need start zookeeper with ambari-server and kill it and restart machine?

avatar
Master Mentor

@qiancai zhou

Its a crash recovery feature. So if you gracefully stop the zookeeper process ambari should not attempt to restart it.

Try this to test this feature.

1. Start the Zookeeper Server Process.

2. Now suddenly kill the Zookeeper Server ( this is just to simulate an abroup zookeeper termination, in real time process can get crash due to various other reasons as well).

# kill -9 `cat /var/run/zookeeper/zookeeper_server.pid`

3. Now check the ambari agent logs.

you will notice that within 2-3 minutes your Zookeeper process will be restarted.