Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Zookeeper >> mail # user >> Zookeeper run as non-root

Copy link to this message
Re: Zookeeper run as non-root
W dniu 14.08.2012 23:02, Matthew Sims pisze:
> Hello, we're just starting to implement a Zookeeper where I work on a Red
> Hat system.
> We've set everything up and it starts up just fine. The only issue is that
> the process is run by the root user.
> sudo /etc/init.d/zookeeper start
> I have a zookeeper user ready to go. The init script we have makes a java
> call to start up the process.
> start)
>      echo  -n "Starting zookeeper ... "
>      if [ -f $ZOOPIDFILE ]; then
>        if kill -0 `cat $ZOOPIDFILE` > /dev/null 2>&1; then
>           echo $command already running as process `cat $ZOOPIDFILE`.
>           exit 0
>        fi
>      fi
>      nohup $JAVA "-Dzookeeper.log.dir=${ZOO_LOG_DIR}"
> "-Dzookeeper.root.logger=${ZOO_LOG4J_PROP}" \
> 2>&1 < /dev/null &
>      if [ $? -eq 0 ]
>      then
>        if /bin/echo -n $! > "$ZOOPIDFILE"
>        then
>          sleep 1
>          echo STARTED
>        else
>          echo FAILED TO WRITE PID
>          exit 1
>        fi
>      else
>        echo SERVER DID NOT START
>        exit 1
>      fi
>      ;;
> I've looked in to editing this script, including /etc/init.d/functions and
> calling the daemon function to run the start as user zookeeper. But this
> forks the process and the PID file is updated with the daemon process, not
> the zookeeper process. This causes the stop feature to fail.
> Before I go about re-writing this init script, I figure someone else must
> have a proper way of starting this up as a non-root user.
I run ZooKeeper on Centos 6 (which is a clone of Red Hat Enterprise
Linux 6).  I use upstart to manage the ZooKeeper service. In the upstart
job configuration I have an exec stanza:

exec su -c "/usr/java/default/bin/java [-D this, -D that etc.]
org.apache.zookeeper.server.quorum.QuorumPeerMain /etc/zookeeper/z
oo.cfg" zookeeper

In newer upstart version than what's available in RHEL 6 there's a
"setuid" stanza, which is as an straightforward solution to this problem
as can be.

Best regards,

Tadeusz Andrzej Kadłubowski
Dział Rozwoju Technologii
Wirtualna Polska S.A.

"WIRTUALNA POLSKA" Spolka Akcyjna z siedziba w Gdansku przy ul. Traugutta 115 C, wpisana do Krajowego Rejestru Sadowego - Rejestru Przedsiebiorcow prowadzonego przez Sad Rejonowy Gdansk - Polnoc w Gdansku pod numerem KRS 0000068548, o kapitale zakladowym 67.980.024,00 zlotych oplaconym w calosci oraz Numerze Identyfikacji Podatkowej 957-07-51-216.