1. Overview

Oracle HTTP Server 12cR1 테스트 환경을 자동 재구축을 위해 모든 기본 설치 환경을 집약한다.



2. Descriptions

All-In-One-Script-For-12cR1.sh 실행으로 다음 환경을 구성하도록 한다.

  • base_domain
  • NodeManager (SecureListner=false, TCP 5556)
  • Worker 2ea



3. Script

3.1 Engine

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
BASEDIR=/sw/downloads
OS_USERNAME=$(id --user --name)
OS_GROUPNAME=$(id --group --name)

OHS_INSTALL_FILE=fmw_12.1.3.0.0_ohs_linux64.bin
ENGINE_PATH=/sw/webtier/12cR1
INVENTORY_PATH=/sw/webtier/inventories/12cR1
INVENTORY_GROUP=$(id --group --name)

DOMAIN_NAME=base_domain
DOMAIN_HOME=${ENGINE_PATH}/domains/${DOMAIN_NAME}

HOSTNAME=wls.local
NM_USERNAME=webtier
NM_PASSWORD=webtier1
NM_ADDR=${HOSTNAME}
NM_PORT=5556

WORKER_NAME_1=worker1
WORKER_ADDR_1=${HOSTNAME}
WORKER_PORT_1=10080
WORKER_SSL_1=10443
WORKER_ADMIN_ADDR_1=127.0.0.1
WORKER_ADMIN_PORT_1=10099

WORKER_NAME_2=worker2
WORKER_ADDR_2=${HOSTNAME}
WORKER_PORT_2=10180
WORKER_SSL_2=10543
WORKER_ADMIN_ADDR_2=127.0.0.1
WORKER_ADMIN_PORT_2=10199


# (1) ResponseFile
# https://docs.oracle.com/middleware/1213/core/WTINS/standalone_domain.htm
# https://docs.oracle.com/middleware/1212/core/OUIRF/response_file.htm#OUIRF390
# https://dhkim900331.github.io/webtier/All-In-One-Script-For-12cR1

cat << EOF > ${BASEDIR}/rsp
[ENGINE]
#DO NOT CHANGE THIS.
Response File Version=1.0.0.0.0

[GENERIC]
ORACLE_HOME=${ENGINE_PATH}
INSTALL_TYPE=Standalone HTTP Server (Managed independently of WebLogic server)
DECLINE_SECURITY_UPDATES=true
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false
EOF


# (2) Inventory
# https://docs.oracle.com/en/middleware/fusion-middleware/12.2.1.4/ouirf/using-oracle-universal-installer-silent-mode.html#GUID-756E3FD9-4094-412F-9BEB-72C5FD51056B
# * inventory.loc 파일 샘플은 문서에 없음

cat << EOF > ${BASEDIR}/loc
inventory_loc=${INVENTORY_PATH}
inst_group=${INVENTORY_GROUP}
EOF


# (3) Installation

${BASEDIR}/${OHS_INSTALL_FILE} -silent -responseFile ${BASEDIR}/rsp -invPtrLoc ${BASEDIR}/loc

ADMIN_ADDR을 127.0.0.1 으로만 해야 되는 것으로 테스트상 확인되는데,

구체적인 이유는 확인되지 않는다.



3.2 Domain

1
2
3
4
5
6
7
8
9
# (4) Domain

${ENGINE_PATH}/oracle_common/common/bin/wlst.sh << EOF
readTemplate('${ENGINE_PATH}/wlserver/common/templates/wls/base_standalone.jar')
addTemplate('${ENGINE_PATH}/ohs/common/templates/wls/ohs_standalone_template_12.1.3.jar')
writeDomain('${DOMAIN_HOME}')
closeTemplate()
exit()
EOF


3.3 NodeManager

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# (5) NodeManager

${ENGINE_PATH}/oracle_common/common/bin/wlst.sh << EOF
readDomain('${DOMAIN_HOME}')
cd('/SecurityConfiguration/base_domain')
set('NodeManagerUsername','${NM_USERNAME}')
set('NodeManagerPasswordEncrypted','${NM_PASSWORD}')

