c7安装weblogic多域

时间:2022-11-10 17:59:45

一、简介  WebLogic是美国Oracle公司出品的一个application server,确切的说是一个基于JAVAEE架构的中间件,WebLogic是用于开发、集成、部署和管理大型分布式Web应用、网络应用和数据库应用的Java应用服务器。

二、weblogic安装 java安装不再赘述

weblogic用户创建 weblogic不能在root环境下安装,我在root环境下安装会报错

groupadd deploy useradd -g deploy deploy 切换到weblogic用户 su - deploy 获取安装包 #下载安装包 wget https://www.oracle.com/webapps/redirect/signon?nexturl=https://download.oracle.com/otn/nt/middleware/12c/12213/fmw_12.2.1.3.0_wls_quick_Disk1_1of1.zip

#解压 unzip fmw_12.2.1.3.0_wls_quick_Disk1_1of1.zip 创建相关目录

#静默安装应答文件存放目录 mkdir /home/weblogic/rsp
#产品清单目录,安装产品的信息 mkdir /home/weblogic/oraInventory 创建相应文件 vim /home/weblogic/rsp/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/weblogic/wls #创建安装目录 #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= 创建loc文件 vim /home/weblogic/rsp/oraInst.loc inventory_loc=/home/weblogic/oraInventory inst_group=weblogic 安装 java -jar /home/weblogic/fmw_12.2.1.3.0_wls_quick.jar -silent -responseFile /home/weblogic/rsp/wls.rsp -invPtrLoc /home/weblogic/rsp/oraInst.loc ORACLE_HOME="/home/weblogic/wls"

ps:我之前安装时,参照大多数博客,发现他们没有指定ORACLE_HOME这个参数,还能安装到指定目录,但是我安装时,就一直安装到默认的wls目录,即使应答文件中已经指定了安装目录,所以,最好加上这个参数

创建域 weblogic启动时,是以某个域来启动的

引入WLST WLST : WebLogic Scripting Tool ,即 Weblogic 脚本工具。 WebLogic 脚本工具 (WebLogic Scripting Tool , WLST) 是一种命令行脚本界面,系统管理员和操作员用它来监视和管理 WebLogic Server 实例以及域。WLST 脚本环境基于 Java 脚本解释器 Jython。除 WebLogic 脚本功能外,还可以使用解释语言(包括本地变量、条件变量以及流控制语句)的常用功能。WebLogic Server 开发人员和管理员可以按照 Jython 语言语法扩展 WebLogic 脚本语言,以满足其环境需要。(本段摘自百度百科-wlst)

WLST 工具可以实现多种针对 Weblogic 的操作,在本文中主要演示如何使用 WLST 新建空白域,其他功能可通过 Oracle 的官方操作文档了解。 以下内容中以具体的例子进行说明。 假设 Weblogic 的安装目录为:/data/www 假设默认的 Weblogic Domain 目录为:/data/app/weblogic/domains

编写 WLST 建域脚本

在 /data/app/weblogic/domains 目录下建立空的域文件夹 example_domain ,绝对目录为 /data/app/weblogic/domains/example_domain 。 复制 /data/www/wlserver/common/templates/scripts/wlst/basicWLSDomain.py 文件到 example_domain 文件夹下,并重命名为 ExampleDomain.py ,该文件将作为创建当前域的脚本文件。 修改脚本

打开 ExampleDomain.py 文件,按照以下代码所示,删除多余的配置并修改该脚本文件:

# Weblogic Domain Template 
# Use Basic Domain Template
readTemplate("/bea/Oracle/Middleware/wlserver/common/templates/wls/wls.jar")
 
# Config AdminServer Listen Address and Port
cd('Servers/AdminServer')
set('ListenAddress','')
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('weblogic123')
 
# 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', '/usr/java/jdk1.8.0_91')
# Config the Domain folder path
writeDomain('/datafs/fs/weblogic/domains/example_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 函数退出脚本。 以上实例为最简单的域创建脚本, WLST 本身提供了丰富的函数进行域创建和域操作,详细的说明请参考 Oracle 的官方文档。 执行 WLST 建域脚本 进入 /data/app/weblogic/domains/example_domain 目录,执行以下命令,通过WLST脚本创建域: 首先执行以下命令设置临时环境变量,用于解决创建域过程过慢问题,该问题在Oracle官方手册中已有说明: $ export CONFIG_JVM_ARGS='-Djava.security.egd=file:/dev/urandom' 然后执行建域脚本: $ /data/www/wlserver/common/bin/wlst.sh /data/app/weblogic/domains/example_domain/ExampleDomain.py 若未报错则说明域已创建成功。 当前域目录下已生成相关的文件: 此时可使用以下命令即可启动当前域的 Weblogic Server:(也可根据个人需要采用其他命令启动) $ nohup ./startWebLogic.sh &

本文引用创建的域脚本如下 第一个域 #!/usr/bin/python readTemplate('/data/app/weblogic/wls/wlserver/common/templates/wls/wls.jar')

cd('Servers/AdminServer') set('ListenPort',7001)

cd('/') cd('Security/base_domain/User/weblogic')

#如果需要修改管理员用户名为weblogic,则需要cmo.setName('weblogic') cmo.setName('weblogic') #用户名 cmo.setPassword('weblogic12g') #密码

setOption('ServerStartMode','prod') setOption('OverwriteDomain','true') writeDomain('/data/www/test_domain/') #自定义的domin路径

closeTemplate() exit()

第二个域

#!/usr/bin/python readTemplate('/data/app/weblogic/wls/wlserver/common/templates/wls/wls.jar')

cd('Servers/AdminServer') set('ListenPort',7002)

cd('/') cd('Security/base_domain/User/weblogic')

#如果需要修改管理员用户名为weblogic,则需要cmo.setName('weblogic') cmo.setName('weblogic') #用户名 cmo.setPassword('weblogic12g') #密码

setOption('ServerStartMode','prod') setOption('OverwriteDomain','true') writeDomain('/data/www/test2_domain/') #自定义的domin路径

closeTemplate() exit()

解决weblogic启动慢的问题 添加 启动参数 : -Xms256m -Xmx512m -XX:MaxPermSize=256m 原因 : 实际是JVM在Linux下的bug:他想调用一个随机函数,但是取不到。 暂时的解决办法是 2) 1)较好的解决办法: 在Weblogic启动参数里添加 “-D java.security.egd=file:/dev/./urandom” (/dev/urandom 无法启动) 2)最差的解决办法: 执行命令 mv /dev/random /dev/random.ORIG ; ln /dev/urandom /dev/random   将/dev/random 指向/dev/urandom 3)最好的解决办法:(亲测有效) 修改Linux上Weblogic使用的jdk $JAVA_HOME/jre/lib/security/java.security 文件   将securerandom.source=file:/dev/urandom 修改为 securerandom.source=file:/dev/./urandom 这样可以解决任何一个域Weblogic启动慢的问题的问题

启动weblogic服务时,还需要输入用户名和密码的解决方法 而在生产环境中,一般会要求不要在每次启动时都输入用户名密码, 因此可以通过一些简单的配置达到此目的,通常的做法有两种: 修改WebLogic的启动脚本,在里面填入用户名和密码 增加boot.properties文件,保存用户名和密码(推荐方式) 修改WebLogic的启动脚本,即修改startWebLogic.sh,增加如下内容: WLS_USER="weblogic" export WLS_USER WLS_PW="weblogic11g" export WLS_PW 保存用户名和密码信息到boot.properties文件中,在AdminServer和ManagedServer的目录下 (例如:/home/test/Oracle/pnunuDomain/servers/AdminServer)