安装weblogic12c的shell脚本文件

安装weblogic12c的shell脚本文件

安装

使用脚本的前提:

  1. 适版本最低要求weblogic12c,以上版本未验证;

  2. 确保JDK环境变量以配置好(不支持OpenJDK)

  3. 该脚本包含默认机制和参数机制两种

    默认机制:使用指定的安装包文件名(fmw_12.1.3.0.0_wls.jar)并确认安装包文件上传到指定位置(/software);

    参数机制:参数1指定安装包位置;参数2指定安装包文件名;参数3指定BEA_HOME(安装根目录位置);

  4. 如果是基于Windows下编辑迁移至Linux,请核查语法如下,并打开文件执行set fileformat=unix保存并退出(文件格式)

    bash -n installWebLogic.sh
    

该脚本只是安装了weblogic,并没有创建域,有关创建域的,可以根据weblogic安装目录下的域模板脚本自行改动,或其他方式自行建域。

关于静默建域,看以后的时间情况,进行更新

安装实例:

# 执行格式
./installWebLogic.sh arg1 arg2 arg3

# 默认参数
./installWebLogic.sh
# 自定义参数
./installWebLogic.sh /software fmw_12.1.3.0.0_wls.jar /u01

小提示:这是我在学习shell脚本时,进行的一个小测试编写案例
关于weblogic12c的安装其实很简单的
里面涉及很多的内容,可以进行相应的删减,然后保留一些配置文件的创建然后根据weblogic12c的静默安装,很方便的,感谢浏览
weblogic的详细安装请浏览:weblogic12c和11g安装配置

vim installWebLogic.sh
#!/bin/bash
##
## use scirpt install weblogic
## Author:Geray
## Email:shougui.zhu@enmotech.com
## date:2020.09.14
## #########################################################################################################
## Parameter type: 
## $1 file_localtion
## $2 Install_package_name
## $3 BEA_HOME
##
## default file location: /software/fmw_12.1.3.0.0_wls.jar
## default file name:  fmw_12.1.3.0.0_wls.jar
## default install location:/home/weblogic/Oracle/Middleware
## for example: ./installWEBlogic.sh /software fmw_12.1.3.0.0_wls.jar /home/weblogic/Oracle/Middleware
## #########################################################################################################
user=weblogic
group=weblogic

## create group if not exists
egrep ${group} /etc/group >& /dev/null
if [ $? -ne 0 ]
then
        groupadd ${group}
        echo "### A ${group} group is created ... "
else
        echo "### The ${group} group already exists "

fi

## create user if not exists
## 如果用户不存在,创建用户
egrep ${user} /etc/passwd >& /dev/null
if [ $? -ne 0 ]
then
        useradd -g ${group} ${user}
        echo "### A ${user} user is created ... "
else
        echo "### The ${user} user already exists "
fi

## Define installation package file location
## 定义安装包文件路径
if [ $1 ];then
        file_localtion=$1
        echo "### The location of the installation package file you specified is: ${file_localtion}"
else
        file_localtion=/software
        echo "### You will use the default installation package file location: ${file_localtion}"
fi

## Define installation package file name
## 定义安装包的名称
if [ $2 ];then
        Install_package_name=$2
        echo "### The package name you specified is: ${Install_package_name}"
else
        Install_package_name=fmw_12.1.3.0.0_wls.jar
        echo "### You will use the default installation package file name : ${Install_package_name}"
fi

## Define BEA_HOME
## 定义安装的BEA_HOME路径
if [ $3 ];then
        BEA_HOME=$3
        mkdir ${BEA_HOME}
        chown -R ${user}:${group} ${BEA_HOME}
        echo "### BEA_HOME directory location is: ${BEA_HOME}"
else
        BEA_HOME=/home/weblogic/Oracle/Middleware
        echo "### You will use the default BEA_HOME directory location : ${BEA_HOME}"
fi

## Create oraInst.loc file
## 创建配置文件
loc_file=oraInst.loc
if [ ! -f ${loc_file} ];then
        echo "### File ${loc_file} does not exist, creating ..."
        touch ${loc_file}
fi

echo "#产品安装清单目录,方便后来人员升级维护时查看
inventory_loc=/home/weblogic/oraInventory
## 用户的组名称,谨慎,一旦确定,安装后读写都将以此为基准
inst_group=${group}
" > ${loc_file}

## Create response file wls.rsp,Cannot contain Chinese Notes
## 创建响应文件,文件中不能包含中文注释
rsp_file=wls.rsp
if [ ! -f ${rsp_file} ];then
        echo "### File ${rsp_file} does not exist, creating ..."
        touch ${rsp_file}
fi

echo "[ENGINE]
Response File Version=1.0.0.0.0
[GENERIC]
ORACLE_HOME=${BEA_HOME}
INSTALL_TYPE=WebLogic Server

MYORACLESUPPORT_USERNAME=
MYORACLESUPPORT_PASSWORD=
DECLINE_SECURITY_UPDATES=true
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false
PROXY_HOST=
PROXY_PORT=
PROXY_USER=
PROXY_PWD=<SECURE VALUE>

COLLECTOR_SUPPORTHUB_URL=
" > ${rsp_file}

## change file owner and group
## 设置安装包的用户和组
echo  ${user} ${group}
echo "### Setting file group ..."
chown ${user}:${group} ${loc_file}
if [ $? -eq 0 ];then
        echo "### Set ${loc_file} file group successfully !"
else
        echo "### Set ${loc_file} file group failed !"
fi

