一、首先准备JDK、weblogic安装包,本次使用的安装包版本为jdk-7u80-linux-x64.rpm、fmw_12.1.3.0.0_wls.jar,以此为例
进行JDK脚本安装,需要用ROOT用户
vi jdk_create.sh
#!/bin/bash
#检查JDK安装包是否存在
if [ -f jdk-*.rpm ]; then
echo '下面开始安装JDK'
sleep 1
rpm -ivh jdk-*.rpm
#将JDK添加到全局变量中
cat >>/etc/profile << EOF
export JAVA_HOME=/usr/java/jdk1.7.0_80
export JRE_HOME=/usr/java/jdk1.7.0_80/jre
export CLASSPATH=\$CLASSPATH:\$JAVA_HOME/lib:\$JAVA_HOME/jre/lib
export PATH=\$JAVA_HOME/bin:\$JRE_HOME/bin:\$PATH
EOF
source /etc/profile #加载全局变量
java -version #查看JDK是否安装成功,也可以设置if语句进行验证
#java -version
#if [ $? -eq 0 ] then
# echo 'jdk is create successful!'
echo 'Next we will change the conf!'
sed -i 's/file:\/dev\/urandom/file:\/dev\/.\/urandom/g' /usr/java/jdk1.7.0_80/jre/lib/security/java.security
if [ $? -eq 0 ]; then
echo 'conf is changed over!'
else
echo 'conf is not changed!please changed by yourself!'
fi
else
echo '没有jdk安装包!'
exit
fi
执行 sh jdk_create.sh
二、开始创建weblogic用户组、用户和家目录,需要root用户
vi user_add.sh
echo '下面开始安装weblogic!'
read -p '请输入应用用户群组:' group
echo '群组名为:$group'
read -p '请输入用户名:' user
echo '应用用户名为:$user'
read -p '请输入用户密码:' password
echo '用户密码为:$password'
read -p '请输入用户家目录:' path
echo '家目录为:$path'
groupadd $group
useradd -g $group -m -d $home_path $user
chown -R weblogic:weblogic /home/weblogic/
添加用户可以手动添加,这个脚本只是保留批量的时候能够用到
三、下面进入正题,进行静默安装weblogic已经静默安装domain 执行此脚本使用weblogic用户
vi weblogic_create.sh
#!/bin/bash
#检查WEBLOGIC安装包是否存在
if [ -f fmw*.jar ]; then #判断是否有软件包
#编写静默安装weblogic配置文件
cat >/home/weblogic/oraInst.loc <
#Oracle Installer Location File Location
inst_group=$group
inventory_loc=/home/weblogic/oraInventory
EOF
echo -e '\e[32;1m[oraInst.loc配置文件已经完成]\e[0m'
read -p '请输入ORACLE_HOME路径(/home/weblogic/Oracle):' home
#编写静默安装weblogic配置文件
cat >/home/weblogic/wls.rsp <
[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
#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=
#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=
#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=
EOF
echo -e '\e[32;1m[wls.rsp配置文件已经完成]\e[0m'
if [ -f '/home/weblogic/wls.rsp' ]; then #判断编写的配置文件是否存在
echo -e "\e[32;1m[You can check /tmp/weblogic.log]\e[0m"
java -jar fmw_12.1.3.0.0_wls.jar -silent -responseFile /home/weblogic/wls.rsp -invPtrLoc /home/weblogic/oraInst.loc >/tmp/weblogic.log
if [ -d $home ]; then #通过手动输入可以设定控制台账号密码端口号,如果是批量创建可以将账号密码端口号进行固定,根据需求改动
mkdir -p $home/user_projects/domains/
read -p 'Console控制台账号:' console_user
read -p 'Console控制台密码:' console_passwd
read -p 'weblogic监听端口号:' port1
read -p 'weblogic_ssl监听端口号:' port2
#根据变量创建安装domain的配置文件
#指定JDK路径需要手动更改JavaHome
#通过变量$port1指定weblogic监听端口
#通过变量$port2指定SSL监听端口,此项可省略,如果省略需要把上面变量注释掉
#指定控制台账号密码$console_passwd
#指定安装路径
cat >/home/weblogic/create_domain.rsp <
read template from "/home/weblogic/Oracle/wlserver/common/templates/wls/wls.jar";
set JavaHome "/usr/java/jdk1.7.0_80";
set ServerStartMode "dev";
find Server "AdminServer" as AdminServer;
set AdminServer.ListenAddress "";
set AdminServer.ListenPort "$port1";
set AdminServer.SSL.Enabled "true";
set AdminServer.SSL.ListenPort "$port2";
find User "weblogic" as u1;
set u1.password "$console_passwd";
write domain to "/home/weblogic/Oracle/user_projects/";
close template;
EOF
#通过配置文件create_domain.rsp进行域的静默安装
sh /home/weblogic/Oracle/wlserver/common/bin/config.sh -mode=silent -silent_script=/home/weblogic/create_domain.rsp -logfile=/home/weblogic/create_domain.log
fi
else
echo 'No wls.rsp in the path!'
exit
fi
else
echo '没有安装包!'
exit
fi
本次脚本里面编写配置文件用的是EOF格式,也可以用echo格式添加配置文件,哪种方式没有区别。
脚本编写仅仅是为了打发时间,如有问题或建议欢迎留言,勿喷!