jojo's blog--快乐忧伤都与你同在
为梦想而来,为自由而生。 性情若水,风起水兴,风息水止,故时而激荡,时又清平……
posts - 11,  comments - 30,  trackbacks - 0
[mdrop@deployment1-1 newDeploy]$ cat setup_gf.sh
#!/bin/bash

# Do not edit below , please supply variable in command line
ACTION=$1
COBRAND=$2
GLASS_FISH=$3
DOMAIN=domain1
MASTERIP=$4
ACTIVEMQ=$5
INSTANCE_NO=$6
JDBC_USER=$7
JDBC_PASSWORD=$8
JDBC_HOST=$9



CLUSTER=ps-$COBRAND-cluster
NODE=ps-$COBRAND-node-$INSTANCE_NO
INSTANCE=ps-$COBRAND-instance-$INSTANCE_NO


function common () {


#those two command should be executed in master and slave machine
cp mysql-connector-java-5.1.5-bin.jar $GLASS_FISH/lib
cp obrealm.jar  $GLASS_FISH/lib
cp -rf activeMQ_config/*  $ACTIVEMQ/

if [ $ACTION = "master" ]; then
$GLASS_FISH/bin/asadmin stop-domain $DOMAIN
$GLASS_FISH/bin/asadmin start-domain $DOMAIN
fi

#run those following lines to stop cluster and node in the master machine
if [ $ACTION = "master" ]; then
$GLASS_FISH/bin/asadmin stop-cluster --user admin --host  $MASTERIP  --port 4848 $CLUSTER
fi
$GLASS_FISH/bin/asadmin stop-node-agent $NODE

#run those following lines to delete node, cluster and instance in the master machine
$GLASS_FISH/bin/asadmin delete-node-agent  $NODE
if [ $ACTION = "master" ]; then
$GLASS_FISH/bin/asadmin delete-cluster  $CLUSTER
fi
$GLASS_FISH/bin/asadmin delete-instance  $INSTANCE


#run those following lines to create node, cluster and instance in the master machine
$GLASS_FISH/bin/asadmin create-node-agent --host $MASTERIP --port 4848 $NODE
if [ $ACTION = "master" ]; then
$GLASS_FISH/bin/asadmin create-cluster --host $MASTERIP --port 4848 $CLUSTER
fi
$GLASS_FISH/bin/asadmin create-instance --host $MASTERIP --port 4848 --nodeagent $NODE --cluster $CLUSTER $INSTANCE



#run those following lines to start node, cluster and instance in the master machine
#bin/asadmin start-node-agent --syncinstances=true $NODE
#bin/asadmin start-cluster --user admin --host $MASTERIP --port 4848 $CLUSTER
#bin/asadmin start-instance --user admin --host $MASTERIP --port 4848 $INSTANCE

}

function master () {

#cp -r classes/* $GLASS_FISH/domains/$DOMAIN/lib/classes/

cp  activemq-rar-5.1.0.rar  $GLASS_FISH/

#those two command should be executed in master and slave machine
cp mysql-connector-java-5.1.5-bin.jar $GLASS_FISH/lib
cp obrealm.jar  $GLASS_FISH/lib

$GLASS_FISH/bin/asadmin stop-domain $DOMAIN
$GLASS_FISH/bin/asadmin start-domain $DOMAIN



$GLASS_FISH/bin/asadmin set $CLUSTER.java-config.classpath-suffix='${com.sun.aas.installRoot}/lib/mysql-connector-java-5.1.5-bin.jar'
$GLASS_FISH/bin/asadmin set $CLUSTER.java-config.classpath-suffix='${com.sun.aas.installRoot}/lib/obrealm.jar'
mkdir -p /usr/local/site/webroot/template/pointsystem/
$GLASS_FISH/bin/asadmin set $CLUSTER.system-property.com_outblaze_config_cobrand='/usr/local/site/webroot/template/pointsystem/'
$GLASS_FISH/bin/asadmin create-auth-realm --classname com.outblaze.glassfish.security.OBAppservRealm --property auth-type=obRealm:jaas-context=obRealm --target $CLUSTER obRealm

echo "obRealm {com.outblaze.glassfish.security.OBPasswordLoginModule required;};" >> $GLASS_FISH/domains/$DOMAIN/config/login.conf

$GLASS_FISH/bin/asadmin  set $CLUSTER.http-service.virtual-server.server.property.accessLoggingEnabled=true
echo "finished setting the access log "

$GLASS_FISH/bin/asadmin delete-jdbc-connection-pool --cascade=true --target $CLUSTER mysqlPool
$GLASS_FISH/bin/asadmin create-jdbc-connection-pool --datasourceclassname com.mysql.jdbc.jdbc2.optional.MysqlXADataSource --restype javax.sql.XADataSource --isolationlevel read-committed --isisolationguaranteed --property User=$JDBC_USER:Password=$JDBC_PASSWORD:URL="jdbc":mysql"://$JDBC_HOST/pointsystem_sd" --target $CLUSTER mysqlPool
$GLASS_FISH/bin/asadmin create-jdbc-resource --connectionpoolid mysqlPool --target $CLUSTER jndi/cobrandpsDS
$GLASS_FISH/bin/asadmin delete-jdbc-connection-pool --cascade=true --target $CLUSTER mysqlPoolOffline
$GLASS_FISH/bin/asadmin create-jdbc-connection-pool --datasourceclassname com.mysql.jdbc.jdbc2.optional.MysqlXADataSource --restype javax.sql.XADataSource --isolationlevel read-committed --isisolationguaranteed --property User=$JDBC_USER:Password=$JDBC_PASSWORD:URL="jdbc":mysql"://$JDBC_HOST/pointsystem_off" --target $CLUSTER mysqlPoolOffline
$GLASS_FISH/bin/asadmin create-jdbc-resource --connectionpoolid mysqlPoolOffline --target $CLUSTER jndi/cobrandpsDS_of
$GLASS_FISH/bin/asadmin delete-jdbc-connection-pool --cascade=true --target $CLUSTER mysqlPoolLog
$GLASS_FISH/bin/asadmin create-jdbc-connection-pool --datasourceclassname com.mysql.jdbc.jdbc2.optional.MysqlXADataSource --restype javax.sql.XADataSource --isolationlevel read-committed --isisolationguaranteed --property User=$JDBC_USER:Password=$JDBC_PASSWORD:URL="jdbc":mysql"://$JDBC_HOST/wslog_stats_db" --target $CLUSTER mysqlPoolLog
$GLASS_FISH/bin/asadmin create-jdbc-resource --connectionpoolid mysqlPoolLog --target $CLUSTER jndi/cobrandpsDS_log
$GLASS_FISH/bin/asadmin delete-jdbc-connection-pool --cascade=true --target $CLUSTER itemmallsqlPool
$GLASS_FISH/bin/asadmin create-jdbc-connection-pool --datasourceclassname com.mysql.jdbc.jdbc2.optional.MysqlXADataSource --restype javax.sql.XADataSource --isolationlevel read-committed --isisolationguaranteed --property User=$JDBC_USER:Password=$JDBC_PASSWORD:URL="jdbc":mysql"://$JDBC_HOST/obcart" --target $CLUSTER itemmallsqlPool
$GLASS_FISH/bin/asadmin create-jdbc-resource --connectionpoolid itemmallsqlPool --target $CLUSTER jndi/itemmallDS

$GLASS_FISH/bin/asadmin delete-jdbc-connection-pool --cascade=true --target $CLUSTER mysqlPoolpsClusterTimer
$GLASS_FISH/bin/asadmin create-jdbc-connection-pool --datasourceclassname com.mysql.jdbc.jdbc2.optional.MysqlXADataSource --restype javax.sql.XADataSource --isolationlevel read-committed --isisolationguaranteed --property User=$JDBC_USER:Password=$JDBC_PASSWORD:URL="jdbc":mysql"://$JDBC_HOST/glassfishtimer" --target $CLUSTER mysqlPoolpsClusterTimer
$GLASS_FISH/bin/asadmin create-jdbc-resource --connectionpoolid mysqlPoolpsClusterTimer --target $CLUSTER jndi/ps_cluster_timer

$GLASS_FISH/bin/asadmin delete-jdbc-connection-pool --cascade=true --target $CLUSTER reportPool
$GLASS_FISH/bin/asadmin create-jdbc-connection-pool --datasourceclassname com.mysql.jdbc.jdbc2.optional.MysqlXADataSource --restype javax.sql.XADataSource --isolationlevel read-committed --isisolationguaranteed --property User=$JDBC_USER:Password=$JDBC_PASSWORD:URL="jdbc":mysql"://$JDBC_HOST/pointsystem_sd" --target $CLUSTER reportPool
$GLASS_FISH/bin/asadmin create-jdbc-resource --connectionpoolid reportPool --target $CLUSTER jndi/reportDS

$GLASS_FISH/bin/asadmin set $CLUSTER-config.ejb-container.ejb-timer-service.timer-datasource=jndi/ps_cluster_timer

#$GLASS_FISH/bin/asadmin create-jvm-options --target $CLUSTER -Dcom.sun.enterprise.web.connector.enableJK=8012
#$GLASS_FISH/bin/asadmin create-jvm-options --target $CLUSTER -DjvmRoute=glassfish1
#$GLASS_FISH/bin/asadmin create-jvm-options --target $CLUSTER -DjvmRoute=glassfish2
#$GLASS_FISH/bin/asadmin set $CLUSTER.java-config.classpath-prefix='${com.sun.aas.installRoot}/lib/patch.jar'
#$GLASS_FISH/bin/asadmin set $CLUSTER.java-config.system-classpath='${com.sun.aas.installRoot}/lib/tomcat-ajp.jar,${com.sun.aas.installRoot}/lib/commons-modeler.jar,${com.sun.aas.installRoot}/lib/commons-logging.jar'


}

function setupmq () {


echo "Prepare for MQ"
echo "============================================================================="
$GLASS_FISH/bin/asadmin delete-jmsdest  --desttype queue --target $CLUSTER ActiveMqQueue
$GLASS_FISH/bin/asadmin delete-admin-object --target $CLUSTER jms/ActiveMqQueue
$GLASS_FISH/bin/asadmin delete-connector-resource --target $CLUSTER jms/ActiveMQConnectionFactory
$GLASS_FISH/bin/asadmin delete-connector-connection-pool --target $CLUSTER jms/ActiveMQpool
$GLASS_FISH/bin/asadmin undeploy --target $CLUSTER activemq-rar-5.1.0
echo "finished prepare for MQ"
echo "============================================================================="


echo "Start config for MQ"
echo "--------------------------------------------------------------------------------"
$GLASS_FISH/bin/asadmin deploy --target $CLUSTER activemq-rar-5.1.0.rar
echo "finished deploying activemq-rar-5.1.0.rar"

$GLASS_FISH/bin/asadmin create-admin-object --raname activemq-rar-5.1.0 --restype javax.jms.Queue --property DestinationJndiName=ActiveMqQueue --target $CLUSTER jms/ActiveMqQueue
echo "finished create admin object jms/ActiveMqQueue"

$GLASS_FISH/bin/asadmin create-jmsdest --desttype queue --target $CLUSTER ActiveMqQueue
echo "finished create jmsdest ActiveMqQueue"

$GLASS_FISH/bin/asadmin create-connector-connection-pool --raname activemq-rar-5.1.0 --connectiondefinition javax.jms.ConnectionFactory --transactionsupport  XATransaction --target $CLUSTER jms/ActiveMQpool
echo "finished create connector connection pool jms/ActiveMQpool"

$GLASS_FISH/bin/asadmin create-connector-resource --poolname jms/ActiveMQpool --target $CLUSTER jms/ActiveMQConnectionFactory
echo "finished create connector resource jms/ActiveMQConnectionFactory"

echo "MQ Setup complete"
echo "--------------------------------------------------------------------------------"


}

if [ $# != 9 ]; then
        echo $"Usage: $prog {master|slave cobrand_name glassfish_path DAS_hostname ActiveMQ_path instance_no mysql_username mysql_password mysql_host}"
        exit 1
fi

case "$1" in
  master)
        common
        master
        setupmq
        ;;
  slave)
        common
        ;;
  *)
        echo $"Usage: $prog {master|slave cobrand_name glassfish_path DAS_hostname ActiveMQ_path instance_no mysql_username mysql_password mysql_host}"
        exit 1
esac

posted on 2009-07-31 11:53 Blog of JoJo 阅读(602) 评论(0)  编辑  收藏 所属分类: 每日一记My Script

只有注册用户登录后才能发表评论。


网站导航:
 

<2024年12月>
24252627282930
1234567
891011121314
15161718192021
22232425262728
2930311234

常用链接

留言簿(6)

随笔档案

文章分类

文章档案

新闻分类

新闻档案

相册

收藏夹

搜索

  •  

最新评论

阅读排行榜

评论排行榜