cd('/Machine/localmachine/NodeManager/localmachine')
set('ListenAddress','${NM_ADDR}')
set('ListenPort',${NM_PORT})

cd('/NMProperties')
set('SecureListener',false)
updateDomain()
EOF


# (6) NodeManager SSL disabled
# WLST 으로 update 되지 않아 추가로 해야 한다. 실질적으로 아래가 필수
sed -i 's/SecureListener=true/SecureListener=false/g' ${DOMAIN_HOME}/nodemanager/nodemanager.properties


3.4 Component

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# (7) Component
${ENGINE_PATH}/oracle_common/common/bin/wlst.sh << EOF
readDomain('${DOMAIN_HOME}')

create('${WORKER_NAME_1}','SystemComponent')
create('${WORKER_NAME_2}','SystemComponent')
delete('ohs1','SystemComponent')

cd('/SystemComponent/${WORKER_NAME_1}')
cmo.setComponentType('OHS')
cd('/SystemComponent/${WORKER_NAME_2}')
cmo.setComponentType('OHS')

cd('/OHS/${WORKER_NAME_1}')
cmo.setListenAddress('${WORKER_ADDR_1}')
cmo.setListenPort('${WORKER_PORT_1}')
cmo.setSSLListenPort('${WORKER_SSL_1}')
cmo.setAdminHost('${WORKER_ADMIN_ADDR_1}')
cmo.setAdminPort('${WORKER_ADMIN_PORT_1}')
cmo.setServerName('http://${HOSTNAME}:${WORKER_PORT_1}')

cd('/OHS/${WORKER_NAME_2}')
cmo.setListenAddress('${WORKER_ADDR_2}')
cmo.setListenPort('${WORKER_PORT_2}')
cmo.setSSLListenPort('${WORKER_SSL_2}')
cmo.setAdminHost('${WORKER_ADMIN_ADDR_2}')
cmo.setAdminPort('${WORKER_ADMIN_PORT_2}')
cmo.setServerName('http://${HOSTNAME}:${WORKER_PORT_2}')

updateDomain()
exit()
EOF


3.5 Create NodeManager Scripts (start, stop, log, ps)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# (8) Create NodeManager Scripts (start, stop, log, ps)
cat << "EOF" > ${DOMAIN_HOME}/startNM.sh
#!/usr/bin/bash
BASEDIR=$(realpath $(dirname $0))
SERVER_NAME=nodemanager
DOMAIN_HOME=${BASEDIR}
LOG_HOME=${DOMAIN_HOME}/logs/${SERVER_NAME}
LOG_TIME=$(date +%y%m%d_%H%M)

##### User Check #####
USER=#OS_USERNAME#
if [ "$USER" != `/usr/bin/whoami` ]; then
     echo "* you do not have permission. *"
     exit;
fi
####################

## Process Check ##
WEB_PID=$(${DOMAIN_HOME}/psNM.sh)
if [ "$WEB_PID" != "" ]; then
     echo "Server already Started."
     exit;
fi
###################

mkdir -p ${LOG_HOME}
mv ${LOG_HOME}/${SERVER_NAME}.out ${LOG_HOME}/${SERVER_NAME}.out.${LOG_TIME}
nohup ${BASEDIR}/bin/startNodeManager.sh >> ${LOG_HOME}/${SERVER_NAME}.out 2>&1 &
EOF


cat << "EOF" > ${DOMAIN_HOME}/stopNM.sh
#!/usr/bin/bash
BASEDIR=$(realpath $(dirname $0))
SERVER_NAME=nodemanager
DOMAIN_HOME=${BASEDIR}
LOG_HOME=${DOMAIN_HOME}/logs/${SERVER_NAME}

##### User Check #####
USER=#OS_USERNAME#
if [ "$USER" != `/usr/bin/whoami` ]; then
     echo "* you do not have permission. *"
     exit;
