반응형

기본적으로 systemctl 명령을 통한 방식 (CASE 1)과 Startup.sh 및 Shutdown.sh 2가지 방식(CASE 2)이 있습니다.

 

설정하는 환경에 따른 차이로

 

공통적으로 시작 및 종료를 하기 위해서는

 

정확하게 쉘을 수행하는 것이 좋습니다.

 

systemctl 명령을 통해 시작한 tomcat은 Shutdown.sh를 수행하여도

 

잠시뒤에 다시 시작하는 현상도 볼수 있습니다.

 

1. Tomcat 시작하는 쉘

- CASE 1 방식

# Systemctl 서비스 시작 방식

MYID=`whoami`

# CHECK WAS PORT
WASPORT=`lsof -i TCP:80 | grep -i java | wc -l`

if [ ${WASPORT} -gt 0 ]; then
        echo ""
        echo "====================================="
        echo " 이미 WAS(Tomcat)가 실행 중입니다."
        echo ""

        echo " 종료한 뒤 수행해 주세요."
        echo "===================================="
        echo ""

        exit 0

fi

if [ ${MYID} = "root" ]; then
        systemctl start tomcat
else

        echo " root 계정만 실행 가능합니다."
fi

- CASE 2 방식

# WAS 서비스 시작 방식
WASHOME='/apache-tomcat-8.5.40/bin'

MYID=`whoami`

# CHECK WAS PORT
WASPORT=`lsof -i TCP:80 | wc -l`

if [ ${WASPORT} -gt 0 ]; then
        echo ""
        echo "====================================="
        echo " 이미 WAS(Tomcat)가 실행 중입니다."
        echo ""

        echo " 종료한 뒤 수행해 주세요."
        echo "===================================="
        echo ""

        exit 0

fi

if [ ${MYID} = "root" ]; then
        cd ${WASHOME}
        ./startup.sh
else

        echo " root 계정만 실행 가능합니다."
fi

 

2. Tomcat 종료하는 쉘

- CASE 1

# Systemctl 서비스 종료 방식
MYID=`whoami`

# CHECK WAS PORT
WASPORT=`lsof -i TCP:80 | wc -l`

if [ ${WASPORT} -eq 0 ]; then
        echo ""
        echo "====================================="
        echo " WAS가 기동중인 상태가 아닙니다."
        echo ""

        echo " 종료한 뒤 수행해 주세요."
        echo "===================================="
        echo ""

        exit 0

fi

if [ ${MYID} = "root" ]; then
        systemctl stop tomcat
else

        echo " root 계정만 실행 가능합니다."
fi

- CASE 2

# WAS 서비스 종료 방식
WASHOME='/apache-tomcat-8.5.40/bin'

MYID=`whoami`

# CHECK WAS PORT
WASPORT=`lsof -i TCP:80 | wc -l`

if [ ${WASPORT} -eq 0 ]; then
        echo ""
        echo "====================================="
        echo " WAS가 기동중인 상태가 아닙니다."
        echo ""

        echo " 종료한 뒤 수행해 주세요."
        echo "===================================="
        echo ""

        exit 0

fi

if [ ${MYID} = "root" ]; then
        cd ${WASHOME}
        ./shutdown.sh
else

        echo " root 계정만 실행 가능합니다."
fi

 

3. 서비스 포트에 수행되는 PID 확인

# Tomcat 기준

echo ""
echo "==================================================="
echo ""
echo " Use Port : 80, 8005, 8009, 8443, 8080 "
echo ""
echo "==================================================="

echo ""
echo "***************************************************"
echo " 1. Search : 80 Port "
lsof -i TCP:80
echo "***************************************************"
echo ""

echo ""
echo "***************************************************"
echo " 2. Search : 8005 Port "
lsof -i TCP:8005
echo "***************************************************"

echo ""
echo "***************************************************"
echo " 3. Search : 8009 Port "
lsof -i TCP:8009
echo "***************************************************"

echo ""
echo "***************************************************"
echo " 4. Search : 8443 Port "
lsof -i TCP:8443
echo "***************************************************"

echo ""
echo "***************************************************"
echo " 5. Search : 8080 Port "
lsof -i TCP:8080
echo "***************************************************"

echo ""

 

4. tomcat 에 WAR 파일 Deploy 하는 쉘

echo ""
echo "===================================================================="
echo ""
echo " Deploy Shell "
echo ""
echo "===================================================================="

############################# Define Path ################################
BACKUP_ROOT="/home/tomcat/backup"
WAR_DIR="/apache-tomcat-8.5.40/webapps"
WAR_FILE="deploy.war"

##########################################################################


