前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >weblogi 12.2.1.4一键安装,包含补丁

weblogi 12.2.1.4一键安装,包含补丁

原创
作者头像
用户10800300
发布2023-10-20 08:40:53
4090
发布2023-10-20 08:40:53
举报
文章被收录于专栏:weblogic

1 环境

Os :centos7

Middleware:weblogic

Version: 12.2.1.4

Psu: Patch Set Update 12.2.1.4.221210

所需软件

1 unzip-6.0-24.el7_9.x86_64.rpm  解压工具

2 jdk-8u361-linux-x64.tar.gz          java环境

3 fmw_12.2.1.4.0_wls_lite_Disk1_1of1.zip  weblogic安装软件

4 p28186730_1394211_Generic.zip   opatch

5 p34883826_122140_Generic.zip        psu

注意:由于涉及到版权问题,软件需自行下载

2 脚本内容

#!/bin/bash ###################################################################### # Author : xiaozhang # # Version : V1.4 # # Function : weblogic instlall&&psu # # Date : 20230401 # # Usage : sh weblogic.sh # ###################################################################### # Modifications Section: ###################################################################### ## Date File Changes ## ## 20230401 weblogis.sh Init ## V1.0 ## 20230410 weblogis.sh Added optional Update Psu Part ## V1.1 ## 20230411 weblogis.sh Modified log ## V1.2 ## 20230412 weblogis.sh Added optional case ## V1.3 ## 20230412 weblogis.sh Added yum unzip ## V1.4 ###################################################################### #变量 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/bin:/sbin export PATH JAVA_VERSION="jdk-8u361-linux-x64.tar.gz" WEBLOGIC_PASSWORD="weblogic!2W" MW_HOME=/home/weblogic/weblogic12c #4件套 tip(){ echo -e '\E[37;44m'"\033[1m$1\033[0m" } error(){ echo -e "\033[31;1m$1\033[0m" } exec_failed(){ if [ $? -ne 0 ];then error $1 exit fi } is_file_exists(){ if [ ! -f $1 ];then error "File $1 is not exists!" exit fi } echo "######################################################################" echo "# Author : xiaozhang " echo "# Version : V1.4 " echo "# Function : weblogic instlall&&psu " echo "# Date : 20230401 " echo "# Usage : sh weblogic.sh " echo "######################################################################" #添加unzip解压包 if which unzip &>/dev/null; then echo "" else rpm -ivh unzip-6.0-24.el7_9.x86_64.rpm &>/dev/null exec_failed "unzip失败" fi firewall_stop(){ tip "关闭防火墙和selinux" ##stop firewall if egrep "7.[0-9]" /etc/redhat-release &>/dev/null; then systemctl stop firewalld systemctl disable firewalld elif egrep "6.[0-9]" /etc/redhat-release &>/dev/null; then service iptables stop chkconfig iptables off fi ##stop selinux setenforce 0 sed -i -r "/^SELINUX=/c SELINUX=disabled" /etc/selinux/config } ##安装java环境 java_install(){ if egrep "jdk" /etc/profile &>/dev/null ; then echo "java already exists"; else if [ -f $JAVA_VERSION ]; then tip "install java...." tar -zxf $JAVA_VERSION &>/dev/null exec_failed "tar command failed" mv jdk1.* /usr/jdk exec_failed "mv command failed" tip "config java env" cat << "EOF" >> /etc/profile export JAVA_HOME=/usr/jdk export JRE_HOME=/usr/jdk/jre export PATH=$JAVA_HOME/bin:$PATH export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar EOF source /etc/profile #解决随机数bug sed -i 's#securerandom.source=file:/dev/random#securerandom.source=file:/dev/./random#' $JAVA_HOME/jre/lib/security/java.security java -version exec_failed "env command failed" else tip "not java install file!" fi fi } ##创建用户 create_user(){ tip 创建weblogic用户 useradd weblogic exec_failed "创建失败" echo $WEBLOGIC_PASSWORD | passwd --stdin weblogic tip "weblogic密码是$WEBLOGIC_PASSWORD" } ##初始化文件创建 init_file(){ su - weblogic <<EOF cat >/home/weblogic/oraInst.loc<<EOF1 inventory_loc=/home/weblogic/oraInventory inst_group=weblogic EOF1 EOF ##创建weblogic软件响应文件 su - weblogic <<EOF cat >wls.rsp<<EOF2 [ENGINE] #DO NOT CHANGE THIS. Response File Version=1.0.0.0.0 [GENERIC] #The oracle home location. This can be an existing Oracle Home or a new Oracle Home ORACLE_HOME=/home/weblogic/weblogic12c #Set this variable value to the Installation Type selected. e.g. WebLogic Server, Coherence, Complete with Examples. INSTALL_TYPE=WebLogic Server #Provide the My Oracle Support Username. If you wish to ignore Oracle Configuration Manager configuration provide empty string for user name. MYORACLESUPPORT_USERNAME= #Provide the My Oracle Support Password MYORACLESUPPORT_PASSWORD=<SECURE VALUE> #Set this to true if you wish to decline the security updates. Setting this to true and providing empty string for My Oracle Support username will ignore the Oracle Configuration Manager configuration DECLINE_SECURITY_UPDATES=true #Set this to true if My Oracle Support Password is specified SECURITY_UPDATES_VIA_MYORACLESUPPORT=false #Provide the Proxy Host PROXY_HOST= #Provide the Proxy Port PROXY_PORT= #Provide the Proxy Username PROXY_USER= #Provide the Proxy Password PROXY_PWD=<SECURE VALUE> #Type String (URL format) Indicates the OCM Repeater URL which should be of the format [scheme[Http/Https]]://[repeater host]:[repeater port] COLLECTOR_SUPPORTHUB_URL= EOF2 EOF ##创建域响应文件 su - weblogic <<EOF cat >/home/weblogic/create_domain.py<<EOF3 readTemplate('$MW_HOME/wlserver/common/templates/wls/wls.jar') cd('Servers/AdminServer') set('ListenPort',7001) cd('/') cd('Security/base_domain/User/weblogic') #set admin user to weblogic cmo.setName('weblogic') #set password cmo.setPassword('$WEBLOGIC_PASSWORD') setOption('ServerStartMode','prod') setOption('OverwriteDomain','true') #set domain path writeDomain('$MW_HOME/domain') closeTemplate() exit() EOF3 EOF } ## install_weblogic() { tip "解压文件fmw_12.2.1.4.0_wls_lite_Disk1_1of1.zip" is_file_exists fmw_12.2.1.4.0_wls_lite_Disk1_1of1.zip exec_failed "文件不存在" unzip fmw_12.2.1.4.0_wls_lite_Disk1_1of1.zip exec_failed "解压失败" is_file_exists fmw_12.2.1.4.0_wls_lite_generic.jar ##修改权限 chown weblogic:weblogic fmw_12.2.1.4.0_wls_lite_generic.jar mv fmw_12.2.1.4.0_wls_lite_generic.jar /home/weblogic su - weblogic <<EOF java -jar fmw_12.2.1.4.0_wls_lite_generic.jar -silent -responseFile /home/weblogic/wls.rsp -invPtrLoc /home/weblogic/oraInst.loc EOF exec_failed "weblog文件失败" } install_domain(){ tip "开始创建domain" su - weblogic <<EOF if $MW_HOME/wlserver/common/bin/wlst.sh /home/weblogic/create_domain.py;then echo "domain创建成功" mkdir -p $MW_HOME/domain/servers/AdminServer/security/ cat >$MW_HOME/domain/servers/AdminServer/security/boot.properties<<EOF4 username=weblogic password=$WEBLOGIC_PASSWORD EOF4 else echo "domain创建失败" exit fi EOF } psu_weblogic(){ tip "开始打补丁" #升级psu tip "解压文件p28186730_1394211_Generic.zip" is_file_exists p28186730_1394211_Generic.zip exec_failed "文件不存在" unzip -q p28186730_1394211_Generic.zip exec_failed "解压失败" ##修改权限 chown -R weblogic:weblogic 6880880 mv 6880880 /home/weblogic tip "正在打补丁,时间比较长,不要关闭窗口" su - weblogic <<EOF cd 6880880 java -jar opatch_generic.jar -silent oracle_home=/home/weblogic/weblogic12c -invPtrLoc /home/weblogic/oraInst.loc >/dev/null if [ $? -ne 0 ];then echo"psu升级失败" exit else echo"psu升级成功" fi EOF #升级补丁 tip "解压文件p34883826_122140_Generic.zip" is_file_exists p34883826_122140_Generic.zip exec_failed "文件不存在" unzip -q p34883826_122140_Generic.zip exec_failed "解压失败" ##修改权限 chown -R weblogic:weblogic 34883826 mv 34883826 /home/weblogic su - weblogic <<EOF cd 34883826 /home/weblogic/weblogic12c/OPatch/opatch apply -silent >/dev/null if [ $? -ne 0 ];then echo"补丁升级失败" exit else echo"补丁升级成功" fi EOF } start_weblogic() { tip "开始启动weblogic" su - weblogic <<EOF sed -i -r "/WLS_MEM_ARGS_64BIT=\"-Xms256m -Xmx512m\"/c WLS_MEM_ARGS_64BIT=\"-Xms4096m -Xmx8192m\"" $MW_HOME/domain/bin/setDomainEnv.sh nohup $MW_HOME/domain/bin/startWebLogic.sh& if [ $? -ne 0 ];then echo"webloc启动失败,请查看nohup.out日志" exit fi sleep 5 tail -f nohup.out EOF } echo echo -e "\t Menu\n" echo -e "1. Install weblogic soft&&domain" echo -e "2. Install weblogic soft&&domain&&psu" echo -e "3. Quit" read -p "请输入编号:" number case $number in 1) firewall_stop java_install create_user init_file install_weblogic install_domain start_weblogic ;; 2) firewall_stop java_install create_user init_file install_weblogic install_domain psu_weblogic start_weblogic ;; 3) eixt ;; esac

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 1 环境
  • 2 脚本内容
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档