fi
####################

## Process Check ##
WEB_PID=$(${DOMAIN_HOME}/psNM.sh)
if [ "$WEB_PID" == "" ]; then
     echo "Server already Stopped."
     exit;
fi
###################

${DOMAIN_HOME}/bin/stopNodeManager.sh >> ${LOG_HOME}/${SERVER_NAME}.out
sleep 1
tail -5 ${LOG_HOME}/${SERVER_NAME}.out
EOF


cat << "EOF" > ${DOMAIN_HOME}/logNM.sh
#!/usr/bin/bash
BASEDIR=$(realpath $(dirname $0))
SERVER_NAME=nodemanager
DOMAIN_HOME=${BASEDIR}
LOG_HOME=${DOMAIN_HOME}/logs/${SERVER_NAME}
tail -10f ${LOG_HOME}/${SERVER_NAME}.out
EOF


cat << "EOF" > ${DOMAIN_HOME}/psNM.sh
#!/usr/bin/bash
BASEDIR=$(realpath $(dirname $0))
DOMAIN_HOME=${BASEDIR}
ps -ef | grep "java" | grep "weblogic.NodeManager -v" | grep "${DOMAIN_HOME}"
EOF


3.6 Create Component Scripts (start, stop, ps)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# (9) Create Component Scripts (start, stop, ps)
cat << "EOF" > ${DOMAIN_HOME}/start-worker.sh
#!/usr/bin/bash
BASEDIR=$(realpath $(dirname $0))
DOMAIN_HOME=${BASEDIR}
DOMAIN_NAME=$(basename ${DOMAIN_HOME})
WORKER=#WORKER_NAME#
NM_ADDR=#NM_ADDR#
NM_PORT=#NM_PORT#
NM_USERNAME=#NM_USERNAME#
NM_PASSWORD=#NM_PASSWORD#
WL_HOME=${DOMAIN_HOME}/../../wlserver

##### User Check #####
USER=#OS_USERNAME#
if [ "$USER" != `/usr/bin/whoami` ]; then
     echo "* you do not have permission. *"
     exit;
fi
####################

## Process Check ##
WEB_PID=$(${DOMAIN_HOME}/ps-${WORKER}.sh)
if [ "$WEB_PID" != "" ]; then
     echo "Server already Started."
     exit;
fi
###################

${WL_HOME}/../oracle_common/common/bin/wlst.sh << INNER_EOF
nmConnect('${NM_USERNAME}', '${NM_PASSWORD}', '${NM_ADDR}', '${NM_PORT}', '${DOMAIN_NAME}', '${DOMAIN_HOME}','plain')
nmStart(serverName='${WORKER}', serverType='OHS')
nmServerStatus(serverName='${WORKER}', serverType='OHS')
nmDisconnect()
exit()
INNER_EOF
EOF


cat << "EOF" > ${DOMAIN_HOME}/stop-worker.sh
#!/usr/bin/bash
BASEDIR=$(realpath $(dirname $0))
DOMAIN_HOME=${BASEDIR}
DOMAIN_NAME=$(basename ${DOMAIN_HOME})
WORKER=#WORKER_NAME#
NM_ADDR=#NM_ADDR#
NM_PORT=#NM_PORT#
NM_USERNAME=#NM_USERNAME#
NM_PASSWORD=#NM_PASSWORD#
WL_HOME=${DOMAIN_HOME}/../../wlserver

##### User Check #####
USER=#OS_USERNAME#
if [ "$USER" != `/usr/bin/whoami` ]; then
     echo "* you do not have permission. *"
     exit;
fi
####################

## Process Check ##
WEB_PID=$(${DOMAIN_HOME}/ps-${WORKER}.sh)
if [ "$WEB_PID" == "" ]; then
     echo "Server already Stopped."
     exit;
fi
###################

