Web开发Unix常用命令

在你定义的域中可以找到如下命令:
/[youHome]/domains/[yourDomain]/startWebLogic.sh
/[youHome]/domains/[yourDomain]/stopWebLogic.sh

启动weblogic,可以参考如下命令:
nohup ./startWebLogic.sh &
或者:
nohup ./startWebLogic.sh >日志文件名 &

关闭weblogic,我们更倾向于直接杀掉weblogic进程:
ps -ef|grep java
查找到进程ID之后,直接运行如下命令:
kill -9 ID

weblogic 关闭和启动

1、 使用 Xmanager Enterprise或ssh 等工具登陆Linux 或unix机器上

找到weblogic安装目录 如:/bea/user_projects/domains/自己建的域名

2、进入目录执行下列命令后台启动weblocgic

#nohup ./startWebLogic.sh >out.log 2>&1 &

该命令后台启动weblogic,并且把运行日至放到当前目录out.log文件里,并且返回一个进程号

3、停止后台weblocgic进程

在上述domain目录里执行以下命令停止weblogic

# ./stopWebLogic

用ps -ef|grep java查找进程看是否停掉

一般情况很难关闭,需要杀掉后台进程(经常这样)

查看后台weblogic进程 或者利用上面启动时返回的进程号

#ps -ef|grep java 如:

root 123456 2346546

root 1346464 64646464

杀后台进程 :#kill -9 1346464(返回的进程号)

有的操作系统用线程模拟进程,在部分linux操作系统下面,wenlogic进程表现为多线程,这样的话需用脚本杀死weblogic多线程

#ps -ef|grep java |awk ‘{printf “kill -9 ” $2}’ >killjava

#sh killjava

即可杀死weblogic的java进程,但是执行时要注意该机器是否还有其他java进程运行,小心错杀,造成其他应用down机。

 

在启动weblogic的时候我们经常看到如下的命令:

nohup ./startWebLogic.sh >out.log 2>&1 &

从09年开始用weblogic到现在已经过去3年多了 ,今天终于将该命令理解清楚了。

其中 0、1、2分别代表如下含义:
 0 – stdin (standard input)
 1 – stdout (standard output)
 2 – stderr (standard error)

nohup ./startWebLogic.sh >out.log 2>&1 &

nohup+最后面的& 是让命令在后台执行

>out.log 是将信息输出到out.log日志中

2>&1 是将标准错误信息转变成标准输出,这样就可以将错误信息输出到out.log 日志里面来。

 

 

Q1) In what order  you can start /stop a WebLogic  server?

Ans:  startup  –> 1. Admin server

2. Managed server

stopping  –> 1. Managed server

2. Admin server.

If we stop Admin server before Managed server, it may happen that Managed server will not come down. In that case we may need to kill the process.

Q2) How to start/ stop WL server?

Ans: $DOMAIN_HOME/bin  –> contains all start/stop scripts.

Admin server –> startWebLogic.sh , stopWebLogic.sh

Managed server –> startManagedweblogic.sh, stopManagedweblogic.sh

To start/stop Manager server, we need to provide 2  values to the script.

1. Managed server name

2. Admin server URL  i.e. socket address

e.g.

$ .  ./startWebLogic.sh goodbankMng1-1 192.165.125.1:8000 

It will ask for username and password.

Note:  Closing the terminal in which you started Admin or Managed server will shutdown the server. To avoid this , we need to start them as background process using “nohup” and “&”. Details in wrapper scripts.

Q3) What is location of logfile for weblogic?

Logfile location: $DOMAIN_HOME/server/log/<server_name>.log

For other possible location, check wrapper script section.

Q4)  What are the various states of weblogic server startup?

Ans:   STARTING–> STANDBY –> STARTING –> ADMIN –> RESUMING –> RUNNING

Note: unless, the state come to RUNNING mode, weblogic server has not come up properly.

Q5) what are the states of weblogic server stopping?

Ans:  RUNNING –> SUSPENDING –>  ADMIN –> SHUTTING DOWN

Q6) In which mode does the Admin server ask password while starting up?

Ans: In production mode, Admin server ask for password while starting up. In development mode, it doesn’t ask.

Managed server always ask for password in both the modes.

 

 

To start a weblogic server as background process without passing username/password , 2 steps are required.

1. using nohup, & and redirection >>

2. creating boot.properties

To see simple startup/stop only check here

Lets check this out in detail:

Some linux basics before we actually create the Wrapper Script.

1. nohup –> no hangup. This command will make command to run even if we close the terminal.

2.  & –> will start the command in background

3. >>  –> appending. This will append the output of left side command to file, without overwriting it.

4.  Every Linux command have two types of outputs.

i. STDOUT  –> denote as 1. This is output of command

ii. STDERR  –> denoted as 2. This is any error occurred during execution of the command.

 

So, we will append the output of startup/stop command of server in a file , which will serve as one more log file.

Admin server:

$ nohup ./startWebLogic.sh 1>>admin.log 2>&1 &

Managed Server:

$ nohup ./startManagedWebLogic.sh goodbankMng1-1 192.165.123.1:8000 1>>goodbankMng1-1.log 2>&1 &

It will ask for username/password . To avoid this prompt for username and password, we will create a file called boot.properties.

$cd $DOMAIN_HOME/servers/AdminServer/security

______________________________

$ vi boot.porperties

username=wlsadmin

password=wlsadmin

______________________________

:wq!  ( i.e.save the file)

Note: $&DOMAIN_HOME can be either  $BEA_HOME/user_projects/domain/<domain_name>/  . Instead of BEA_HOME, it can be MW_HOME also. Both are same, only name changed based upon the version you are working on.

