linux中利用Shell脚本实现自动安装部署weblogic服务
安装weblogic版本:wls1036_linux64
#!/bin/bash ############################################### echo "" echo "" echo "**************************************" echo "* *" echo "* *" echo "* WebLogic服务自动安装部署 *" echo "* *" echo "* *" echo "**************************************" echo "" echo "" echo "*****安装时间大约需要25分钟,请耐心等待*****" #获取脚本所在的当前路径 path_now=$(cd "$(dirname "$0")"; pwd) echo "脚本执行当前路径为{$path_now}" #声明变量:安装weblogic的路径 path_weblogic=/home/username/Oracle/Middleware/wlserver_10.3/common/bin #weblogic启动文件路径 path_startWebLogic=/home/username/domains/base_domain/bin #节点服务的启动脚本路径 path_node=/home/username/Oracle/Middleware/wlserver_10.3/server/bin #节点管理nodemanager.properties文件地址 path_nodepro=/home/username/Oracle/Middleware/wlserver_10.3/common/nodemanager #upload 文件夹 path_upload=/home/username/upload echo "" echo "判断是否存在upload文件夹,如果不存在则新建upload文件夹" if [ -d $path_upload ] then echo "upload文件夹已经创建,不需要重复创建!" else mkdir -p /home/username/upload echo "upload文件夹创建成功!" fi echo "" echo "创建web/wars路径,用于应用部署" if [ -d /home/username/web/wars ] then echo "web/wars路径已经存在" else mkdir -p /home/username/web/wars echo "web/wars路径创建成功" fi echo "" echo "1.安装weblogic服务,默认安装路径为:/home/username/Oracle/Middleware" ./wls1036_linux64.bin -mode=silent -silent_xml=silent.xml -log=$path_now/weblogic.out sleep 2s echo "1.安装webloigc服务完成" echo "2.配置weblogic域路径,默认域路径为:/home/username/domains/basedomain" cd $path_weblogic ./config.sh -mode=silent -silent_script=$path_now/create_domain.rsp echo "2.配置weblogic域路径完成!" echo "3.添加hibernate映射文件jar包" cd $path_now cp antlr-2.7.6rc1.jar /home/username/Oracle/Middleware/wlserver_10.3/server/ext/ sleep 2s echo "3.添加hibernate映射文件jar包成功!" echo "4.修改startWebLogic.sh启动文件,添加jar包引用路径!" sed -i '/umask 037/a\PRE_CLASSPATH="${WL_HOME}/server/ext/antlr-2.7.6rc1.jar"\ CLASSPATH="${PRE_CLASSPATH}:${CLASSPATH}"\ JAVA_OPTIONS="${JAVA_OPTIONS} -Dweblogic.security.SSL.ignoreHostnameVerification=true"' $path_startWebLogic/startWebLogic.sh sleep 2s echo "4.修改startWebLogic.sh启动文件成功!" echo "5.启动节点服务" str="/n" cd $path_node nohup ./startNodeManager.sh & sstr=$(echo -e $str) sleep 2s echo "5.启动节点服务完成!" echo "6.修改nodemanager.properties文件,开启监听!(nodemanager.properties文件生成时间较久)" echo "因此写了一个循环,不出现就一直循环下去,直到出现这个文件为止" while [ 0 ]; do if [ ! -e $path_nodepro/nodemanager.properties ] then echo "不存在nodemanager.properties文件,请等待10秒,不要关闭脚本!" sleep 10s else echo "已经生成nodemanager.properties文件,正在修改!" sed -i 's/SecureListener=true/SecureListener=false/g' $path_nodepro/nodemanager.properties sed -i 's/StartScriptEnabled=false/StartScriptEnabled=true/g' $path_nodepro/nodemanager.properties break fi done sleep 2s echo "6.修改nodemanager.properties文件完成!" echo "7.注册管理节点服务器" cd $path_weblogic ./wlst.sh $path_now/wlsttest.py echo "7.注册管理节点服务器完成!" echo "" echo "8.将节点服务杀死,并进行重启" ID=`ps -ef | grep "weblogic.NodeManager" | grep -v "grep" | awk '{print $2}'` echo "8.查到的阶段服务进程为:$ID" for id in $ID do kill -9 $id echo "killed $id" done echo "" echo "9.重启节点服务" str1="/n" cd $path_node nohup ./startNodeManager.sh & sstr1=$(echo -e $str1) sleep 2s echo "9.节点服务已重启完成!" echo "" echo "**********TMS系统weblogc服务安装配置结束!**********"
静默安装weblogic的silent.xml文件
data-value中不能出现空格回车等其他字符,要一行结束
<?xml version="1.0" encoding="utf-8"?> <bea-installer> <input-fields> <data-value name="BEAHOME" value="/home/username/Oracle/Middleware"/> <data-value name="WLS_INSTALL_DIR" value="/home/username/Oracle/Middleware/wlserver_10.3"/> <data-value name="COMPONENT_PATHS" value="WebLogic Server/Core Application Server|WebLogic Server/Administration Console|WebLogic Server/Configuration Wizard and Upgrade Framework|WebLogic Server/Web 2.0 HTTP Pub-Sub Server|WebLogic Server/WebLogic SCA|WebLogic Server/WebLogic JDBC Drivers|WebLogic Server/Third Party JDBC Drivers|WebLogic Server/WebLogic Server Clients|WebLogic Server/WebLogic Web Server Plugins|WebLogic Server/UDDI and Xquery Support|WebLogic Server/Evaluation Database|Oracle Coherence/Coherence Product Files"/> <data-value name="NODEMGR_PORT" value="5559"/> </input-fields> </bea-installer>
创建域的create_domain.rsp文件
read template from "/home/username/Oracle/Middleware/wlserver_10.3/common/templates/domains/wls.jar"; set JavaHome "/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.131.x86_64"; set ServerStartMode "prod"; //生产模式 find Server "AdminServer" as AdminServer; set AdminServer.ListenAddress "10.1.1.1"; set AdminServer.ListenPort "7001"; set AdminServer.SSL.Enabled "false"; //set AdminServer.SSL.ListenPort "7002"; //We can directly create a new managed server. //create Server "base" as BASE; //set BASE.ListenAddress ""; //set BASE.ListenPort "8003"; //set BASE.SSL.Enabled "true"; //set BASE.SSL.ListenPort "8004ยกรฅ //Create Machine //create Machine "base" as Machinename; //use templates default weblogic user find User "weblogic" as u1; set u1.password "weblogic123"; write domain to "/home/username/domains/base_domain/"; //创建域 // The domain name will be "demo-domain" close template;
注册节点服务器的文件
connect('weblogic','weblogic123','t3://10.1.1.1:7001') nmEnroll('/home/username/Oracle/Middleware/wlserver_10.3/common/nodemanager') nmEnroll('/home/username/domains/base_domain') exit()
至此weblogic安装完毕,文章出自https://blog.csdn.net/liusure09/article/details/79880514