Archive for 2021年11月30日


weblogic10.3.6卸载补丁脚本

#!/bin/bash
BSU_PACH=/home/weblogic/Oracle/Middleware/utils/bsu
WLSHOME_PACH=/home/weblogic/Oracle/Middleware/wlserver_10.3

# 将获取到的补丁jar包放入临时的文件,方便后续卸载
cd ${BSU_PACH} && ./bsu.sh -prod_dir=${WLSHOME_PACH} -status=applied -verbose -view | grep jar > tmp_jar

# 将查询到的tmp_jar文件通过tac逆序取出
jar_names=($(tac tmp_jar | awk ‘{print $NF}’ | awk -F ‘.’ ‘{print $(NF-1)}’))
for jar_name in ${jar_names[@]}; do
echo “remove ${jar_name}”
cd ${BSU_PACH} && ./bsu.sh -remove -patchlist=${jar_name} -prod_dir=${WLSHOME_PACH}
done

#!/bin/bash
BSU_PACH=/home/weblogic/Oracle/Middleware/utils/bsu
WLSHOME_PACH=/home/weblogic/Oracle/Middleware/wlserver_10.3
PKG_PACH=ftp://10.1.1.1/patch/weblogic/10.3.6/
PKG_NAME=p33172858_1036_Generic.zip

# 判断清空旧文件夹中内容或创建补丁文件夹
if [ -d ${BSU_PACH}/cache_dir ];then
cd ${BSU_PACH}/cache_dir; rm -rf *
else
mkdir -p ${BSU_PACH}/cache_dir
fi

# PKG_NAME是补丁包名称
cd ${BSU_PACH}/cache_dir && curl -o ./${PKG_NAME} ${PKG_PACH}/${PKG_NAME}

# 解压补丁包
cd ${BSU_PACH}/cache_dir && unzip *.zip

#更改bsu.sh脚本中的内存参数,提高打补丁速度
if [ -f ${BSU_PACH}/bsu.sh.bak ];then
echo “bsu has changed.”
else
cp ${BSU_PACH}/bsu.sh ${BSU_PACH}/bsu.sh.bak
cd ${BSU_PACH} && sed -i ‘5c MEM_ARGS=”-Xms4096m -Xmx4096m -XX:-UseGCOverheadLimit”‘ ./bsu.sh
fi

#停服务
ps -ef | grep java| grep weblogic | grep -v “grep” 2>&1 >/dev/null
if [[ $? -eq 0 ]];then
ps -ef |grep java| grep weblogic | grep -v “grep”|awk ‘{print $2}’|xargs kill -9
else
echo “weblogic process is not exsits”
fi

#打补丁:
cd ${WLSHOME_PACH}/server/bin && source setWLSEnv.sh
cd ${BSU_PACH}/cache_dir && PK=$(ls -lt *.jar | head -n 1 | awk ‘{print $NF}’ | awk -F “.” ‘{print $1}’)
cd ${BSU_PACH} && ./bsu.sh -install -patch_download_dir=${BSU_PACH}/cache_dir -patchlist=${PK} -prod_dir=${WLSHOME_PACH}

#启动weblogic服务
#nohup /home/weblogic/Oracle/Middleware/user_projects/domains/base_domain/bin/startWebLogic.sh &

#!/bin/bash
export ORACLE_HOME=/home/weblogic/Oracle/Middleware/Oracle_Home
OP_PACH=${ORACLE_HOME}/OPatch
PKG_PATCH=ftp://10.1.1.1/patch/weblogic/12.1.3
PKG_NAME=p33172866_121300_Generic.zip
linshi=/home/weblogic/patch

# 创建新文件夹
if [[ -d ${linshi} ]];then
rm -rf ${linshi}
else
mkdir -p ${linshi}
fi

# 获取补丁包
cd ${linshi} && curl -o ./${PKG_NAME} ${PKG_PATCH}/${PKG_NAME}

# 解压
which unzip &> /dev/null
if [[ $? -eq 0 ]];then
unzip ${linshi}/*.zip -d ${linshi};
else
echo “unzip is not exsits, yum install it first, plz”
fi

# 停止weblogic服务
ps -ef | grep java| grep weblogic | grep -v “grep” &> /dev/null
if [[ $? -eq 0 ]];then
ps -ef |grep java| grep weblogic | grep -v “grep”|awk ‘{print $2}’|xargs kill -9
else
echo “weblogic process is not exsits”
fi

# 打补丁
PKG_NAME=$(cd ${linshi} && ls | grep -Ev ‘*.zip’)
cd ${linshi}/${PKG_NAME} && ${OP_PACH}/opatch apply -silent

# 启动weblogic
#nohup ${ORACLE_HOME}/user_projects/domains/base_domain/startWebLogic.sh &

#!/bin/bash
# 安装EPEL
yum -y localinstall ftp://10.1.1.1/epel-release-latest-7.noarch.rpm

# 更新REPO文件为内网源
curl -o /etc/yum.repos.d/CentOS-Base.repo ftp://10.1.1.1/centos7.repo
curl -o /etc/yum.repos.d/epel.repo ftp://10.1.1.1/epel7.repo

# 卸载rh自带包
yum -y remove rhnlib redhat-support* subscription-manager
rpm -e –nodeps redhat-release-server redhat-logos
rm -rf /usr/share/redhat-release* /usr/share/doc/redhat-release*

# 安装centos重要文件
yum -y install centos-release yum centos-logos
yum clean all
yum -y update

# 禁用墙
systemctl disable firewalld