ambari-server开机启动失败原因定位

在CentOS7.2环境下,AMBARI-2.4.0.1开机自启动失败,原因是启动脚本存在问题。问题源于$ROOT变量设置错误,导致脚本执行的路径不正确。解决方案是修正AMBARI_PYTHON_EXECUTABLE和AMBARI_EXECUTABLE的路径,并将$ROOT的取值设为空字符串。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

使用的ambari版本为AMBARI-2.4.0.1
环境为centos7.2

问题:安装完ambari-server之后,开机自启动失败
原因:ambari-server的启动脚本有问题

1、开机启动脚本一般在/etc/rc.d/init.d目录下

在这里插入图片描述

2、不同的开机启动级别,启动脚本的范围不一样

在这里插入图片描述
开机启动级别:
运行级别0:系统停机状态,系统默认运行级别不能设为0,否则不能正常启动,对应的启动脚本目录rc0.d
运行级别1:单用户工作状态,root权限,用于系统维护,禁止远程登陆,对应的启动脚本目录rc1.d
运行级别2:多用户状态(没有NFS),对应的启动脚本目录rc2.d
运行级别3:完全的多用户状态(有NFS),登陆后进入控制台命令行模式,对应的启动脚本目录rc3.d
运行级别4:系统未使用,保留,对应的启动脚本目录rc4.d
运行级别5:X11控制台,登陆后进入图形GUI模式,对应的启动脚本目录rc5.d
运行级别6:系统正常关闭并重启,默认运行级别不能设为6,否则不能正常启动,对应的启动脚本目录rc6.d

开机的时候,如果开机启动级别是3(最常用),那么就执行rc3.d下面的脚本
在这里插入图片描述
可以看到,rc3.d下面的脚本实际上是/etc/rc.d/init.d目录下脚本的软连接,相当于执行的是/etc/rc.d/init.d里面的脚本。

3、手动执行ambari-server开机启动脚本,打印调试信息

[root@brms01 rc3.d]# pwd
/etc/rc.d/rc3.d
[root@brms01 rc3.d]# sh -x S95ambari-server 
+ VERSION=2.4.0.1-1
+ HASH=8c0e2bdc031b1a36bd90753210313951f5178a93
+ case "$1" in
+++ dirname S95ambari-server
++ cd .
++ pwd
+ SCRIPT_DIR=/etc/rc.d/rc3.d
+++ dirname /etc/rc.d/rc3.d
++ dirname /etc/rc.d
+ export ROOT=/etc
+ ROOT=/etc
++ echo /etc
++ sed 's/\/$//'
+ ROOT=/etc
+ export 'PATH=/etc/usr/lib/ambari-server/*:/usr/local/openssl/bin:/usr/jdk1.8.0_91/bin:/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/oracle/112/client/bin:/root/bin:/root/bin:/sbin/:/usr/sbin'
+ PATH='/etc/usr/lib/ambari-server/*:/usr/local/openssl/bin:/usr/jdk1.8.0_91/bin:/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/oracle/112/client/bin:/root/bin:/root/bin:/sbin/:/usr/sbin'
+ export AMBARI_CONF_DIR=/etc/etc/ambari-server/conf
+ AMBARI_CONF_DIR=/etc/etc/ambari-server/conf
+ PYTHON_WRAP=/etc/usr/bin/ambari-python-wrap
+ AMBARI_ENV=/etc/var/lib/ambari-server/ambari-env.sh
+ AMBARI_PYTHON_EXECUTABLE=/etc/usr/sbin/ambari-server.py
+ AMBARI_EXECUTABLE=/etc/usr/sbin/ambari-server
+ '[' -z '' ']'
++ readlink /etc/usr/bin/ambari-python-wrap
+ export PYTHON=
+ PYTHON=
+ '[' -a /etc/var/lib/ambari-server/ambari-env.sh ']'
+ '[' -z '' ']'
+ AMBARI_PASSPHRASE=DEV
+ '[' -n /usr/jdk1.8.0_91 ']'
+ export JAVA_HOME=/usr/jdk1.8.0_91
+ JAVA_HOME=/usr/jdk1.8.0_91
+ export AMBARI_PASSPHRASE=DEV
+ AMBARI_PASSPHRASE=DEV
++ -V
++ awk '{print $2}'
++ cut -d. -f1
+ majversion=line
++ -V
++ awk '{print $2}'
++ cut -d. -f2
+ minversion=line
+ numversion=0
+ ((  0 < 26  ))
+ echo 'Need python version > 2.6'
Need python version > 2.6
+ exit 1

在这里插入图片描述
可以看到这几个目录和文件的路径其实是错误的

根源是脚本中$ROOT的取值是错误的,看如下的脚本中,在启动、停止、重启ambari-server时,使用的是脚本

  • AMBARI_PYTHON_EXECUTABLE=/etc/usr/sbin/ambari-server.py
  • AMBARI_EXECUTABLE=/etc/usr/sbin/ambari-server

明显是错误的,正确的应该是:

  • AMBARI_PYTHON_EXECUTABLE=/usr/sbin/ambari-server.py
  • AMBARI_EXECUTABLE=/usr/sbin/ambari-server

原始的脚本:

#!/usr/bin/env bash
# chkconfig: 345 95 20
# description: ambari-server daemon
# processname: ambari-server

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

### BEGIN INIT INFO
# Provides:          ambari-server
# Required-Start:
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      0 6
### END INIT INFO

# /etc/init.d/ambari-server

VERSION="2.4.0.1-1"
HASH="8c0e2bdc031b1a36bd90753210313951f5178a93"

case "$1" in
  --version)
        echo -e $VERSION
        exit 0
        ;;
  --hash)
        echo -e $HASH
        exit 0
        ;;
esac

SCRIPT_DIR="$( cd "$( dirname "${
     
     BASH_SOURCE[0]}" )" && pwd )"
export ROOT=`dirname $(dirname $SCRIPT_DIR)`
ROOT=
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值