${WL_HOME}/../oracle_common/common/bin/wlst.sh << INNER_EOF
nmConnect('${NM_USERNAME}', '${NM_PASSWORD}', '${NM_ADDR}', '${NM_PORT}', '${DOMAIN_NAME}', '${DOMAIN_HOME}','plain')
nmKill(serverName='${WORKER}', serverType='OHS')
nmServerStatus(serverName='${WORKER}', serverType='OHS')
nmDisconnect()
exit()
INNER_EOF
EOF


cat << "EOF" > ${DOMAIN_HOME}/ps-worker.sh
#!/usr/bin/bash
BASEDIR=$(realpath $(dirname $0))
DOMAIN_HOME=${BASEDIR}
WORKER=#WORKER_NAME#
ps -ef | grep "httpd" | grep "${WORKER}" | grep "${DOMAIN_HOME}"
EOF

sed -i "s|#OS_USERNAME#|${OS_USERNAME}|g" ${DOMAIN_HOME}/*NM.sh

cp ${DOMAIN_HOME}/start-worker.sh ${DOMAIN_HOME}/start-${WORKER_NAME_1}.sh
cp ${DOMAIN_HOME}/stop-worker.sh ${DOMAIN_HOME}/stop-${WORKER_NAME_1}.sh
cp ${DOMAIN_HOME}/ps-worker.sh ${DOMAIN_HOME}/ps-${WORKER_NAME_1}.sh

cp ${DOMAIN_HOME}/start-worker.sh ${DOMAIN_HOME}/start-${WORKER_NAME_2}.sh
cp ${DOMAIN_HOME}/stop-worker.sh ${DOMAIN_HOME}/stop-${WORKER_NAME_2}.sh
cp ${DOMAIN_HOME}/ps-worker.sh ${DOMAIN_HOME}/ps-${WORKER_NAME_2}.sh

sed -i "s/#WORKER_NAME#/${WORKER_NAME_1}/g" ${DOMAIN_HOME}/*${WORKER_NAME_1}.sh
sed -i "s/#NM_ADDR#/${NM_ADDR}/g" ${DOMAIN_HOME}/*${WORKER_NAME_1}.sh
sed -i "s/#NM_PORT#/${NM_PORT}/g" ${DOMAIN_HOME}/*${WORKER_NAME_1}.sh
sed -i "s/#NM_USERNAME#/${NM_USERNAME}/g" ${DOMAIN_HOME}/*${WORKER_NAME_1}.sh
sed -i "s/#NM_PASSWORD#/${NM_PASSWORD}/g" ${DOMAIN_HOME}/*${WORKER_NAME_1}.sh
sed -i "s/#NM_ADDR#/${NM_ADDR}/g" ${DOMAIN_HOME}/*${WORKER_NAME_1}.sh
sed -i "s|#OS_USERNAME#|${OS_USERNAME}|g" ${DOMAIN_HOME}/*${WORKER_NAME_1}.sh


sed -i "s/#WORKER_NAME#/${WORKER_NAME_2}/g" ${DOMAIN_HOME}/*${WORKER_NAME_2}.sh
sed -i "s/#NM_ADDR#/${NM_ADDR}/g" ${DOMAIN_HOME}/*${WORKER_NAME_2}.sh
sed -i "s/#NM_PORT#/${NM_PORT}/g" ${DOMAIN_HOME}/*${WORKER_NAME_2}.sh
sed -i "s/#NM_USERNAME#/${NM_USERNAME}/g" ${DOMAIN_HOME}/*${WORKER_NAME_2}.sh
sed -i "s/#NM_PASSWORD#/${NM_PASSWORD}/g" ${DOMAIN_HOME}/*${WORKER_NAME_2}.sh
sed -i "s/#NM_ADDR#/${NM_ADDR}/g" ${DOMAIN_HOME}/*${WORKER_NAME_2}.sh
sed -i "s|#OS_USERNAME#|${OS_USERNAME}|g" ${DOMAIN_HOME}/*${WORKER_NAME_2}.sh