项目部署(五)Centos虚拟机安装weblogic

我们可以在CentOS 7.0中安装weblogic和数据库oracle等,用来本地部署项目,实验双机,热备,集群等等。下面我们介绍一下weblogic的安装。

  • 安装JDK

具体请参照我的前一篇博客,此处不再赘述。

https://hzxblogs.github.io/2017/12/26/%E9%A1%B9%E7%9B%AE%E9%83%A8%E7%BD%B2%EF%BC%88%E4%BA%8C%EF%BC%89JDK1.8%E5%AE%89%E8%A3%85/


  • 环境准备

下载WebLogic安装包,我下载的是11g,也就是10.3.6版本,官网上安装包名称为wls1036_generic.jar,Oracle官网下载连接。将其拷贝到机器上来。
安装weblogic的链接 链接:https://pan.baidu.com/s/1bEffFg 密码:zg95


  • 创建weblogic组和用户

创建用户组一是方便管理,减少误操作对系统产生的影响。二是为了安全起见,即使别人攻入了你的系统获得了Weblogic的控制权,对于操作系统来说也只是一个普通的受限用户。

1
2
3
[root@localhost~]groupadd weblogic
[root@localhost~]useradd -g weblogic weblogic
[root@localhost~]passwd weblogic123

用root用户创建weblogic组和用户后,切换用户:

1
su - weblogic

在home目录下创建文件夹:

1
2
[weblogic@localhost~]cd /home
[weblogic@localhost~]mkdir weblogic

将weblogic安装包wls1211_generic.jar上传至weblogic主目录下即/home/weblogic。否则用root用户上传文件后,weblogic对其没有权限操作。
如果误传文件,不要急,切换到root用户对weblogic赋权即可。可以使用chown命令来改变文件所有者及用户组,chgrp命令来改变文件所在用户组
chown [-R] 账号名称:用户组名称 文件或目录

1
2
[root@localhost~]chown [-R] weblogic:weblogic /home/weblogic
[root@localhost~]chmod 777 wls1211_generic.jar


  • 安装weblogic

1
[weblogic@localhost~]java -jar wls1211_generic.jar -mode=console

Welcome:


This installer will guide you through theinstallation of WebLogic 12.1.1.0.
Type “Next” or enter to proceedto the next prompt. If you want tochange data entered previously, type “Previous”. You may quit the installer at any time bytyping “Exit”.
Enter [Exit][Next]> Next


Choose Middleware Home Directory:


“Middleware Home” = [Enter new value or use default
“/home/weblogic/Oracle/Middleware”]
Enter new Middleware Home OR[Exit][Previous][Next]> Next

Choose Middleware Home Directory:


“Middleware Home” = [/home/weblogic/Oracle/Middleware]
Use above value or select another option:
1- Enter new Middleware Home
2- Change to default [/home/weblogic/Oracle/Middleware]
Enter option number to select OR[Exit][Previous][Next]> Next

Register for Security Updates:

Provide your email address for securityupdates and to initiate configurationmanager.
1|Email:[]
2|Support Password:[]
3|Receive Security Update:[Yes]
Enter index number to select OR[Exit][Previous][Next]> 3


Register for Security Updates:


Provide your email address for securityupdates and to initiate configurationmanager.
“Receive Security Update:” = [Enter new value or use default”Yes”]
Enter [Yes][No]? No

Register for Security Updates:


Provide your email address for securityupdates and to initiate configurationmanager.
“Receive Security Update:” = [Enter new value or use default”Yes”]
Do you wish to bypass initiation of the configuration manager and remain uninformed of criticalsecurity issues in your configuration?
Enter [Yes][No]? ### yes

Register for Security Updates:


Provide your email address for securityupdates and to initiate configurationmanager.
1|Email:[]
2|Support Password:[]
3|Receive Security Update:[No]
Enter index number to select OR [Exit][Previous][Next]> ### Next

Choose Install Type:


Select the type of installation you wish toperform.
->1|Typical
| Install the followingproduct(s) and component(s):
|- WebLogic Server
|- Oracle Coherence

2|Custom
| Choose software products andcomponents to install and perform optional
|configuration.
Enter index number to select OR[Exit][Previous][Next]> ### 1

Choose Product Installation Directories:


Middleware Home Directory: [/home/weblogic/Oracle/Middleware]
Product Installation Directories:
1|WebLogic Server: [/home/weblogic/Oracle/Middleware/wlserver_12.1]
2|Oracle Coherence: [/home/weblogic/Oracle/Middleware/coherence_3.7]
Enter index number to select OR[Exit][Previous][Next]> ### Next

The following Products and JDKs will beinstalled:


WebLogic Platform 12.1.1.0
|_WebLogic Server
| |_Core Application Server
| |_Administration Console
| |_Configuration Wizardand Upgrade Framework
| |_Web 2.0 HTTP Pub-SubServer
| |_WebLogic SCA
| |_WebLogic JDBC Drivers
| |_Third Party JDBCDrivers
| |_WebLogic Server Clients
| |_Xquery Support
| |_Evaluation Database
|_Oracle Coherence
| |_Coherence Product Files
|_JDKs
|_SUN SDK 1.6.0_29
|_Oracle JRockit 1.6.0_29 SDK
*Estimated size of installation: 1,178.0 MB
Enter [Exit][Previous][Next]> ### Next