Or it can be in $HOME location of the weblogic software user.  Generally, all domain are created under $HOME of Web Logic user so that in a glance we can know how many domains are there in this box. Otherwise we need to go to $BEA_HOME of all the installations and check there.

So, now we have created a password file. After creating it, first time we start the server, the username and password will get encrypted.

Now we will make wrapper script and will try to make it as general as possible, so that same script can be used anywhere.

 

1. Admin server

__________________________________________________

$vi StartAdmin.sh

DOMAIN_NAME=/home/wlsuser/domain/goodbankDm/

nohup $DOM AIN_HOME/bin/startWebLogic.sh 1>>admin.log 2>&1 &

__________________________________________________

2. Managed server

__________________________________________________

$vi StartMng1-1.sh     <———(  i.e. we are making startup wrapper script for Managed server 1 in box 1. There can be multiple Manged servers in a domain in multiple boxes.)

DOMAIN_NAME=/home/wlsuser/domain/goodbankDm/

nohup $DOMAIN_HOME/bin/startManagedweblogic.sh goodbankMng1-1 192.165.123.1:8000 1>> Mng1-1.log 2>&1 &

__________________________________________________

Note:  In case, you have multiple Mangd servers, just change the name of Manage server in above script.

Similarly we can create stopping script fot both Admin and Manage server.

 

3. Stoping Admin server

_________________________________________

vi StopAdmin

DOMAIN_NAME=/home/wlsuser/domain/goodbankDm/

nohup $DOM AIN_HOME/bin/stopWebLogic.sh 1>>admin.log 2>&1 &

_________________________________________

 

4. Stopping Managed server

$vi StopMng1-1.sh

DOMAIN_NAME=/home/wlsuser/domain/goodbankDm/

nohup $DOMAIN_HOME/bin/stopManagedweblogic.sh goodbankMng1-1 192.165.123.1:8000 1>> Mng1-1.log 2>&1 &

__________________________________________________

 

Congratulation, you have created wrapper scripts which can be used anywhere by just changing the server name .

 

Cheers  !! :)

 

 

 

Nohup commands to start weblogic admin and managed servers

 
<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>
START ADMIN SERVER
 
 
[oracle@oel64 bin]$ pwd
/u01/iam/Oracle/Middleware/user_projects/domains/oamdomain/bin
 
[oracle@oel64 bin]$ nohup ./startWebLogic.sh &
[1] 6209
[oracle@oel64 bin]$ nohup: ignoring input and appending output to `nohup.out'
 
[oracle@oel64 bin]$ tail -f nohup.out 
 
<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
[oracle@oel64 bin]$ nohup ./startManagedWebLogic.sh oam_server1 http://localhost:7001 >nohupOAM.out &
[3] 6520
[oracle@oel64 bin]$ nohup: ignoring input and redirecting stderr to stdout
 
[oracle@oel64 bin]$ ls -l
total 76
drwxr-x--- 2 oracle dba  4096 Feb  7 23:41 nodemanager
-rw-r--r-- 1 oracle dba     0 Feb 10 07:01 nohupAdmin.out
-rw-r--r-- 1 oracle dba  2415 Feb 10 07:07 nohupOAM.out
-rw------- 1 oracle dba 19087 Feb 10 07:06 nohup.out
drwxr-x--- 2 oracle dba  4096 Feb  7 23:41 server_migration
drwxr-x--- 2 oracle dba  4096 Feb  7 23:41 service_migration
-rwxr-x--- 1 oracle dba 17566 Feb  7 23:42 setDomainEnv.sh
-rwxr-x--- 1 oracle dba  3181 Feb  7 23:42 startManagedWebLogic.sh
-rwxr-x--- 1 oracle dba  6112 Feb  7 23:42 startWebLogic.sh
-rwxr-x--- 1 oracle dba  2394 Feb  7 23:42 stopManagedWebLogic.sh
-rwxr-x--- 1 oracle dba  1968 Feb  7 23:42 stopWebLogic.sh
[oracle@oel64 bin]$ tail -f nohupOAM.out 
 
 

nohup: ignoring input and appending output to `nohup.out'

 

When running a script using nohup piping your output to a log you may receive this message “nohup: ignoring input and appending output to `nohup.out'”. This is just a notice to tell you that standard error message will also be sent to standard out which is being redirect to a log file. This is nothing to worry about but if you would prefer not to have the message printed you can tell nohup that you want both stderr and stdout to go to the same file very easily. This is ideal for scripts run in cron or schedule to avoid unnecessary log messages.

Example of message when running a script

nohup $DOMAIN_HOME/startWebLogic.sh > ~/logs/start_$1_domain.`date +%y%m%d%H%M%S`.log &

nohup: ignoring input and appending output to `nohup.out'

 

Do the following to avoid this message.

nohup $DOMAIN_HOME/startWebLogic.sh > ~/logs/start_$1_domain.`date +%y%m%d%H%M%S`.log 2>&1 &

 

WebLogic

Stop WLS sytnax

.[full/domain/path]/bin/stopWebLogic.sh

Stop WLS example

./app/bea/wlp1032/user_projects/domains/portal_domain/bin/stopWebLogic.sh

Start WLS sytnax

.[full/domain/path]/bin/startWebLogic.sh

Start WLS example

./app/bea/wlp1032/user_projects/domains/portal_domain/bin/startWebLogic.sh

Sample nohup Start Script

#!/bin/sh

dir=/app/bea/wlp1032/user_projects/domains/f1_domain/bin/wwwlog
log=Admin.weblogic.log
export dir; export log;
echo “tail -f $dir/$log”

mv $dir/$log $dir/archived/$log.`date ‘+%m%d%y.%H%M’`
nohup ./startWebLogic.sh > $dir/$log 2>&1 &

你可能感兴趣的:(web开发)