chown ${user}:${group} ${rsp_file}
if [ $? -eq 0 ];then
        echo "### Set ${rsp_file} file group successfully !"
else
        echo "### Set ${rsp_file} file group failed !"
fi

## Move oraInst.loc and wls.rsp to the /home/Weblogic directory
HOME_PATH=`cut -d: -f 6 /etc/passwd | egrep ${user}`
echo "### Copy file to ${HOME_PATH} ..."
cp ${loc_file} ${HOME_PATH}
if [ $? -eq 0 ];then
        echo "### Copy file ${loc_file} ok!"
else
        echo "### Copy file ${rsp_file} failed"
fi
cp ${rsp_file} ${HOME_PATH}
if [ $? -eq 0 ];then
        echo "### Copy file ${loc_file} ok!"
else
        echo "### Copy file ${rsp_file} failed"
fi

if [ $USER != $user ]; then 
  su - ${user} 
  ## source /etc/profile
  ## Install
  cd ${file_localtion}

  ## Start installation
  echo "
  Start installation
  ==========================================================================================="

  java -jar ${Install_package_name} -silent -responseFile ~/wls.rsp -invPtrLoc ~/oraInst.loc

  exit
else
  ## source /etc/profile
  ## Install
  cd ${file_localtion}

  ## Start installation
  echo "
  Start installation
  ==========================================================================================="

  java -jar ${Install_package_name} -silent -responseFile ~/wls.rsp -invPtrLoc ~/oraInst.loc

fi

if [ $? -eq 0 ];then
      chown ${user}:${group} ${rsp_file}
      echo "===========================================================================================
installation is complete !
Installation successful !"
else
      echo "Installation failed !"
fi

java -jar /opt/src/fmw_12.1.3.0.0_wls.jar -silent -responseFile ~/wls.rsp -invPtrLoc ~/oraInst.loc
进行实例:
sh installWebLogic.sh ./ fmw_12.1.3.0.0_wls.jar /home/weblogic/Oracle/Middleware

创建域

weblogic12c自带默认的建域python脚本

/home/weblogic/Oracle/Middleware/wlserver/common/templates/scripts/wlst

vim createBaseDomain.py
# Use Basic Domain Template
readTemplate('/home/weblogic/Oracle/Middleware/wlserver/common/templates/wls/wls.jar')

# Config AdminServer Listen Address and Port
cd('Servers/AdminServer')
set('ListenAddress','localhost')
set('ListenPort', 8001)

# Config username and password of Console User
cd('/')
# 'Security/base_domain/User/weblogic' The 'weblogic' is username
cd('Security/base_domain/User/weblogic')
cmo.setPassword('welcome1')

# If the domain already exists, overwrite the domain
setOption('OverwriteDomain', 'true')
# Config home directory for the JVM to be used when starting the weblogic server
setOption('JavaHome', '/opt/jdk1.8.0_40')
# Config the Domain folder path
writeDomain('/home/weblogic/Oracle/Middleware/user_projects/domain/base_domain')

# Close Template
closeTemplate()

# Exit script
exit()

'''
使用 readTemplate 函数读取建域模版脚本, Weblogic 预置了多种建域脚本,我们仅使用最基础的建域脚本即可。

设置 AdminServer 的监听地址和端口号, ListenAddress 为监听地址,默认为 '' 表示监听所有本机地址; ListenPort 为监听端口号,这里根据实际情况设置,不冲突即可。

设置用户名密码, 'Security/base_domain/User/weblogic' 中 weblogic 就是用户名, cmo.setPassword('weblogic123') 用于将密码设置为 weblogic123 。

设置域参数:OverwriteDomain 设置为覆盖已有域文件;JavaHome 设置 Weblogic 域运行时用到的 JVM 。

设置域路径并写入,使用 writeDomain 函数设置待写入的域路径,并执行写入过程。

使用 closeTemplate 函数在执行完域写入后关闭域模版。

使用 exit 函数退出脚本。
'''

使用脚本创建域实例:

cd Oracle/Middleware/wlserver/common/bin/
./wlst.sh /software/createBaseDomain.py 

如果想要在安装时一并创建域,在安装脚本中添加执行语句即可(请自行更改配置选项):

cd ${BEA_HOME}/wlserver/common/bin
sh wlst.sh /software/createBaseDomain.py

weblogic12c卸载

weblogic12c以前的版本卸载使用uninstall.sh(BEA_HOME/utils/uninstall),然后删除目录即可(WL_HOME下只剩common和inventory);

在weblogic12c中,进行了相应的更改,由原来的uninstall.sh改为deinstall.sh

cd /home/weblogic/Oracle/Middleware/oui/bin

weblogic12c静默卸载在脚本后添加-silent即可,如:

deinstall.sh -silent

正确卸载后BEA_HOME下会有很多目录跟随删除如:oui,wlserver等,以此验证

然后删除根目录,如:

rm -rf ~/Oracle

JDK环境变量

# 设置JDK环境变量
export JAVA_HOME=/java/jdk1.8.0_172
#export JAVA_HOME=/java/jdk1.7.0_80

export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

访问控制台缓慢

  1. 修改jdk随机数

    修改Weblogic使用的jdk $JAVA_HOME/jre/lib/security/java.security 文件
    将securerandom.source=file:/dev/urandom 修改为
    securerandom.source=file:/dev/./urandom

  2. 修改起动脚本

​ weblogic启动脚本中添加一下参数:

JAVA_OPTIONS="-Djava.security.egd=file:/dev/./urandom ${SAVE_JAVA_OPTIONS}"

​ 重启生效

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值