最近做一个项目的时候,客户要求发布的生产环境的web应用服务器为weblogic,之前一直用的是tomcat,为此着实费了一番脑子,记录下。
weblogic版本10.3.6,jdk版本1.7.9。
一.weblogic10.3.6安装
1. 卸载openjdk
先查系统已有jdk版本,
rpm -qa|grep java
卸载openjdk
rpm -e --nodeps java-1.7.0-openjdk-headless-1.7.0.91-2.6.2.3.el7.x86_64 -e --nodeps java-1.7.0-openjdk-1.7.0.91-2.6.2.3.el7.x86_64 -e --nodeps java-1.8.0-openjdk-1.8.0.65-3.b17.el7.x86_64
卸载完成。
2.安装新jdk
下载Linux版本jdk,并解压。
ll 可以查看当前目录下存在目录jdk1.7.0_07,然后将其移动到/usr/local/目录下,并重命名为 jdk7,输入命令:mv jdk1.7.0_07 /usr/local/jdk7
修改 /etc/profile,它是所有用户的共用的环境变量输入命令:vi /etc/profile然后在打开的文件末尾添加如下内容:
JAVA_HOME=/usr/local/jdk8
JRE_HOME=/usr/local/jdk8/jre
PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
export JAVA_HOME JRE_HOME PATH CLASSPATH
使环境变量立即生效,输入命令:source /etc/profile
输入命令:java #检测jdk bin环境
接着输入:javac #检测jdk classpath环境
3.安装weblogic
创建用户组:groupadd xycrm_weblogic
创建用户添加用户组weblogci指目录:
useradd -g xycrm_weblogic -m -d /home/lip weblogic
设置密码 passwd Xycrmwb123
指定用户目录 chown -R weblogic:xycrm_weblogic /home
执行ll 可查看目录属组
安装:
进入weblogic安装包存放目录执行安装命令如:
java -jar wls1036_generic.jar
一、安装weblogic10.3.6 64位:
-bash-4.1$ java -jar wls1036_generic.jar
Unable to instantiate GUI, defaulting to console mode.无法实例化 GUI,默认进入控制台模式。
Extracting 0%……………………………………………………………………………………….100%
<——————– Oracle Installer - WebLogic 10.3.6.0 ——————->
Welcome:
This installer will guide you through the installation of WebLogic 10.3.6.0.
Type “Next” or enter to proceed to the next prompt. If you want to change data entered previously, type “Previous”. You may quit the installer at any time by typing “Exit”.
Enter [Exit][Next]> 回车
<——————– Oracle Installer - WebLogic 10.3.6.0 ——————->
Choose Middleware Home Directory:
"Middleware Home" = [Enter new value or use default
“/bea/weblogic/Oracle/Middleware”]
Enter new Middleware Home OR [Exit][Previous][Next]> /bea/weblogic/
<——————– Oracle Installer - WebLogic 10.3.6.0 ——————->
Choose Middleware Home Directory:
"Middleware Home" = [/bea/weblogic]
Use above value or select another option:
1 - Enter new Middleware Home
2 - Change to default [/bea/weblogic/Oracle/Middleware]
Enter option number to select OR [Exit][Previous][Next]> 1
<——————– Oracle Installer - WebLogic 10.3.6.0 ——————->
Choose Middleware Home Directory:
"Middleware Home" = [/bea/weblogic]
Enter new Middleware Home OR [Exit][Previous][Next]>
<——————– Oracle Installer - WebLogic 10.3.6.0 ——————->
Choose Middleware Home Directory:
Warning
/bea/weblogic directory is not empty. Proceed with installation?
Enter [Exit][Previous][Next]>
<——————– Oracle Installer - WebLogic 10.3.6.0 ——————->
Register for Security Updates:
Provide your email address for security updates and to initiate configuration manager.
1|Email:[]
2|Support Password:[]
3|Receive Security Update:[Yes]
Enter index number to select OR [Exit][Previous][Next]> 3
<——————– Oracle Installer - WebLogic 10.3.6.0 ——————->
Register for Security Updates:
Provide your email address for security updates and to initiate configuration manager.
“Receive Security Update:” = [Enter new value or use default “Yes”]
Enter [Yes][No]? no
<——————– Oracle Installer - WebLogic 10.3.6.0 ——————->
Register for Security Updates:
Provide your email address for security updates and to initiate configuration manager.
“Receive Security Update:” = [Enter new value or use default “Yes”]
Enter [Yes][No]? yes
<——————– Oracle Installer - WebLogic 10.3.6.0 ——————->
Register for Security Updates:
Provide your email address for security updates and to initiate configuration manager.
1|Email:[]
2|Support Password:[]
3|Receive Security Update:[No]
Enter index number to select OR [Exit][Previous][Next]>
<——————– Oracle Installer - WebLogic 10.3.6.0 ——————->
Register for Security Updates:
Provide your email address for security updates and to initiate configuration manager.
1|Email:[]
2|Support Password:[]
3|Receive Security Update:[No]
Enter index number to select OR [Exit][Previous][Next]>
<——————– Oracle Installer - WebLogic 10.3.6.0 ——————->
Choose Install Type:
Select the type of installation you wish to perform.
->1|Typical
| Install the following product(s) and component(s):
| - WebLogic Server
| - Oracle Coherence
2|Custom
| Choose software products and components to install and perform optional
|configuration.
Enter index number to select OR [Exit][Previous][Next]> 2
<——————– Oracle Installer - WebLogic 10.3.6.0 ——————->
Choose Products and Components:
Release 10.3.6.0
|_____WebLogic Server [1] x
| |_____Core Application Server [1.1] x
| |_____Administration Console [1.2] x
| |_____Configuration Wizard and Upgrade Framework [1.3] x
| |_____Web 2.0 HTTP Pub-Sub Server [1.4] x
| |_____WebLogic SCA [1.5] x
| |_____WebLogic JDBC Drivers [1.6] x
| |_____Third Party JDBC Drivers [1.7] x
| |_____WebLogic Server Clients [1.8] x
| |_____WebLogic Web Server Plugins [1.9] x
| |_____UDDI and Xquery Support [1.10] x
| |_____Server Examples [1.11]
| |_____Evaluation Database [1.12] x
|_____Oracle Coherence [2] x
|_____Coherence Product Files [2.1] x
|_____Coherence Examples [2.2]
*Estimated size of installation: 690.2 MB
Enter number exactly as it appears in brackets to toggle selection OR [Exit][Previous][Next]> 2
<——————– Oracle Installer - WebLogic 10.3.6.0 ——————->
Choose Products and Components:
Release 10.3.6.0
|_____WebLogic Server [1] x
| |_____Core Application Server [1.1] x
| |_____Administration Console [1.2] x
| |_____Configuration Wizard and Upgrade Framework [1.3] x
| |_____Web 2.0 HTTP Pub-Sub Server [1.4] x
| |_____WebLogic SCA [1.5] x
| |_____WebLogic JDBC Drivers [1.6] x
| |_____Third Party JDBC Drivers [1.7] x
| |_____WebLogic Server Clients [1.8] x
| |_____WebLogic Web Server Plugins [1.9] x
| |_____UDDI and Xquery Support [1.10] x
| |_____Server Examples [1.11]
| |_____Evaluation Database [1.12] x
|_____Oracle Coherence [2]
|_____Coherence Product Files [2.1]
|_____Coherence Examples [2.2]
*Estimated size of installation: 678.7 MB
Enter number exactly as it appears in brackets to toggle selection OR [Exit][Previous][Next]>
<——————– Oracle Installer - WebLogic 10.3.6.0 ——————->
JDK Selection (Any * indicates Oracle Supplied VM):
JDK(s) chosen will be installed. Defaults will be used in script string-substitution if installed.
1|Add Local Jdk
2|/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64[x]
*Estimated size of installation: 678.7 MB
Enter 1 to add or >= 2 to toggle selection OR [Exit][Previous][Next]>
<——————– Oracle Installer - WebLogic 10.3.6.0 ——————->
Choose Product Installation Directories:
Middleware Home Directory: [/bea/weblogic]
Product Installation Directories:
"WebLogic Server" = [Enter new value or use default
“/bea/weblogic/wlserver_10.3”]
Enter new WebLogic Server OR [Exit][Previous][Next]>
<——————– Oracle Installer - WebLogic 10.3.6.0 ——————->
The following Products and JDKs will be installed:
WebLogic Platform 10.3.6.0
|_____WebLogic Server
|_____Core Application Server
|_____Administration Console
|_____Configuration Wizard and Upgrade Framework
|_____Web 2.0 HTTP Pub-Sub Server
|_____WebLogic SCA
|_____WebLogic JDBC Drivers
|_____Third Party JDBC Drivers
|_____WebLogic Server Clients
|_____WebLogic Web Server Plugins
|_____UDDI and Xquery Support
|_____Evaluation Database
*Estimated size of installation: 678.8 MB
Enter [Exit][Previous][Next]>
<——————– Oracle Installer - WebLogic 10.3.6.0 ——————->
Installing files..
0% 25% 50% 75% 100%
[————|————|————|————]
[*****************************************]
Performing String Substitutions…
<——————– Oracle Installer - WebLogic 10.3.6.0 ——————->
Configuring OCM…
0% 25% 50% 75% 100%
[————|————|————|————]
[*****************************************]
Creating Domains…
<——————– Oracle Installer - WebLogic 10.3.6.0 ——————->
Installation Complete
Congratulations! Installation is complete.
Press [Enter] to continue or type [Exit]>
<——————– Oracle Installer - WebLogic 10.3.6.0 ——————->
Clean up process in progress …
二、配置domains
-bash-4.1
./config.sh./config.sh:line103:/usr/lib/jvm/java−1.6.0−openjdk−1.6.0.0.x8664/bin/java:Nosuchfileordirectory−bash−4.1
./config.sh
Unable to instantiate GUI, defaulting to console mode.
<——————- Fusion Middleware Configuration Wizard ——————>
Welcome:
Choose between creating and extending a domain. Based on your selection,
the Configuration Wizard guides you through the steps to generate a new or
extend an existing domain.
->1|Create a new WebLogic domain
| Create a WebLogic domain in your projects directory.
2|Extend an existing WebLogic domain
| Use this option to add new components to an existing domain and modify |configuration settings.
Enter index number to select OR [Exit][Next]> 1
<——————- Fusion Middleware Configuration Wizard ——————>
Select Domain Source:
Select the source from which the domain will be created. You can create the
domain by selecting from the required components or by selecting from a
list of existing domain templates.
->1|Choose Weblogic Platform components
| You can choose the Weblogic component(s) that you want supported in
|your domain.
2|Choose custom template
| Choose this option if you want to use an existing template. This
|could be a custom created template using the Template Builder.
Enter index number to select OR [Exit][Previous][Next]> 1
<——————- Fusion Middleware Configuration Wizard ——————>
Application Template Selection:
Available Templates
|_____Basic WebLogic Server Domain - 10.3.6.0 [wlserver_10.3]x
|_____Basic WebLogic SIP Server Domain - 10.3.6.0 [wlserver_10.3] [2]
|_____WebLogic Advanced Web Services for JAX-RPC Extension - 10.3.6.0 [wlserver_10.3] [3]
|_____WebLogic Advanced Web Services for JAX-WS Extension - 10.3.6.0 [wlserver_10.3] [4]
Enter number exactly as it appears in brackets to toggle selection OR [Exit][Previous][Next]>
<——————- Fusion Middleware Configuration Wizard ——————>
Edit Domain Information:
| Name | Value |
|_|_____|
1| *Name: | base_domain |
Enter value for “Name” OR [Exit][Previous][Next]> xycrmweb
按照提示的步骤设置即可。
启动Weblogic
在启动Weblogic之前,可将服务用户名和密码写入启动脚本。
进入刚刚配置完成的域目录(例如:/bea/webapp/domains/),编辑startWeblogic.sh启动脚本,执行
vistartWeblogic.sh在“WLSUSER=xxxxxWLSPW=xxxxx”输入用户名和密码,保存退出;最后执行
./startWeblogic.sh,启动Weblogic..
访问:
http://ip:7001/console 用户名:xxxxx密码:xxxxxx
WebLogic在开发模式下,启动是不需求输入管理员的用户名和密码的,但在生产模式下,是需要的。如何才能在生产模式下自动输入管理员的密码呢?方法如下:
第一种方法:
1、在WebLogic启动脚本相同目录下创建一个密码存储文件boot.properties,
文件内容:
username=你的WebLogic的启动用户
password=你的WebLogic的启动密码
2、再次启动WebLogic,此时不需要密码就可以进行系统.
3、删除刚才创建的boot.properties的文件.(必须要做,不然下次启动时就又进不去了)
4、再次启动WebLogic,以后就不要密码了
注:
安装时用的是开发模式,在console中可以更改为生产模式。
第二种方法:
D:\bea\user_projects\domains\mydomain\servers\实例server下建立security目录,把boot.properties文件拷进去就行了.不需要进行2,3,4的步骤.
注意问题一 chown –R weblogic:bea /u02
把weblogic文件夹的权限给bea组下的weblogic用户
注意关闭防火墙:
Service iptables stop
chkconfig iptables off
方式一暂时关闭
方式二永久关闭。
特别注意:
autodeloy方式部署跟控制台部署方式,项目的解压路径不一样。如果在项目中有根据classloader获取项目名称及路径,来拼接静态资源路径,需注意。
在我的项目中,生产模式解压路径为:
/home/weblogic/Oracle/webapp/domains/xycrmweb/servers/AdminServer/tmp/_WL_user/rcrm/sqn7ce/war/WEB-INF/classes/
其中蓝色部分为项目名称,而红色部分则是weblogic以生成的随机字符串拼接的路径。那么当项目分别运行于tomcat或weblogic下时,根据classloader.getResouce(“”)获取的项目路径就有问题。如果用weblogic发布项目遇到静态资源路径问题,可从此方面着手解决。
另外:
由于weblogic不会自动展开war包,所以需要在WEB-INF下,增加weblogic.xml
内容如下:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE weblogic-web-app PUBLIC "-//BEA Systems, Inc.//DTD Web Application 8.1//EN" "http://www.bea.com/servers/wls810/dtd/weblogic810-web-jar.dtd"> <weblogic-web-app>
<weblogic-version>10.3.6</weblogic-version>
<context-root>/rcrm/</context-root>
<container-descriptor>
<prefer-web-inf-classes>true</prefer-web-inf-classes>
<show-archived-real-path-enabled>true</show-archived-real-path-enabled>
</container-descriptor>
</weblogic-web-app>
========================================================================