集群启动与停止一键操作

集群往往横跨多台物理机器,每次启动停止需要分别连上多台机器,比较麻烦。
可以通过一个脚本来完成这些工作如下:

一两台机器为例,其中两个ManagedServer,一个Admin Server,一个Proxy Server。
Environment: Solaris 10 X86 + Weblogic 10.2

Configuration:

Weblogic user configuration:

Server1:

bash-3.00$ ssh-keygen -t rsa

Generating public/private rsa key pair.

Enter file in which to save the key (/export/home/weblogic/.ssh/id_rsa):

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /export/home/weblogic/.ssh/id_rsa.

Your public key has been saved in /export/home/weblogic/.ssh/id_rsa.pub.

The key fingerprint is:

6c:3a:d1:69:e1:aa:69:5d:c6:23:d9:96:6d:ba:cd:be weblogic@unknown



Server2:

bash-3.00$ ssh-keygen -t rsa

Generating public/private rsa key pair.

Enter file in which to save the key (/export/home/weblogic/.ssh/id_rsa):

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /export/home/weblogic/.ssh/id_rsa.

Your public key has been saved in /export/home/weblogic/.ssh/id_rsa.pub.

The key fingerprint is:

c0:c0:78:3b:8b:be:9e:1c:c7:73:3d:bc:60:ea:71:69 weblogic@unknown



Server1:

bash-3.00$ scp /export/home/weblogic/.ssh/id_rsa.pub Server2 IP:/export/home/weblogic/.ssh/authorized_keys

Password:

id_rsa.pub           100% |***************************************************|   226       00:00



Server2:

bash-3.00$ scp /export/home/weblogic/.ssh/id_rsa.pub Server1 IP:/export/home/weblogic/.ssh/authorized_keys

Password:

id_rsa.pub           100% |******************************************|   226       00:00   

bash-3.00$



Start Cluster:

Use weblogic user to login:

bash-3.00$ start_ABC_cluster.sh



Stop Cluster:

bash-3.00$ stop_ABC_cluster.sh

Shell Script:
Start:
DOMAIN_HOME="/opt/weblogic/.../"

echo "begin start admin server"
nohup ${DOMAIN_HOME}/bin/startWebLogic.sh & $*

echo "begin start M1 server"
nohup ${DOMAIN_HOME}/bin/startManagedWebLogic.sh M1 192.168.81.219:9001 & $*

echo "begin connect to 192.168.81.143"

echo "begin start M2 server"
nohup ssh [email protected] "/opt/.../bin/startManagedWebLogic.sh M2 192.168.81.219:9001" & $*

echo "begin start P1 server"
nohup ssh [email protected] "/opt/.../bin/startManagedWebLogic.sh P1 192.168.81.219:9001" & $*


Stop:
DOMAIN_HOME="/opt/.../"

echo "begin stop P1 server"
ssh [email protected] "/opt/.../bin/stopManagedWebLogic.sh P1 192.168.81.219:9001" $*

echo "begin stop M2 server"
ssh [email protected] "/opt/.../bin/stopManagedWebLogic.sh M2 192.168.81.219:9001" $*

echo "begin stop M1 server"
${DOMAIN_HOME}/bin/stopManagedWebLogic.sh M1 192.168.81.219:9001 $*

echo "begin stop admin server"
${DOMAIN_HOME}/bin/stopWebLogic.sh $*

你可能感兴趣的:(weblogic,Solaris,ssh,脚本,bash)