linux -/etc/profile 中的环境变量不适用于 Ubuntu 12.04LTS 上的 HBase

标签 linux shell ubuntu ssh hbase

我正在尝试在运行 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/

相关文章:

android - 使用 adb 卸载多个 android 包

Bash 'for' 循环语法?

linux - shell脚本阻塞进程

ubuntu - 要求 aspell 跳过部分文档

php - Apache 使用 http 和 https 设置多个域

regex - 当扩展正则表达式 (ERE) 选项与 sed 一起使用时,为什么美元不匹配文字美元?

c - 在 C 中删除 Linux 信号处理程序

java - 通过 wget 在 Linux 上下载 Java JDK 会显示许可证页面

Linux命令/脚本替换文件夹/目录

linux - 如何让我的 Asterisk 服务器调用出站电话和接收入站电话