if [ $# -eq 1 ]; then


        echo ""
        echo " 1. Check Deploy File Exist....."
        echo ""

        if [ -f $1 ]; then

                echo ""
                echo " 2. Check WAR File Exist..... "

                if [ -f ${WAR_DIR}/${WAR_FILE} ]; then

                        echo ""
                        echo " 3. Exist deploy.war File Backup"
                        echo "    Backup Folder => $BACKUP_ROOT "
                        echo ""

                        BK_NAME=`date +%Y%m%d_%H%M%S`

                        echo " *  cp ${WAR_DIR}/${WAR_FILE} ${BACKUP_ROOT}/${WAR_FILE}_${BK_NAME}"
                        cp ${WAR_DIR}/${WAR_FILE} ${BACKUP_ROOT}/${WAR_FILE}_${BK_NAME}
                        echo ""

                else

                        echo " *  Don't Backup Run becase, War File Not Exist "
                fi

                # delete old deploy folder
###                rm -rf ${WAR_DIR}/factory

                # Deploy File
                echo " *  cp $1 ${WAR_DIR}/${WAR_FILE}"
                cp $1 ${WAR_DIR}/${WAR_FILE}
                echo ""
                echo " >>> Please Restart Tomcat Service"
                echo ""

        else
                echo ""
                echo " $1 File not Exist .... Please check!"
                echo ""
        fi

else

        echo ""
        echo " Usage : $0 ${WAR_FILE} "
        echo ""
fi

echo ""
echo "===================================================================="
echo ""

 

반응형
반응형


CD 롬 정보 얻어오는 스크립트(dvd.bat)


 @echo off

set USB_DRIVE=none

for /F "tokens=1*" %%a in ('fsutil fsinfo drives') do (

   for %%c in (%%b) do (

      for /F "tokens=3" %%d in ('fsutil fsinfo drivetype %%c') do (


         if %%d equ CD-ROM (

            set DVD=%%c:

          )

          

      )

   )

)





자동으로 복구하는 BATCH 스크립트 (setup.bat)


 @echo off

setlocal


rem call 은 같은 화면 / start은 별도로 수행

call dvd.exe


::::::::::::::::::::::::::::::::::::::::::::::

:LOOP

color 1F

cls

echo.

echo.

echo.

echo.                  ◀ 고스트 자동 복구용 ▶

echo. 

echo.            1. Centos 6.3 복구 (DVD -^> resource\backup.gho)

echo.                (ID : root / password : 1q2w3e )

echo. 

echo.            2. Partition Wizard Professional Edition

echo.

echo.            3. Q-Dir

echo.

echo.            4. reboot

echo.

echo.            ※ 리눅스 복원(1번)은 모든 데이터가 지원지니

echo.

echo                제안서 작업 폴더 등은 백업 후 수행 하세요

echo.

echo                자세한 사항은 root로 로그인 한 뒤 바탕화면 참고하세요

echo.

echo.

set /p ANS="☞ 번호를 입력해 주세요 : "


if "%ANS%" == "1" goto MENU1

if "%ANS%" == "2" goto MENU2

if "%ANS%" == "3" goto MENU3

if "%ANS%" == "4" goto QUIT


goto LOOP

:::::::::::::::::::::::::::::::::::::::::::::::

:MENU1

echo.

echo. Windows 7 Restore

echo. 

start x:\ghost32 -clone,mode=load,src=%DVD%\sources\backup.gho,dst=1 -sure -fx

goto LOOP


:MENU2

echo.

echo "Partition Wizard Run~"

start x:\PartitionWizardPro6.exe

echo.

goto LOOP


:MENU3

echo.

echo "Q-Dir Run"

echo.

start x:\Q-Dir.exe

goto LOOP


:QUIT

reboot






반응형
반응형

Now, this one was pretty frustrating, especially with a DBA demanding X11 access to an AIX server so that he could install on it...

Here is how to do it:

1. Check that the X11 server is installed

This can be done with the following command:

# lslpp -l | grep -i X11.Dt

If X11 is installed on an AIX machine, the above command should return (more or less):

andre@galactus$ lslpp -l | grep -i x11.dt
  X11.Dt.ToolTalk           5.3.0.60  COMMITTED     AIX CDE ToolTalk Support
  X11.Dt.bitmaps             5.3.0.0  COMMITTED     AIX CDE Bitmaps
  X11.Dt.helpmin             5.3.0.0  COMMITTED     AIX CDE Minimum Help Files
  X11.Dt.helprun             5.3.0.0  COMMITTED     AIX CDE Runtime Help
  X11.Dt.lib                5.3.0.60  COMMITTED     AIX CDE Runtime Libraries
  X11.Dt.rte                5.3.0.60  COMMITTED     AIX Common Desktop Environment
  X11.Dt.ToolTalk           5.3.0.60  COMMITTED     AIX CDE ToolTalk Support
  X11.Dt.bitmaps             5.3.0.0  COMMITTED     AIX CDE Bitmaps
  X11.Dt.helpmin             5.3.0.0  COMMITTED     AIX CDE Minimum Help Files
  X11.Dt.rte                5.3.0.60  COMMITTED     AIX Common Desktop Environment

If not, you need to install the X11 server. See below.

2. Installing the X11 server on an AIX machine

The X11 packages are on the #2 AIX installation CD, in the /installp/ppc/ directory.

To search for the proper package, once the CD has been installed in the CD-ROM drive of your AIX machine, you can issue the following commands:

# find /cdrom1 -name *dt* /cdrom1/installp/ppc/X11.adt /cdrom1/usr/sys/inst.images/X11.adt

Here, of course, the CD-ROM drive is mounted under /cdrom1.

If we list this directory, here is the content:

# cd /cdrom1/installp/ppc/
# ls
.toc                     X11.help.en_US           csm.gui.dcem_1.6.0.10
Java14.license           X11.loc.en_US            invscout.websm
Java14.sdk               X11.man.en_US            sysmgt.help.en_US
Java5.sdk                X11.motif                sysmgt.help.msg.en_US
X11.Dt                   X11.msg.en_US            sysmgt.msg.en_US.sguide
X11.Dt.other             X11.samples              sysmgt.msg.en_US.websm
X11.adt                  X11.vfb                  sysmgt.sguide
X11.apps                 X11.vsm                  sysmgt.websm
X11.base                 bos.aixpert              sysmgt.websm.diskarray
X11.compat.X11R5         bos.ecc_client           sysmgtlib.framework
X11.compat.other         bos.installers           sysmgtlib.libraries
X11.fnt                  csm.gui.dcem

Now, to install with smitty, type smitty as root, and go to "Software installation > Install software".

Next, select your CD-ROM device, and check the following configuration is correct:

                                Install Software

Type or select values in entry fields.       
Press Enter AFTER making all desired changes.

                                                        [Entry Fields]
* INPUT device / directory for software               /dev/cd1
* SOFTWARE to install                                [+ 5.3.0.60  AIX CDE A> +
  PREVIEW only? (install operation will NOT occur)    no                     +
  COMMIT software updates?                            yes                    +
  SAVE replaced files?                                no                     +
  AUTOMATICALLY install requisite software?           yes                    +
  EXTEND file systems if space needed?                yes                    +
  OVERWRITE same or newer versions?                   no                     +
  VERIFY install and check file sizes?                yes                    +
  Include corresponding LANGUAGE filesets?            yes                    +
  DETAILED output?                                    yes                    +
  Process multiple volumes?                           yes                    +
  ACCEPT new license agreements?                      yes                    + 
  PREVIEW new LICENSE agreements?                     no                     +

F1=Help             F2=Refresh          F3=Cancel           F4=List
F5=Reset            F6=Command          F7=Edit             F8=Image
F9=Shell            F10=Exit            Enter=Do                    

In the SOFTWARE to install, press "F4" (=List) and select all the CDE packages, using the list of packages above as a guide.

Next, press ENTER and the installation should proceed correctly.

3. How to start the X11 server

There are several possibilities here. Please keep in mind that I was trying to have a minimal X11 server, to allow one user to connect. I was not so much interested in correctness...

Two possibilities:

  • Use the dtlogin command as shown below:
# /usr/dt/bin/dtlogin -daemon
  • Use the /etc/rc.dt script as shown below:
# /etc/rc.dt

This script has the advantage of launching a full X11 environment, including a login prompt on the console.

In both cases, you can check the X11 server is running correctly with the following command:

andre@galactus$ ps -fe | grep -i dtlogin | grep -v grep root 94310 1 0 26 sep - 0:00 /usr/dt/bin/dtlogin -daemon root 147544 94310 0 26 sep - 0:00 dtlogin <:0> -daemon

4. Restart X11 in case of a crash or a misbehaving server

Please make sure you go through the entire list. This is a bit tedious, but it works very well, so make sure you go through all the steps and don't try to skip one...

  • Stop all "rc.bootx" processes:
# ps -fe | grep -i rc.bootx # kill -9 <rc.bootx PIDs>

WARNING: If there are ANY "rc.bootx" processes, they MUST be stopped before anything else!

  • Stop all "dtlogin" processes:
# ps -fe | grep -i dtlogin # kill -9 <dtlogin PIDs>

WARNING: Make sure there are no processes attached to the "dtlogin" processes...

  • Delete all temporary files:
cd /var/dt rm Xerrors rm Xpid

Sometimes, it could be interesting to keep a copy of the Xerrors file...

  • Check available space under /var and /tmp:

For instance:

-bash-3.00$ df -g /var /tmp Filesystem GB blocks Free %Used Iused %Iused Mounted on /dev/hd9var 1.02 0.29 72% 556 1% /var /dev/hd3 3.05 2.28 26% 1726 1% /tmp

This space-checking stage is optional, but you never know... :-)

  • Check that the "dtsrc" service is inoperative:

Do this with the following command:

$ lssrc -s dtsrc Subsystem Group PID Status dtsrc inoperative
  • Restart the service with "/etc/rc.dt" :
# /etc/rc.dt
  • Check that the "dtlogin" service is running:
bash-2.05b$ ps -fe | grep -i dtlogin | grep -v grep root 65704 1 0 Sep 09 - 0:00 /usr/dt/bin/dtlogin -daemon root 74118 65704 0 Sep 09 - 0:00 dtlogin <:0> -daemon
  • Check that the service is marked as "active":
bash-2.05b$ lssrc -s dtsrc Subsystem Group PID Status dtsrc active

See Also:


 출처 : http://www.gilandre.net/cgi-bin/wiki.cgi/AIXServerX11

반응형

+ Recent posts