WEB2014. 8. 5. 14:00

OHS 12c 버전은 11g 버전에서 사용하던 opmn이 아닌 nodemanager를 이용한 구동으로 변경 되었다.

11g에서 opmn데몬이 구동되어서 관리되었던 것이 12c로 넘어오면서 nodemanager로 바뀐것이다.

따라서 상태를 확인하는 방법 또한 nodemanager를 통해서 확인이 가능하다 .

그럼 어떻게 OHS 상태를 확인 할 수 있는지 알아보자.

 

1. WLST 구문을 사용하여 확인 하는 방법

 

wlst 스크립트를 실행한다.

[DIT:weblogic:ohs12130] /OFM/ohs/ohs12130/oracle_common/common/bin>./wlst.sh

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

wls:/offline>

 

nodemanager로 접속한다.

wls:/offline> nmConnect('weblogic','welcome1','localhost','5556','base_domain')

Connecting to Node Manager ...
Successfully Connected to Node Manager.

 

OHS 상태 확인 쿼리를 실행한다.

wls:/nm/base_domain> nmServerStatus(serverName='ohs1', serverType='OHS')

RUNNING

 

WLS CLI 종료

wls:/nm/base_domain> exit()

 

 

2. 스크립트를 이용하여 OHS 상태 확인하기

 

status.sh 스크립트 작성

#!/bin/sh

# --- Start Functions ---

usage()
{
        echo "Usage: $1 COMPONENT_NAME "
        echo "Where:"
        echo "  COMPONENT_NAME  - Required. System Component name"
        echo "  showErrorStack - Optional. Show error stack if provided."
}

# --- End Functions ---

if [ "$1" = "" ] ; then
        usage $0
        exit
else
        componentName="$1"
        export componentName
        shift
fi

if [ "$1" = "showErrorStack" ] ; then
        showErrorStack="true"
        export showErrorStack
else
        showErrorStack="false"
        export showErrorStack
fi

WL_HOME="/OFM/ohs/ohs12130/wlserver"

DOMAIN_HOME="/OFM/ohs/ohs12130/domains/base_domain"
 
umask 027


if [ "${showErrorStack}" = "false" ] ; then
        echo "try:" >"status.py"
        echo "  componentName = java.lang.System.getenv('componentName')" >>"status.py"
        echo "  nmConnect('weblogic','welcome1','localhost','5556','base_domain')">>"status.py"
        echo "  nmServerStatus('${componentName}',serverType='OHS')" >>"status.py"
        echo "  exit()" >>"status.py"
        echo "except Exception,e:" >>"status.py"
        echo "  print 'Error:', sys.exc_info()[1]" >>"status.py"
        echo "  exit(exitcode=1)" >>"status.py"
else
        echo "componentName = java.lang.System.getenv('componentName')" >"status.py"
        echo "stopComponentInternal('${componentName}', r'${DOMAIN_HOME}')" >>"status.py"
        echo "exit()" >>"status.py"
fi

echo "Showing Status of System Component ${componentName} ..."

# Using WLST...

${WL_HOME}/../oracle_common/common/bin/wlst.sh -i status.py  2>&1

if [ $? -ne 0 ] ; then
        exit 1
fi
if [ -f status.py ] ; then
        rm -f status.py
fi


echo "Done"

exit


WL_HOME, DOMAIN_HOME, 그리고 nodemanager에 접속하기 위한 기타 정보에 대해 변경한다.

 

스크립트를 만들었으니 실행해보자~


[DIT:weblogic:ohs12130] /OFM/ohs/ohs12130/domains/base_domain/bin>./status.sh ohs1
Showing Status of System Component ohs1 ...

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

Connecting to Node Manager ...
Successfully Connected to Node Manager.

RUNNING

 

Exiting WebLogic Scripting Tool.

Done

 

OHS 상태는 "RUNNING" 상태임을 확인 할 수 있다.

 


 


 

추가적으로 Oracle Support 문서 내용...

Report Status of a OHS Instance When Running on a Standalone Environment on FMW 12.1.2 (문서 ID 1663240.1)


Applies to: 
Oracle HTTP Server - Version 12.1.2.0.0 and later
Information in this document applies to any platform.


Goal

To provide methods to display the status of a OHS instance installed in standalone mode.


Solution

