javascript
宝兰德BES安装及Springboot项目打包部署及websocket解决方案
隨著軟件國(guó)產(chǎn)化越來(lái)越普及,客戶在實(shí)施中選擇了寶蘭德,這幾天終于弄好,發(fā)個(gè)文章記錄一下。
2.bes安裝,在實(shí)施過(guò)程中,將安裝步驟整合成shell腳本了,方便新服務(wù)器一鍵安裝,腳本包含內(nèi)容:一鍵安裝參數(shù)檢查、解壓安裝包、導(dǎo)入證書(shū)、指定密碼、實(shí)例配置、修改JVM、創(chuàng)建啟停腳本、權(quán)限控制、安裝補(bǔ)丁等等(具體腳本中都有備注,可根據(jù)實(shí)際情況修改里面的參數(shù))
#!/bin/bash # #********************************************************************************************** #Author: TIL #Date: 2022-06-13 #FileName: BES_standalone_install.sh #腳本執(zhí)行格式: sh BES_standalone_install.sh 安裝包名 /安裝路徑 用戶名 HTTP端口 CONSOLE端口 JMX端口 JDK路徑 #示例: sh BES_standalone_install.sh BOSH-BES952-standalone-install.tar uuop /uuop 28080 19200 10081 /usr/java/jdk1.8.0_251 #********************************************************************************************** DIR=`pwd` BES_FILE=$1 #BOSH-BES952-standalone-install.tar BES_USER=$2 BES_DIR=$3 HTTP_PORT=$4 #默認(rèn)28080 CONSOLE_PORT=$5 #默認(rèn)19200 JMX_PORT=$6 #默認(rèn)10081 JAVA_HOME=$7echo -e "\nParameters checking...\n" ####判斷參數(shù)個(gè)數(shù)############ if ! [ $# -eq 7 ];thenecho "please check Parameters!"exit 1 fi#####判斷BES安裝包####### if [ ! -f "$DIR/$BES_FILE" ];thenecho "file $BES_FILE not exist!"exit 2; fi#####判斷用戶######### if ! id -u $BES_USER >/dev/null 2>&1; thenecho "user $BES_USER not exist!"exit 3 fi#####判斷安裝目錄是否已存在####### if [ ! -d "$BES_DIR" ];thenecho "dir $BES_DIR not exit!"exit 4 fi #####判斷安裝目錄下是否已存在BES目錄####### BES_HOME=$BES_DIR/BES952 echo $BES_HOME if [ -d "$BES_HOME" ];thenecho "dir $BES_HOME exist!"exit 5 fi#####判斷http端口占用## if netstat -ltn|grep :$HTTP_PORT >/dev/null 2>&1; thenecho "port $HTTP_PORT used!"exit 6 fi#####判斷console端口占用## if netstat -ltn|grep :$CONSOLE_PORT >/dev/null 2>&1; thenecho "port $CONSOLE_PORT used!"exit 7 fi#####判斷jmx端口占用## if netstat -ltn|grep :$JMX_PORT >/dev/null 2>&1; thenecho "port $JMX_PORT used!"exit 8 fi if [ $JMX_PORT -gt 10090 ] || [ $JMX_PORT -lt 10071 ];thenecho "port $JMX_PORT error! in 10071~10090"exit 9 fi #####判斷jdk路徑######### if ! [ -d $JAVA_HOME ]; thenecho "jdk $JAVA_HOME not exist!"exit 10 fi echo -e "\nParameters normal!\n" sleep 2#解壓安裝包 echo "=====================decompression=======================" tar -xvf ${BES_FILE} -C $BES_DIR cd $BES_DIR/BES952/installtar -zxvf BES-9.5.2.4703.tar.gz -C ${BES_HOME}#JAVA sed -i "8a\ " ${BES_HOME}/bin/setenv.conf sed -i "9a\export JAVA_HOME=$JAVA_HOME" ${BES_HOME}/bin/setenv.conf sed -i "10a\export PATH=\$PATH:\$JAVA_HOME/bin" ${BES_HOME}/bin/setenv.conf sed -i "11a\ " ${BES_HOME}/bin/setenv.conf#導(dǎo)入證書(shū) #echo "================import license======================" #cd ${BES_HOME}/bin #./lmadm import-lic --sourcepath=${BES_HOME}/license/bes.lic.txt #./lmadm view-lic #echo ""#修改passport echo "==================change passport========================" cd ${BES_HOME}/bin ./iastool --user admin --password B#2008_2108#es --passport B#2008_2108#es change --passport --oldpassword B#2008_2108#es --newpassword B@20211225es --confirmnewpasswo rd B@20211225es echo ""#初始化應(yīng)用服務(wù)器實(shí)例配置 echo "=================== initstore =========================" ./config --user=admin --password=B#2008_2108#es --adminuser=admin --adminpassword=Hello123! --adminhost=0.0.0.0 --adminport=${CONSOLE_PORT:=19200} --userhost=0.0.0.0 --userport=${HTTP_PORT:=28080} echo ""#啟動(dòng)BES echo "=================== start bes =========================" ./iastool --user=admin --passwordfile ${BES_HOME}/conf/.password --port ${CONSOLE_PORT:=19200} start --server echo ""#創(chuàng)建server的zabbix用戶 echo "====================add user zabbix======================" ./iastool --passwordfile ${BES_HOME}/conf/.password --port ${CONSOLE_PORT:=19200} create --file-user --realmname admin-realm --userpassword Zabbix123! --confirmpasswordZabbix123! --groups besadmin zabbix cd ${BES_HOME}/conf/security sed -i '/zabbix/s/besadmin//' admin-keyfile echo ""#修改server的JVM大小 echo "===================change server jvm=====================" cd ${BES_HOME}/bin ./iastool --user=admin --passwordfile ${BES_HOME}/conf/.password --port ${CONSOLE_PORT:=19200} update --jvm-options --xmx 5120 --xms 2048 --metaspacesize 5120 --maxmetas pacesize 2048 echo ""#修改server的線程池 echo "===============change server threadpool==================" ./iastool --user=admin --passwordfile ${BES_HOME}/conf/.password --port ${CONSOLE_PORT:=19200} update --thread-pool --maxthreads 200 --minsparethreads 10 http-thr ead-pool echo ""#開(kāi)啟server的access log echo "================open server accesslog====================" ./iastool --user=admin --passwordfile ${BES_HOME}/conf/.password --port ${CONSOLE_PORT:=19200} update --http-service --globalaccesslogenabled true echo ""#修改jmx端口 echo "==================change jmx port =======================" ./iastool --user=admin --passwordfile ${BES_HOME}/conf/.password --port ${CONSOLE_PORT:=19200} update --jmx-connector --listenerport ${JMX_PORT:=10081} echo ""#創(chuàng)建啟停腳本 echo "==============create start/stop scripts==================" cd ${BES_HOME} cat > stopbes.sh <<EOF echo "================shutdown instance======================" cd $BES_HOME/bin ./iastool --user=admin --passwordfile $BES_HOME/conf/.password --port ${CONSOLE_PORT:=19200} stop --server echo "" EOFcat > startbes.sh <<EOF echo "==================start instance=======================" cd $BES_HOME/bin ./iastool --user=admin --passwordfile $BES_HOME/conf/.password --port ${CONSOLE_PORT:=19200} start --server echo "" EOFchmod 750 stopbes.sh chmod 750 startbes.sh#復(fù)制數(shù)據(jù)庫(kù)驅(qū)動(dòng)包 echo "================copy jdbc jar=======================" cd ${BES_HOME}/install/jdbcdriver cp ojdbc6.jar mysql-connector-java-5.1.29-bin.jar ${BES_HOME}/lib echo ""#安裝補(bǔ)丁 echo "================install patch========================" cd ${BES_HOME}/bin ./patch -path ${BES_HOME}/install/instancepatch/ ./patch -list echo ""#修改控制臺(tái)超時(shí)時(shí)間 echo "==============console timeout=======================" cd ${BES_HOME}/lib/system/apps/console/WEB-INF sed -i 's/30/15/g' web.xml echo ""#重啟 echo "================restart all=========================" cd ${BES_HOME} sh stopbes.sh sh startbes.sh echo ""#cd ${BES_HOME}/../ #mv BOSH-BES952-standalone-install.tar bes952_standalone_install_v1.0.sh ${BES_HOME}/installecho -e "\nprocess status:\n" ps aux|egrep -v "grep|$0"|grep BES952 pid=`ps aux|egrep -v "grep|$0"|grep BES952|awk '{print $2}'` sleep 1 echo -e "\nport listen:\n" for a in $pid;do netstat -nlpt|grep $a;sleep 1;doneecho "" echo "" echo "================install bes end======================" echo "0"安裝成功后,就可以訪問(wèn)到應(yīng)用的控制臺(tái)了,默認(rèn)地址為:http://ip:19200/console,登錄用戶名密碼默認(rèn)為admin/Hello123!(如果自己改過(guò)默認(rèn)密碼,則按自己的來(lái)。)
?進(jìn)入控制臺(tái)后,就可以通過(guò)應(yīng)用管理-常用應(yīng)用來(lái)部署項(xiàng)目包了。根據(jù)提示一步步往下點(diǎn)擊就可以。
整合方案:?
第一種: 之前在網(wǎng)上找資料看到說(shuō)springboot部署寶蘭德有jar包的改造,這里就想說(shuō)明下,如果最終應(yīng)用要部署在bes單實(shí)例或者集群版本的話,即通過(guò)控制臺(tái)部署應(yīng)用,就不能集成寶蘭德的內(nèi)嵌包,否則會(huì)造成jar包沖突。即com.bes.enterprise.logging.internal.Log: Provider com.bes.enterprise.jul.formatter.log.BESASLog not a subtype 這個(gè)問(wèn)題也坑了我好久。
bes和tomcat中間件針對(duì)springboot的部署方式一致的,因此這種情況,不需要做單獨(dú)的改造
第二種: 只有單集成寶蘭德時(shí),才需要在項(xiàng)目中添加相應(yīng)的jar包,如下所示(程序包由寶蘭德提供,不要自己傻傻的從寶蘭德安裝包中找,因?yàn)槲疫@么干過(guò),不想大家再走彎路)
| 包名 | 說(shuō)明 |
| bes-lite-spring-boot-2.x-starter-9.5.2 | 核心包,必須 |
| bes-actuator-spring-boot-2.x-starter-9.5.2.jar | 監(jiān)控包,可選 |
| bes-websocket | 支持 websocket |
| bes-gmssl | 國(guó)密安全包,可選 |
| bes-jasper | 支持JSP,可選 |
| bes-jdbcra | 支持JDBC ,可選 |
項(xiàng)目pom中去掉 spring-boot-starter-web 的 tomcat依賴,將上面用到的包放到自己的私服后,在pom中添加如下內(nèi)容:
<dependency><groupId>com.bes.appserver</groupId><artifactId>bes-lite-spring-boot-2.x-starter</artifactId><version>9.5.2</version> </dependency><dependency><groupId>com.bes.appserver</groupId><artifactId>bes-websocket</artifactId><version>9.5.2</version> </dependency>?應(yīng)用啟動(dòng)時(shí),打印出以下信息,就說(shuō)明改造成功了:
?websocket問(wèn)題解決:
因?yàn)槲覀冺?xiàng)目中用到了websocket,因此在控制臺(tái)部署時(shí)候,遇到了啟動(dòng)失敗的問(wèn)題Caused by: java.lang.IllegalStateException: No suitable default RequestUpgradeStrategy found,其實(shí)是因?yàn)閟pring-websocket對(duì)于第三方的接入不太友好,限制了只能使用tomcat,這種情況的話,如果是通過(guò)xml配置的話,可以通過(guò)配置handshakeHandler解決(具體參考jetty的接入方案),但是如果是通了Bean配置的,那就只能通過(guò)重寫(xiě)spring-websocket的org.springframework.web.socket.server.support.DefaultHandshakeHandler類來(lái)解決問(wèn)題
?通過(guò)配置WEB-INF/bes-web.xml來(lái)確保bes使用上面重寫(xiě)的這個(gè)jar包
?bes-web.xml內(nèi)容如下:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <!DOCTYPE bes-web-app PUBLIC "-//BES Software Corporation//DTD BES Application Server %version Servlet 2.5//EN" "http://www.bessystem.com/appserver/dtds/bes-web-app_2_5-0.dtd"> <bes-web-app><resources><pre-resources base="/home/BES/lib/spring-websocket-bes-support-9.5.2.jar" class-name="com.bes.enterprise.webtier.webresources.JarResourceSet" web-app-mount="/WEB-INF/classes" /></resources> </bes-web-app>修改完成后,重新部署應(yīng)用即可,可以通過(guò)應(yīng)用名稱,看到應(yīng)用的訪問(wèn)鏈接
以下就是本次寶蘭德變更涉及到的全部?jī)?nèi)容,如有問(wèn)題,歡迎提問(wèn)。
總結(jié)
以上是生活随笔為你收集整理的宝兰德BES安装及Springboot项目打包部署及websocket解决方案的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 2021-11-15 cv2.erode
- 下一篇: JavaScript实现移动端跟手轮播图