vlambda博客
学习文章列表

【Tomcat】linux部署Tomcat运行环境

1、 数据库导入

1.1 新建用户并授权

oracle用户下运行如下命令

sqlplus / as sysdba;

create user zbxbid identified by zbxbid;

grant create session to zbxbid;

grant unlimited tablespace to zbxbid;

grant connect to zbxbid;

grant resource to zbxbid;

grant dba to zbxbid;

1.2 导入数据库

将备份的数据泵导出的数据库上传至/server/tools目录,修改dmp文件权限

chown oracle:oinstall 201611082230.dmp

使用imp命令导入数据库

[oracle@bj ~]$ imp zbxbid/zbxbid file='/server/tools/202005062231.dmp' FULL=Y

 

Import: Release 11.2.0.1.0 - Production on Thu Nov 10 18:25:20 2016

 

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

 

Export file created by EXPORT:V11.02.00 via conventional path

import done in US7ASCII character set and AL16UTF16 NCHAR character set

import server uses ZHS16GBK character set (possible charset conversion)

. importing ZBXBID's objects into ZBXBID

. . importing table                    "BID_APPLY"       1140 rows imported

. . importing table                    "BID_GROUP"        516 rows imported

. . importing table                     "BID_INFO"       3683 rows imported

. . importing table                     "BID_ITEM"        524 rows imported

. . importing table                  "BID_PAYMODE"          0 rows imported

. . importing table                      "BID_SEQ"          4 rows imported

. . importing table                  "BID_SESSION"        516 rows imported

. . importing table                     "BID_USER"        629 rows imported

Import terminated successfully without warnings.

1.3 配置sqlplus上下翻页功能

sqlplus默认不支持上下翻页,使用此功能需要安装软件rlwrap

先安装软件依赖包readline-devel

yum install –y readline-devel

将安装包rlwrap-0.30.tar.gz上传至/server/tools目录

tar xf rlwrap-0.30.tar.gz

cd rlwrap-0.30

./configure

make && make install

编辑/home/oracle/.bash_profile,在最后添加如下两行

alias sqlplus='rlwrap sqlplus'

alias rman='rlwrap rman'

使配置生效

source ~/.bash_profile

1.4 更新管理员密码

如果不知道管理员密码,可以使用如下方法更新管理员密码,本系统使用md5加密

登陆到sqlplus

sqlplus zbxbid/zbxbid

SQL> select userid,username,password from bid_user where username='admin';        

 

USERID             USERNAME         PASSWORD

--------------------------   ----------            --------------------------------

1                  admin            f78796a441ffef8b536e70d003628dca àhzw201505

 

如果系统中没有admin账号,可以初始化后台管理员账户admin/111111

insert into bid_user(userid,usertype,truename,username, password,useable,space_ename,role ) values('1','1','admin','admin', '96e79218965eb72c92a549dd5a330112','1','zbx','0000001000') ;

1.5 更改密码到期期限

系统默认安装完成后,oracle数据库用户密码有效期为180天,查询默认密码策略

select username,profile expiry_date from dba_users;

select * from dba_profiles s where s.profile='DEFAULT' and resource_name='PASSWORD_LIFE_TIME';

更改密码到期策略

ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;

 

2、 Java环境配置

2.1 上传jdk程序文件

这里使用jdk7版本进行配置安装,上传到/server/tools目录,解压后移动到/usr/local目录

tar xf jdk-7u80-linux-x64.tar.gz  

mv jdk1.7.0_80 /usr/local/

ln -s /usr/local/jdk1.7.0_80  /usr/local/jdk

查看软链接结果

ll /usr/local/jdk

lrwxrwxrwx 1 root root 22 Nov 10 20:57 /usr/local/jdk -> /usr/local/jdk1.7.0_80

编辑环境变量/etc/profile,在最后添加

export JAVA_HOME=/usr/local/jdk

export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH

export CLASSPATH=.$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/lib/tools.jar

使配置生效

. /etc/profile

验证java环境配置,如果出现以下版本信息,表示java环境配置完成

[root@bj tools]# java -version

java version "1.7.0_80"

Java(TM) SE Runtime Environment (build 1.7.0_80-b15)

Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)

3、 Tomcat配置

3.1 上传tomcat程序

/server/tools目录上传安装程序apache-tomcat-6.0.35-bj.tar.gz

tar xf apache-tomcat-6.0.35-bj.tar.gz

mkdir /application

mv apache-tomcat-6.0.35 /application/

ln -s /application/apache-tomcat-6.0.35/ /application/tomcat

配置数据库用户名和密码,配置文件路径为:apache-tomcat-6.0.35/webapps/ROOT/WEB-INF/classes/bid_pool.xml文件中的16-21行,将对应的IP,sid及用户密码修改为正在使用的对应信息即可     <driver-url>jdbc:oracle:thin:@172.16.10.31:1521:orcl</driver-url>    <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>    <driver-properties>       <property name="user" value="zbxbid"/>       <property name="password" value="zbxbid"/>    </driver-properties>


3.2 启动tomcat

进入安装目录,手动启动tomcat

[root@bj tools]# cd /application/tomcat/bin/

[root@bj bin]# ./startup.sh

Using CATALINA_BASE:   /application/tomcat

Using CATALINA_HOME:   /application/tomcat

Using CATALINA_TMPDIR: /application/tomcat/temp

Using JRE_HOME:        /usr/local/jdk

Using CLASSPATH:       /application/tomcat/bin/bootstrap.jar

检查端口启动情况

[root@bj bin]# netstat -tlunp|grep java

tcp        0      0 :::8081                     :::*                        LISTEN      60323/java          

tcp        0      0 ::ffff:127.0.0.1:8005       :::*                        LISTEN      60323/java          

tcp        0      0 :::1158                     :::*                        LISTEN      60005/java          

tcp        0      0 :::8009                     :::*                        LISTEN      60323/java          

tcp        0      0 :::5520                     :::*                        LISTEN      60005/java

tomcat加入开机自启动

echo "/application/tomcat/bin/startup.sh" >>/etc/rc.local

检查配置结果

tail -1 /etc/rc.local

/application/tomcat/bin/startup.sh

浏览器访问前台大厅验证结果http://10.0.0.11:8081