As the 12c environment employs WLS node manager to control the OHS instance it's possible to use the WLST (WebLogic Scripting Tool) to find out the status of OHS.


Method 1 interactive - We can employ standard WLST syntax

1. Run the wlst.sh shell script

${WL_HOME}/../oracle_common/common/bin/wlst.sh

2. At the resulting wls/offline prompt run each command in turn:

nmConnect('weblogic','<password>','localhost','<node_manager_port>','base_domain')

3. Query the status of the OHS server with:

nmServerStatus(serverName='<ohs_name>', serverType='OHS')

4. To quit the WLST cli run

exit()


Example session where the node manager is running on port 5557:

oracle$ export WL_HOME=/opt/oracle/12c/wlserver
oracle$ ${WL_HOME}/../oracle_common/common/bin/wlst.sh

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

wls:/offline> nmConnect('weblogic','welcome1','localhost','5557','base_domain')
Connecting to Node Manager ...
Successfully Connected to Node Manager.
wls:/nm/base_domain> nmServerStatus(serverName='ohs1', serverType='OHS')

RUNNING

wls:/nm/base_domain> exit()

oracle$



Method 2.

An alternative is given below using a simple script. The sample script given is not supported as part of 12c and supplied "as-is".


1. Create a simple shell script with a standard name, e.g status.sh.

 #!/bin/sh

# --- Start Functions ---

usage()
{
        echo "Usage: $1 COMPONENT_NAME "
        echo "Where:"
        echo "  COMPONENT_NAME  - Required. System Component name"
        echo "  showErrorStack - Optional. Show error stack if provided."
}

# --- End Functions ---

if [ "$1" = "" ] ; then
        usage $0
        exit
else
        componentName="$1"
        export componentName
        shift
fi

if [ "$1" = "showErrorStack" ] ; then
        showErrorStack="true"
        export showErrorStack
else
        showErrorStack="false"
        export showErrorStack
fi

WL_HOME="<set_this>"

DOMAIN_HOME="<set_this>"
 
umask 027


if [ "${showErrorStack}" = "false" ] ; then
        echo "try:" >"status.py"
        echo "  componentName = java.lang.System.getenv('componentName')" >>"status.py"
        echo "  nmConnect('weblogic','','localhost','node_manager_port','base_domain')">>"status.py"
        echo "  nmServerStatus('${componentName}',serverType='OHS')" >>"status.py"
        echo "  exit()" >>"status.py"
        echo "except Exception,e:" >>"status.py"
        echo "  print 'Error:', sys.exc_info()[1]" >>"status.py"
        echo "  exit(exitcode=1)" >>"status.py"
else
        echo "componentName = java.lang.System.getenv('componentName')" >"status.py"
        echo "stopComponentInternal('${componentName}', r'${DOMAIN_HOME}')" >>"status.py"
        echo "exit()" >>"status.py"
fi

echo "Showing Status of System Component ${componentName} ..."

# Using WLST...

${WL_HOME}/../oracle_common/common/bin/wlst.sh -i status.py  2>&1

if [ $? -ne 0 ] ; then
        exit 1
fi
if [ -f status.py ] ; then
        rm -f status.py
fi

echo "Done"

exit

 

2. Change the following elements in the script to match the environment.

WL_HOME
DOMAIN_HOME

The values for these 2 variables can be extracted from the stopComponent.sh or startComponent.sh product scripts, located in the domain bin dir (<instances_path>/user_projects/domains/<domain>/bin).

Finally fix the node_manager_port value in this line, e.g change to 5556 or whatever port is in use

nmConnect('weblogic','','localhost','node_manager_port','base_domain')

 

3. Save the script and make sure it's executable by the Oracle user.

4. Run the script with the following syntax:  

./status.sh <ohs_instance_name>

You will be prompted for the Node manager password.


Example session:

oracle$ ./status.sh ohs1

Showing Status of System Component ohs1 ...

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

Please enter your password :
Connecting to Node Manager ...
Successfully Connected to Node Manager.

RUNNING



Exiting WebLogic Scripting Tool.
 


Posted by 달콤한녀석

댓글을 달아 주세요

WEB2014. 8. 5. 09:40

OHS 12c에서는 ohs component start/stop 수행 시, nodemanager에 connect 하기 위한 password 입력이 꼭 필요합니다. 

 

