简体   繁体   中英

Environment variables in /etc/profile not work for HBase on Ubuntu 12.04LTS

I am trying to deploy HBase in pseudo-distributed mode on my desktop which is running Ubuntu 12.04LTS.

After installation, when I am trying to start hbase-master by:

sudo service hbase-master start

it says JAVA_HOME not found.

But I do have my JAVA_HOME configured in /etc/profile .

I searched on google and found somebody said that sudo service xxx start was using the login shell . Don't variables in /etc/profile work for login shell?

I also tried to login by ssh from another computer to prove /etc/profile not work:

ssh myuser@mypc 'echo $JAVA_HOME > /tmp/tmp.log'

Nothing showed up after I issued the ssh command above.

I also tried to configure JAVA_HOME in ~/.bashrc and /root/.bashrc . It didn't work neither.

But after I set JAVA_HOME in hbase startup script, hbase instance could be started successfully. Which means hbase is installed correctly on my desktop. So the problem must be in the environment configuration.

Could Anyone tell me what's wrong with my environment configuration? Thx.

According to sudoers(5)

By default, the env_reset option is enabled. This causes commands to beexecuted with a new, minimal environment. On AIX (and Linux systemswithout PAM), the environment is initialized with the contents of the/etc/environment file.

As a special case, if sudo's -i option (initial login) is specified,sudoers will initialize the environment regardless of the value ofenv_reset. The DISPLAY, PATH and TERM variables remain unchanged; HOME,MAIL, SHELL, USER, and LOGNAME are set based on the target user. On AIX(and Linux systems without PAM), the contents of /etc/environment arealso included.

This means you should put your JAVA_HOME setting in /etc/environment or run sudo as sudo -i ... .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM