1.切换到hadoop用户执行启动脚本:/usr/bin/sudo -u hadoop -i hadoop-daemon.sh stop namenode
2./etc/monitrc里追加
check process hadoop with pidfile "/usr/local/hadoop/pids/hadoop-hadoop-namenode.pid" ##注意红色字
start program = "/usr/bin/sudo -u hadoop -i hadoop-daemon.sh start namenode" ##下面这2行是启动和停止脚本。
stop program = "/usr/bin/sudo -u hadoop -i hadoop-daemon.sh stop namenode"
主要涉及到sudo的用法切换到特定用户执行命令。
-s [command]
The -s (shell) option runs the shell specified by the SHELL environment variable if it is set or the shell as specified in
passwd(5). If a command is specified, it is passed to the shell for execution. Otherwise, an interactive shell is executed.
大意是指定shell 环境。但不会引用用户的环境变量。
-i [command]
The -i (simulate initial login) option runs the shell specified in the passwd(5) entry of the target user as a login shell. This
means that login-specific resource files such as .profile or .login will be read by the shell. If a command is specified, it is
passed to the shell for execution. Otherwise, an interactive shell is executed. sudo attempts to change to that user鈥檚 home
directory before running the shell. It also initializes the environment, leaving DISPLAY and TERM unchanged, setting HOME, MAIL,
SHELL, USER, LOGNAME, and PATH, as well as the contents of /etc/environment on Linux and AIX systems. All other environment
variables are removed.
这个参数会引用用户的.bashrc.
阅读(585) | 评论(0) | 转发(0) |