Installing files..
0% 25% 50% 75% 100%
[————|————|————|————]
[*]
Installing JDK….
Performing String Substitutions…
Configuring OCM…
Installing Patches…
Creating Domains…
Installation Complete
Press [Enter] to continue or type[Exit]> ### ↙

到目前为止weblogic就安装完成了。


  • 配置domain

安装完成后按下Enter应该会默认启动Domain配置界面,如果不是,请到安装路径下执行配置启动脚本

1
2
[weblogic@localhost~]cd /home/weblogic/Oracle/Middleware/wlserver_10.3/common/bin
[weblogic@localhost~]./config.sh


1、欢迎界面,选择是新建domain还是扩展,因为第一次使用,输入1,即新建;
2、选择domain源,也是使用默认配置,即键入1回车;
3、应用程序模板选择,这里使用默认,即输入Next回车;
4、编辑domain信息,域名base_domain,默认,输入Next回车;
5、为domain选择目标或目录,默认,输入Next回车;
6、配置管理员用户名和口令,这里按需要输入选项,并根据提示操作,比较简单,配置好输入Next回车;
7、domain模式选择,我选择的生产模式,输入2回车;
8、选择JDK,使用我们之前安装的,输入2回车;
9、选择可选配置,我们暂不配置,输入Next回车;
10、开始执行创建,之后显示创建成功。


  • 执行启动脚本
    1
    2
    [weblogic@localhost~]cd /home/weblogic/Oracle/Middleware/user_projects/domains/base_domain
    [weblogic@localhost~]./startWebLogic.shh

提示输入用户名密码,就是我们创建domain时配置的,输入信息后回车,稍等片刻,运行 ifconfig 查看虚拟机IP,在宿主机中访问
http://ip地址:7001/console
如果能出现WebLogic登录页,则说明服务启动成功。

  • 配置weblogic启动参数

每次启动WebLogic时都要输入用户名和密码,假设我的WebLogic是自动随着我的服务器的启动而启动,那么如果此时因为是无人值守,谁来输这个用户名和密码啊?提供个方法记住密码。

1
2
3
[weblogic@localhost~]cd /home/weblogic/Oracle/Middleware/user_projects/domains/base_domain/servers/AdminServer
[weblogic@localhost~]mkdir security
[weblogic@localhost~]vi boot.properties

在文件中输入:
username=xxx
password=xxx

保存就可以了,重启weblogic以后不会再提示输入用户名和密码。

  • 封装weblogic启动脚本

在启动weblogic中,有三个问题,
1、启动目录下只有启动脚本,没有停止脚本。
2、每次启动都要cd到启动目录下。
3、ctrl++c 退出启动脚本后,weblogic服务也停止了。
针对这三个问题,我们一起来看下我是怎么封装的。

首先无论是startWeblogic还是stopWeblogic 都是引用这个目录下的startWeblogic.sh文件

1
[weblogic@localhost~]cd /home/weblogic/Oracle/Middleware/user_projects/domains/base_domain/bin

现在我们可以这么封装:

1
2
3
4
[weblogic@localhost~]cd /home/weblogic/
[weblogic@localhost~]mkdir sh
[weblogic@localhost~]cd sh
[weblogic@localhost~]vi startWeblogic.sh

编辑的startWeblogic.sh内容为:

1
2
3
4
5
6
7
8
#!/bin/sh

# WARNING: This file is created by the Configuration Wizard.
# Any changes to this script may be lost when adding extensions to this configuration

cd /home/weblogic/Oracle/Middleware/user_projects/domains/base_domain/bin
nohup ./startWebLogic.sh >out.log 2>&1 &
tail -f out.log

同理, 编辑的startWeblogic.sh内容为:

1
2
3
4
5
6
7
8
#!/bin/sh

# WARNING: This file is created by the Configuration Wizard.
# Any changes to this script may be lost when adding extensions to this configuration

cd /home/weblogic/Oracle/Middleware/user_projects/domains/base_domain/bin
nohup ./stopWebLogic.sh >outstop.log 2>&1 &
tail -f outstop.log


恭喜你,已经完成了哦,以后就可以直接用 ./home/weblogic/sh/startWebLogic.sh 来启动weblogic了。并且解决了上面我们提出的三个问题。
有兴趣的同学可以跟我一起看看关于命令为什么要这么封装的介绍。

  • nohup脚本介绍
1
nohup ./startWebLogic.sh >out.log 2>&1 &

其中 0、1、2分别代表如下含义:
0 – stdin (standard input)
1 – stdout (standard output)
2 – stderr (standard error)
nohup ./startWebLogic.sh >out.log 2>&1 &
nohup+最后面的& 是让命令在后台执行。

out.log 是将信息输出到out.log日志中。
2>&1 是将标准错误信息转变成标准输出,这样就可以将错误信息输出到out.log 日志里面来。

文章目录
  1. 1. Register for Security Updates:
|