[weblogic@linuxdev bin]$ ./startComponent.sh testWeb
Starting System Component testWeb ...

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

Reading domain from /oracle/web/ohs121200/domains/testDomain
 
Please enter your password :
Connecting to Node Manager ...
Successfully Connected to Node Manager.
Starting server testWeb ...
Successfully started server testWeb ...
Successfully disconnected from Node Manager.


Exiting WebLogic Scripting Tool.

Done

 

하지만, 매번 password를 입력해야 하는 번거로움을 피하기 위해서는 storeUserConfig 라는 옵션으로 cfg(config)와 key를 생성해 주시면 됩니다.

 

cmd > ./startComponent.sh [component name] storeUserConfig

 

storeUserConfig 옵션이 추가되면, password 입력 후에 "Creating the key file can reduce the security of your system if it is not kept in a secured location after it is created. Do you want to create the key file? y or n"라는 메시지를 확인할 수 있습니다.

 

이 때, "y"를 입력하면, 사용자 홈디렉토리에 .wlst/nm-cfg-[domain name].props, .wlst/nm-key-[domain name].props 두 개의 파일이 생성되는 것을 확인할 수 있습니다.

 

[weblogic@linuxdev bin]$ ./startComponent.sh testWeb storeUserConfig
Starting System Component testWeb ...

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

Reading domain from /oracle/web/ohs121200/domains/testDomain
 
Please enter your password :
Creating the key file can reduce the security of your system if it is not kept in a secured location after it is created. Do you want to create the key file? y or n
The username and password that were used for this WebLogic NodeManager connection are stored in /home/weblogic/.wlst/nm-cfg-testDomain.props and /home/weblogic/.wlst/nm-key-testDomain.props.
Connecting to Node Manager ...
Successfully Connected to Node Manager.
Starting server testWeb ...
Successfully started server testWeb ...
Successfully disconnected from Node Manager.


Exiting WebLogic Scripting Tool.

Done

 

cfg와 key 파일이 한 번 생성되면, 더 이상 password를 체크하지 않습니다. 또한 storeUserConfig 옵션을 사용할 필요도 없습니다. (cfg, key를 생성할 때만 사용)

 

반대로 사용자 홈디렉토리에서 cfg, key 파일을 삭제하면, 다시 password 입력을 요청하게 됩니다.

[출처] [OHS] OHS 12.1.2 start/stop component password 생략 방법|작성자 시후아빠

 

 


 

 

추가적으로 Oracle Support 문서 내용...

How to avoid password prompt when using startComponent.sh to start OHS 12c (문서 ID 1671654.1)

Applies to: 
 Oracle Fusion Middleware - Version 12.1.2.0.0 and later
Oracle HTTP Server - Version 12.1.2.0.0 and later
Information in this document applies to any platform.

Goal

When starting OHS , the following  password prompt appears: 

 ./startComponent.sh ohs1

Starting System Component ohs1 ...

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

Reading domain from /opt/ows/Oracle/Middleware/OHS_Home/user_projects/domains/base_domain

Please enter your password :

How to avoid this prompt?

Solution

You can avoid password every time you launch the server with startComponent.sh/.cmd by starting it with the storeUserConfig option for the first time. Do the following:

1.At the prompt, enter the following command: 

$DOMAIN_HOME/bin/startComponent.sh componentName storeUserConfig

Please enter your password :

The system will prompt for your Node Manager password.

2.Type the password and press Enter. The system responds with this message: 

 Creating a key file can reduce the security of your system if it is not a secured location after it is created. Do you want to create the key file? y or n.

3.Type y to store your Node manager password. When you subsequently use this command, you will not need to enter a password. 

It creates hidden files in the users home directory after the above steps.
These files contain domain infomation. 

 for example

.wlst/nm-key-base_domain.props
.wlst/nm-cfg-base_domain.props

When using startComponent.sh to start and stop OHS 12c after the above steps,
password prompt is omitted.

How to return to the original operation

1.stop OHS
2.delete hidden files in the users home directory. 

 for example

.wlst/nm-key-base_domain.props
.wlst/nm-cfg-base_domain.props

By removing the files , you will be prompted for the password used to configure the component.
Posted by 달콤한녀석

댓글을 달아 주세요