我正在尝试在运行 Ubuntu 12.04LTS 的桌面上以伪分布式模式部署 HBase。
安装后,当我尝试通过以下方式启动 hbase-master 时:
sudo service hbase-master start
它说 JAVA_HOME
未找到。
但我确实在 /etc/profile
中配置了我的 JAVA_HOME
。
我在 google 上搜索,发现有人说 sudo service xxx start
正在使用 login shell
。 /etc/profile
中的变量不能用于登录 shell 吗?
我也试过从另一台电脑通过 ssh 登录,证明 /etc/profile
不工作:
ssh myuser@mypc 'echo $JAVA_HOME > /tmp/tmp.log'
在我发出上面的 ssh 命令后没有任何显示。
我还尝试在 ~/.bashrc
和 /root/.bashrc
中配置 JAVA_HOME
。它也不起作用。
但是我在hbase启动脚本中设置JAVA_HOME
后,hbase实例可以成功启动。这意味着 hbase 已正确安装在我的桌面上。所以问题一定出在环境配置上。
有人能告诉我我的环境配置有什么问题吗?谢谢。
最佳答案
根据 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.
这意味着您应该将 JAVA_HOME
设置放入 /etc/environment
或运行 sudo
作为 sudo -i ...
。
关于linux -/etc/profile 中的环境变量不适用于 Ubuntu 12.04LTS 上的 HBase,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22499879/