Red Hat Training

A Red Hat training course is available for Red Hat JBoss Operations Network

2.4. JBoss ON サーバーの起動

JBoss ON サーバーは JBoss ON インストールに含まれるカスタマイズされた JBoss AS サーバーであるため、JBoss ON サーバーを起動すると JBoss インスタンスが起動します。
JBoss ON サーバーは手作業で起動することも、システムサービスとして起動および実行するように設定することもできます。

2.4.1. JBoss ON Server(Basic)の起動

JBoss ON サーバープロセスは、serverRoot/bin/ ディレクトリーで rhqctl スクリプトを実行して開始 ます。
重要
JBoss ON サーバーは、コマンドラインまたは UI のリソース操作(他の EAP リソースとは異なり) から 起動または再起動できません。あるサーバーの JBoss ON UI または CLI を使用して、クラウドで別の JBoss ON サーバーを起動できますが、起動操作または再起動操作を実行できません。
サーバーを起動する最も簡単な方法は、start コマンドでスクリプトを実行することです。これにより、サーバープロセスが開始され、スクリプトから終了します。
serverRoot/bin/rhqctl start --server
Trying to start the RHQ Server...
RHQ Server (pid 27547) is starting
rhqctl スクリプトは実行中、JBoss EAP サーバーインスタンスで使用する JVM に関連する特定の環境変数を検索します。環境変数の完全なリストはスクリプト自体で指定されています。インストール情報に基づくデフォルトが使用されるため、ほとんどの環境変数をリセットする必要はありません。
注記
The RHQ_JAVA_HOME サーバーを起動するには、Red Hat Enterprise Linux システムで環境変数を設定する必要があります。これは、のように一般的な値に設定でき /usr/ます。
サーバーをコンソールモードで起動することもできます。これは、サーバープロセスに関する詳細情報をターミナルにプリントし、サーバーが実行されている限り、スクリプトを開いたままにします。
[root@server ~]# ./rhqctl console --server
20:28:44,120 INFO  [org.jboss.modules] JBoss Modules version 1.2.2.Final-redhat-1
Starting RHQ Server in console...
JAVA_OPTS already set in environment; overriding default settings with values: -
....

2.4.2. JBoss ON Server をサービスとして実行

以下の例を使用して、JBoss ON サーバー、ストレージノード、およびエージェントを Red Hat Enterprise Linux で SysV スタイルの init サービスとして管理し、実行できます。
  1. initalization scipt を作成し /etc/init.d/jboss-onます。
    #!/bin/sh
    #
    # Example Red Hat JBoss Operations Network init script
    #
    # chkconfig: - 95 20
    # description: Red Hat JBoss Operations Network rhqctl services
    # processname: standalone.sh
    #
    #
    # This is an example script that can be used with a SysV style 
    # init service which starts a JBoss ON server, storage node, and 
    # agent using the rhqctl script provided by the JBoss ON server 
    # installation.
    
    prog="`basename "$0"`"
    
    # If available, the following files will be sourced, in order, for 
    # configuration. This means that if the same value is defined in a later
    # file, it will override the one specified in an earlier one:
    #
    #   /etc/jboss-on.conf
    #   /etc/jboss-on/${prog}.conf
    #
    # The following environment variables can be defined:
    # 
    #   RHQ_HOME -- Defaults to /opt/jboss/jboss-on
    #   RHQ_SERVER_HOME -- Defaults to RHQ_HOME/jon-server-*
    #   RHQ_AGENT_HOME -- Defaults to RHQ_HOME/rhq-agent
    #   RHQ_JAVA_HOME -- Defaults to /usr
    #   RHQ_USER -- Defaults to jonadmin
    #
    
    # If available, source environment variables for the service
    # Global defaults/settings
    [ -r "/etc/jboss-on.conf" ] && . "/etc/jboss-on.conf"
    # Settings specific to this service
    [ -r "/etc/jboss-on/${prog}.conf" ] && . "/etc/jboss-on/${prog}.conf"
    
    # If not yet set, use some reasonable defaults:
    [ -z "${RHQ_HOME}" ] && RHQ_HOME='/opt/jboss/jboss-on'
    [ -z "${RHQ_SERVER_HOME}" ] && RHQ_SERVER_HOME="`eval echo "${RHQ_HOME}/jon-server-"*`"
    [ -z "${RHQ_AGENT_HOME}" ] && RHQ_AGENT_HOME="${RHQ_HOME}"'/rhq-agent'
    [ -z "${RHQ_JAVA_HOME}" ] && RHQ_JAVA_HOME='/usr'
    [ -z "${RHQ_USER}" ] && RHQ_USER=jonadmin
    
    # We have to export these variables so that they are available to child
    # processes.
    export RHQ_SERVER_HOME
    export RHQ_AGENT_HOME
    export RHQ_JAVA_HOME
    
    
    # This is a convenient function that invokes rhqctl
    rhqctl() {
    	RHQCTL_SCRIPT="${RHQ_SERVER_HOME}/bin/rhqctl"
    	[ ! -x "${RHQCTL_SCRIPT}" ] && {
    			echo >&2 "${RHQCTL_SCRIPT}"' was not found or is not executable.'
    			exit 2
    	}
    	if [ -n "${RHQ_USER}" -a "$(whoami)" != "${RHQ_USER}" ]; then
    			CMD="su -m ${RHQ_USER} -c '\"${RHQCTL_SCRIPT}\" $@'"
    	else
    			CMD="\"${RHQCTL_SCRIPT}\" $@"
    	fi
    	eval ${CMD}
    }
    
    # We invoke rhqctl differently if start or stop is used so we need this
    # case statement to determine what should happen.
    case "$1" in
    start)
    	# Because rhqctl is so chatty/verbose we redirect standard output to
    	# null so we do not see it during system start and stop.
    	# Additionally, we invoke it in the background as it can block for 
    	# some time during start.
    	rhqctl "$@" >/dev/null &
    	;;
    stop)
    	# Because rhqctl is so chatty/verbose we redirect standard output to
    	# null so we do not see it during system start and stop.
    	rhqctl "$@" >/dev/null
    	;;
    *)
    	# Assuming we are not starting or stopping, we will display complete
    	# output.
    	rhqctl "$@"
    	;;
    esac
    
  2. ファイルに対する権限を変更し、以下を実行します。
    sudo chmod +x /etc/init.d/jboss-on
  3. initalization スクリプトを chkconfig に追加します。
    sudo chkconfig --add /etc/init.d/jboss-on
  4. スクリプトがシステムの起動およびシャットダウン時に停止することを意図していることを示します。
    sudo chkconfig jboss-on on
  5. 、、RHQ_HOME、およびのデフォルト値を上書きするには RHQ_SERVER_HOME、、RHQ_USERRHQ_AGENT_HOME RHQ_JAVA_HOME および、/etc/jboss-on.conf または特定の値 /etc/jboss-on/<SERVICE NAME>.conf でサービス設定ファイルを作成します。
    RHQ_HOME=/usr/share/jboss-on
    RHQ_USER=jbosson