From user-return-11556-archive-asf-public=cust-asf.ponee.io@zookeeper.apache.org Mon Jul 16 13:49:35 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id D0E2E180657 for ; Mon, 16 Jul 2018 13:49:34 +0200 (CEST) Received: (qmail 33124 invoked by uid 500); 16 Jul 2018 11:49:33 -0000 Mailing-List: contact user-help@zookeeper.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@zookeeper.apache.org Delivered-To: mailing list user@zookeeper.apache.org Received: (qmail 33112 invoked by uid 99); 16 Jul 2018 11:49:32 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 16 Jul 2018 11:49:32 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 7C47C1A3E98 for ; Mon, 16 Jul 2018 11:49:32 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.898 X-Spam-Level: * X-Spam-Status: No, score=1.898 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=cloudera.com Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id Hnify0KSDVKJ for ; Mon, 16 Jul 2018 11:49:30 +0000 (UTC) Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id AA58E5F3BC for ; Mon, 16 Jul 2018 11:49:29 +0000 (UTC) Received: by mail-pg1-f172.google.com with SMTP id x5-v6so7399023pgp.7 for ; Mon, 16 Jul 2018 04:49:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=BEhQ3OXEcpyEIQauQRI9bhq35488vh4o5+s9wxoA9YE=; b=UilT9omdhlSCf/V7dId44yXoHynS12kMRNJ5imDCNPEl3qYHW+V5i9mVXr+39ZOjwY rLOBXdwfsFkI5HRzgqPGvePR6r3bgEngTt2xDoFVoUmDCE6sSHgeEMx9JzIRFKaPDkYB CiyqLleGEMA6xmd2yo0Fa7QYnK0LZF1cnWeclZ15NAxwwnSx3v3Z4VJs1hfPAnCBMQ0f iX/KabG93RE7lRyhXTmt/LXLMO/insawe1bgjwrHSuRO+9m7XiMiaS+4ucac5kHVoyF5 N2R9njnyy4qm5iSbQvkC08wG8ZYJe/4CLRXxQ04aa+Wt+3IGyKC1oXtyC3alNEkQRahn BgAQ== X-Gm-Message-State: AOUpUlEmlPsmmM6SDVRQ+AZiTbxWczth+5c/qPYJGGThZ78QaagjlJwx iXrcGeK5viCbEhQF3gSqcpPpjtyRmd7Us5YQBGjqgbhN X-Google-Smtp-Source: AAOMgpe3A8VoMuKxXOD0MJsZzcJwxtHD7ItaB2M6KU79uXdlX8rhHFnQcOsqMr7cMzFy3inj0i/FjaZCXa0avXHInm4= X-Received: by 2002:a63:8648:: with SMTP id x69-v6mr15196026pgd.172.1531741768010; Mon, 16 Jul 2018 04:49:28 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Norbert Kalmar Date: Mon, 16 Jul 2018 13:49:16 +0200 Message-ID: Subject: Re: zookeeper as systemd To: user@zookeeper.apache.org Content-Type: multipart/alternative; boundary="000000000000f86ea205711c6b25" --000000000000f86ea205711c6b25 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable The type is Linux config, and forking is used when we want the process to call fork() during startup. This should guarantee that when startup is finished, all ports are open. In my understanding, using FORKING will tell systemd the startup is complete and ports are open. See https://www.freedesktop.org/software/systemd/man/systemd.service.html for more information. TYPE=3Dsimple is mainly for daemons that don't use network channels, or the= y have their own socket activation. So in my opinion, TYPE=3Dforking is better for ZK. But! Forking should require a PIDfile in order for it to work properly... but since systemd is used, it should know the PID as it is a supervisor. I'm also lost here a bit... Looking at ZK PID file should be available: ZOOPIDFILE=3D"$ZOO_DATADIR/zookeeper_server.pid" About the simple start or start-foreground... I think I was quick to say only use simple start in prod environment. This is much more complicated, for example start-foreground would just make it ignore nohup. Doing some search, these 2 questions might help: https://stackoverflow.com/questions/40620544/systemd-zookeeper-service-fail= ed https://askubuntu.com/questions/979498/how-to-start-a-zookeeper-daemon-afte= r-booting-under-specific-user-in-ubuntu-serv Putting this all together, I think if you don't really care when socket is ready, just use TYPE=3Dsimple and call with start-foreground. Regards, Norbert On Mon, Jul 16, 2018 at 11:48 AM adrien ruffie wrote: > Thank Nobert ! > > > It really help me, > > > according to you, what would you recommend? > > > To launch with "Type=3Dsimple" and zkServer.sh start ? > > Or "Type=3Dforking" and zkServer.sh start ? > > > Because start command launch Zookeeper as a Daemon, > > but if I use "Type=3Dsimple" the system already daemonize the process ... > > Do you think that can be daemonize a daemon ... ? Strange > > > I really ready to use "Type=3Dforking" option but, according to this > following post > > > https://bbs.archlinux.org/viewtopic.php?id=3D191669 > > > the "Type=3Dforking" is not really recommended ... > > what do you think ? > > > Adrien > > > ________________________________ > De : Norbert Kalmar > Envoy=C3=A9 : lundi 16 juillet 2018 10:15 > =C3=80 : user@zookeeper.apache.org > Objet : Re: zookeeper as systemd > > Hi Adrien, > > zkServer.sh start-foreground - starts the ZooKeeper process in the > foreground. Good for debugging (thats what I use it for), or check > something, as you will have the logs printed to standard output (console > most probably). > The "start" is what you want to use in production environment. the proces= s > will run in the background. > > ' What is "After=3Dnetwork.target" ? ' - ZooKeeper should only start a= fter > the network... available? I think this should be something like > After=3Dnetwork-online.target > > But looking at the others, I'm not entirely sure either what they really > do. But checko out this jira - > https://issues.apache.org/jira/browse/ZOOKEEPER-2095 > > There was a patch about this, and they added systemd startup/conf files. > > Sorry, this is all I could come up with, as I'm not familiar with this pa= rt > either. Hope it helps. > > Regards, > Norbert > > > On Fri, Jul 13, 2018 at 5:30 PM adrien ruffie > wrote: > > > Hello Zookeeper's users, > > > > > > I have 2 questions for you. > > > > > > what is the real difference between these 2 following commands ? (I don= 't > > find any documentation) > > > > > > zkServer.sh start-foreground > > > > and > > > > zkServer.sh start > > > > > > > > My second question is, how I can correctly start my zookeeper as a > > systemclt service ? > > > > What is the common best template to write into > > /etc/systemd/system/zookeeper.service ? > > > > Do you use Restart=3Dalways ? RestartSec=3D0s ? > > > > What is "After=3Dnetwork.target" ? > > > > If my Zookeeper does not really start in 300 sec, the process will be > > shutdown ? > > > > > > Do you have any example of zookeeper service file ? > > > > > > Because our zookeeper.service is right now: > > > > > > [Unit] > > Description=3DZooKeeper > > > > [Service] > > Type=3Dsimple > > User=3Dzookeeper > > Group=3Dzookeeper > > ExecStart=3D/usr/local/zookeeper-3.4.9/bin/zkServer.sh start-foreground > > > > TimeoutSec=3D300 > > > > [Install] > > WantedBy=3Dmulti-user.target > > > > ------------------- But I found this following on a blog: > > > > > > [Unit] > > Description=3DApache Zookeeper > > After=3Dnetwork.target > > > > [Service] > > Type=3Dforking > > User=3Dzookeeper > > Group=3Dzookeeper > > SyslogIdentifier=3Dzookeeper > > Restart=3Dalways > > RestartSec=3D0s > > ExecStart=3D/usr/bin/zookeeper-server start > > ExecStop=3D/usr/bin/zookeeper-server stop > > ExecReload=3D/usr/bin/zookeeper-server restart > > > > [Install] > > WantedBy=3Dmulti-user.target > > > > > > Thank you very much and best regards > > > > Adrien > > > --000000000000f86ea205711c6b25--