LIULIANG

ubuntu11.10 安装tpc_w

首先简介一下在安装tpc_w时我们需要安装的软件
 jdk,tomcat,ant,jdbc,servlet,mysql,tpc_w
下面是具体的安装步骤
 一、安装jdk
 下载jdk-7u5-linux-i586.tar.gz
 下载地址:http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-i586.tar.gz
 安装jdk
 解压刚才下载的jdk-7u5-linux-i586.tar.gz
 然后在配置环境变量,命令如下:
 sudo gedit /etc/profile
  在文件后面添加如下环境变量:
 export JAVA_HOME=/jdk/jdk1.7.0
 export JRE_HOME=${JAVA_HOME}/jre
 export CATALINA_HOME=/tomcat/tomcat-7.0.30
 export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib:$CLASSPATH
 export PATH=${JAVA_HOME}/bin:$PATH
保存,关闭profile文件,然后时当前配置生效,使用命令如下:
 source /etc/profile
 然后再使用命令查看是否安装成功,命令如下:
   java -version
 会打印如下信息:
 java version "1.7.0_05"
 Java(TM) SE Runtime Environment (build 1.7.0_05-b05)
 Java HotSpot(TM) Client VM (build 23.1-b03, mixed mode)
说明已经安装成功了。


二、安装tomcat
  首先下载apache-tomcat-7.0.30.tar.gz
  然后解压上面的文件,
 配置环境变量

  $ cd programs/tomcat7/bin          #进入tomcat安装目录下的bin目录

  $ sudo gedit ./catalina.sh        #在打开的文本编辑器中加入

编辑catalina.sh文件,在
cygwin=false
darwin=false
os400=false
前面加入一下语句
  JAVA_HOME=/home/newbie/jdk7      #/home/newbie/jdk7 为jdk的安装路径
  JAVA_OPTS="-server -Xms512m -Xmx1024m -XX:PermSize=600M -XX:MaxPermSize=600m -Dcom.sun.management.jmxremote"       #这句也可以没有
  保存退出

  在tomcat7/bin目录下

  $ sudo ./startup.sh 若显示
Using CATALINA_BASE:   /tpc_w_all/tomcat7.0.30/apache-tomcat-7.0.30
Using CATALINA_HOME:   /tpc_w_all/tomcat7.0.30/apache-tomcat-7.0.30
Using CATALINA_TMPDIR: /tpc_w_all/tomcat7.0.30/apache-tomcat-7.0.30/temp
Using JRE_HOME:        /tpc_w_all/jdk1.7/jdk1.7.0_05
Using CLASSPATH:       /tpc_w_all/tomcat7.0.30/apache-tomcat-7.0.30/bin/bootstrap.jar:/tpc_w_all/tomcat7.0.30/apache-tomcat-7.0.30/bin/tomcat-juli.jar

 浏览器 输入 http://localhost:8080/ 可见缺省页面。配置成功。


三、 ant安装
  1. 运行:

    sudo apt-get install ant

 2. 查看成够安装否
root@ub-virtual-machine:~# ant -version             #查看ant版本
Apache Ant(TM) version 1.8.2 compiled on August 19 2011
root@ub-virtual-machine:~# ant               #使用ant
Buildfile: build.xml does not exist!
Build failed

若出现以上信息信息,则代表成够安装。


四、jdbc和server安装
  首先我们要下载mysql-connector-java-5.1.22.tar.gz
  然后解压给文件,然后在解压目录下找到mysql-connector-java-5.1.22-bin.jar
  servlet-api.jar在我们安装tomcat的路径下lib目录下即可找到
  然后将该这两个jar包添加到我们的环境变量中,这里我们同样使用
  sudo gedit /etc/profile
  在profile文件中的CLASSPATH环境变量中添加mysql-connector-java-5.1.22-bin.jar所在路径信息,在我本机中为:
export CLASSPATH=.:${CATALINA_HOME}/lib/servlet-api.jar:${CATALINA_HOME}/webapps/tpcw/WEB-INF/lib/mysql-connector-java-5.1.22-bin.jar:${JAVA_HOME}/lib:${JRE_HOME}/lib:$CLASSPATH

五、mysql的安装
下载地址:
http://dev.mysql.com/downloads/mysql/

1、添加用户组
#> groupadd mysql
2、添加用户
#> useradd -r -g mysql mysql
3、切换目录
#> cd /usr/local
4、解压(mysql-5.5.22-linux2.6-i686.tar.gz已经复制到/usr/local下)
#> tar zxvf mysql-5.5.22-linux2.6-i686.tar.gz
5、创建软链接
#> ln -s mysql-5.5.22-linux2.6-i686 mysql
6、删除压缩包(可操作)
#> rm mysql-5.5.22-linux2.6-i686.tar.gz
7、进入mysql目录
#> cd mysql
8、改变用户权限和组权限
#> chown -R mysql .
#> chgrp -R mysql .
9、初始化数据库
<1> 保证在/etc/目录下面没有my.cnf、mysql文件夹,如果有请删除
<2> 安装libaio1.so 执行sudo apt-get install libaio1 安装了则跳过
#> scripts/mysql_install_db --user=mysql


初始化成功则出现如下提示:
Installing MySQL system tables...
OK
Filling help tables...
OK


To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system


PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:


./bin/mysqladmin -u root password 'root'
./bin/mysqladmin -u root -h VWmare password 'new-password'


Alternatively you can run:
./bin/mysql_secure_installation


which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.


See the manual for more instructions.


You can start the MySQL daemon with:
cd . ; ./bin/mysqld_safe &


You can test the MySQL daemon with mysql-test-run.pl
cd ./mysql-test ; perl mysql-test-run.pl


Please report any problems with the ./bin/mysqlbug script!


10、修改权限
#> chown -R root .
#> chown -R mysql data


11、复制配置文件
#> cp support-files/my-medium.cnf /etc/my.cnf
#> cp support-files/mysql.server /etc/init.d/mysql.server


12、启动数据库
#> bin/mysqld_safe --user=mysql &


13、查看是否有3306端口启动
#> netstat -nat


14、设置密码
#> ./bin/mysqladmin -u root password 'new-password'
或者
#> ./bin/mysql_secure_installation


15、使用mysql
#> cd bin  
#> ./mysql -u root -p


16、设置开机自动启动
#> cd /etc/init.d/
sudo update-rc.d mysql.server defaults

17、设置默认编码为UTF8

登录MySQL,执行编码显示:

show variables like 'character%';

QUOTE:

+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | latin1 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+

sudo vi /etc/mysql/my.cnf


找到[client] 添加:



default-character-set=utf8

找到[mysqld] 添加:

character_set_server = utf8

init_connect='SET NAMES utf8'

修改好后,重新启动mysql 即可.
sudo/etc/init.d/mysql.server restart

若启动异常则把[mysqld]处修改为

default-character-set=utf8

init_connect='SET NAMES utf8'


查询一下show variables like 'character%';

QUOTE:

+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+


六、tpcw_w安装
   首先下载tpcw-java-dist-1.0.zip,下载网址:http://mitglied.multimania.de/jankiefer/tpcw/index.html
   然后将该文件进行解压
   然后修改其中的main.properties、tpcw.properties 文件
下面时我的main.properties文件的内容(最后的dbName制定数据库名,在数据库里新建一个数据库名是用tpcw的数据库)
##############################################################################
# main.properties for build.xml.
# Copyright 2003 by Jan Kiefer.
#
# This file is distributed "as is". It comes with no warranty and the
# author takes no responsibility for the consequences of its use.
#
# Usage, distribution and modification is allowed to everyone, as long
# as reference to the author(s) is given and this license note is included.
##############################################################################

#<!-- Path to servlet.jar, change this ... -->
cpServ=/tomcat/tomcat-7.0.30/lib/servlet-api.jar

#<!-- Path to the JDBC driver for your DBMS, change this ... -->
cpJDBC=/tomcat/tomcat-7.0.30/webapps/tpcw/WEB-INF/lib/mysql-connector-java-5.1.22-bin.jar

#<!-- Directory where tpcw.war will be put with task 'inst' -->
webappDir=/tomcat/tomcat-7.0.30/webapps/tpcw

#<!-- Path to the Perl interpreter. -->
perlPath=/usr/bin/perl

#<!-- Directory where the Images will be put with task genimg. -->
imagesDir=${webappDir}/Images

#<!-- Filter file for SQL queries, change this if needed -->
sqlFilter=sql-mckoi.properties

#dbName=std
dbName=tpcw
 以及我的tpcw.properties:
##############################################################################
# tpcw.properties for build.xml.
# Copyright 2003 by Jan Kiefer.
#
# This file is distributed "as is". It comes with no warranty and the
# author takes no responsibility for the consequences of its use.
#
# Usage, distribution and modification is allowed to everyone, as long
# as reference to the author(s) is given and this license note is included.
##############################################################################

# set the JDBC parameters
jdbc.driver=com.mysql.jdbc.Driver
#jdbc.driver=com.mckoi.JDBCDriver
jdbc.path=jdbc:mysql://localhost:3306/tpcw?user=root&password=a
jdbc.connPoolMax=100

sql.bigCharType=varchar(500)
#sql.bigCharType=tinyblob

# set the values you want for tpcw
num.item=1000
num.eb=10

# use the right session string for your servlet container
#sessionIdString=$sessionid$
sessionIdString=jsessionid=

standardUrl=http://localhost:8080
#servletUrlPath=/servlet
servletUrlPath=/
tpcwUrlPath=/tpcw


  在解压后的tpc-w路径下将TPCW_Database.std.java文件改名为TPCW_Database.tpcw.java

 修改函数名
 /home/liova/download/tpcw/tpc-w/src/rbe/util/Debug.java中
 public class Debug {  public static void assert(boolean assertCond, String message)
 把assert改成你自己想要的名字,我是改成assert1。
 接着以下三个文件中所有出现的Debug.assert中的assert都改成你自己修改函数名,我这里改完是Debug.assert1
 /home/liova/download/tpcw/tpc-w/src/rbe/EB.java
 /home/liova/download/tpcw/tpc-w/src/rbe/util/CharSetStrPattern.java
 /home/liova/download/tpcw/tpc-w/src/rbe/util/Histogram.java
 

修改代码:tpc-w\tpcw\servlets\TPCW_Database.java
    Class.forName(driverName); 改为:Class.forName(driverName).newInstance();//Class.forName(driverName);  
            
   ant
(1)执行命令

   ant dist        (这条命令用来编译servlets以及rbe java文件)
   ant inst        (这命令执行后,将把tpcw.war包移动到tomcat的tpcw目录下)  

(2)创建数据库中的表及记录,执行

   ant gendb        (这命令将调用TPCW_populate.class)

(3)创建图像

   ant genimg     (这命令将用make编译图像生成工具,用perl去运行图像生成脚本,复制静态图像到tomcat主目录)

然后在主目录下新建一个tpcw目录和文件
 新建如下路径
  \tpcw\Images         #将ant genimg生成的图片复制到该路径
  \tpcw\WEB-INF
  \tpcw\WEB-INF\classes   #将ant dist生成的servlet的字节文件拷贝到该路径下,就是src\serverts下的.class文件
  \tpcw\WEB-INF\lib      #将mysql-connector-java-5.1.22-bin.jar放到该路径(环境变量中如果有就不需要了)
  \tpcw\WEB-INF\web.xml

   web.xml文件如下:

<?xml version="1.0" encoding="ISO-8859-1"?>

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
    version="2.4">

  <display-name>TPC-W</display-name>
  <description>
    TPC-W Java Implementation
  </description>

  <servlet>
    <servlet-name>TPCW_home_interaction</servlet-name>
    <servlet-class>TPCW_home_interaction</servlet-class>
  </servlet>
  <servlet>
    <servlet-name>TPCW_shopping_cart_interaction</servlet-name>
    <servlet-class>TPCW_shopping_cart_interaction</servlet-class>
  </servlet>
  <servlet>
    <servlet-name>TPCW_order_inquiry_servlet</servlet-name>
    <servlet-class>TPCW_order_inquiry_servlet</servlet-class>
  </servlet>
  <servlet>
    <servlet-name>TPCW_order_display_servlet</servlet-name>
    <servlet-class>TPCW_order_display_servlet</servlet-class>
  </servlet>
  <servlet>
    <servlet-name>TPCW_search_request_servlet</servlet-name>
    <servlet-class>TPCW_search_request_servlet</servlet-class>
  </servlet>
  <servlet>
    <servlet-name>TPCW_execute_search</servlet-name>
    <servlet-class>TPCW_execute_search</servlet-class>
  </servlet>
  <servlet>
    <servlet-name>TPCW_new_products_servlet</servlet-name>
    <servlet-class>TPCW_new_products_servlet</servlet-class>
  </servlet>
  <servlet>
    <servlet-name>TPCW_best_sellers_servlet</servlet-name>
    <servlet-class>TPCW_best_sellers_servlet</servlet-class>
  </servlet>
  <servlet>
    <servlet-name>TPCW_product_detail_servlet</servlet-name>
    <servlet-class>TPCW_product_detail_servlet</servlet-class>
  </servlet>
  <servlet>
    <servlet-name>TPCW_customer_registration_servlet</servlet-name>
    <servlet-class>TPCW_customer_registration_servlet</servlet-class>
  </servlet>
  <servlet>
    <servlet-name>TPCW_buy_request_servlet</servlet-name>
    <servlet-class>TPCW_buy_request_servlet</servlet-class>
  </servlet>
  <servlet>
    <servlet-name>TPCW_buy_confirm_servlet</servlet-name>
    <servlet-class>TPCW_buy_confirm_servlet</servlet-class>
  </servlet>
  <servlet>
    <servlet-name>TPCW_admin_request_servlet</servlet-name>
    <servlet-class>TPCW_admin_request_servlet</servlet-class>
  </servlet>
  <servlet>
    <servlet-name>TPCW_admin_response_servlet</servlet-name>
    <servlet-class>TPCW_admin_response_servlet</servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>TPCW_home_interaction</servlet-name>
    <url-pattern>/TPCW_home_interaction</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>TPCW_shopping_cart_interaction</servlet-name>
    <url-pattern>/TPCW_shopping_cart_interaction</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>TPCW_order_inquiry_servlet</servlet-name>
    <url-pattern>/TPCW_order_inquiry_servlet</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>TPCW_order_display_servlet</servlet-name>
    <url-pattern>/TPCW_order_display_servlet</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>TPCW_search_request_servlet</servlet-name>
    <url-pattern>/TPCW_search_request_servlet</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>TPCW_execute_search</servlet-name>
    <url-pattern>/TPCW_execute_search</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>TPCW_new_products_servlet</servlet-name>
    <url-pattern>/TPCW_new_products_servlet</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>TPCW_best_sellers_servlet</servlet-name>
    <url-pattern>/TPCW_best_sellers_servlet</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>TPCW_product_detail_servlet</servlet-name>
    <url-pattern>/TPCW_product_detail_servlet</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>TPCW_customer_registration_servlet</servlet-name>
    <url-pattern>/TPCW_customer_registration_servlet</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>TPCW_buy_request_servlet</servlet-name>
    <url-pattern>/TPCW_buy_request_servlet</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>TPCW_buy_confirm_servlet</servlet-name>
    <url-pattern>/TPCW_buy_confirm_servlet</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>TPCW_admin_request_servlet</servlet-name>
    <url-pattern>/TPCW_admin_request_servlet</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>TPCW_admin_response_servlet</servlet-name>
    <url-pattern>/TPCW_admin_response_servlet</url-pattern>
  </servlet-mapping>

  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
  </welcome-file-list>

</web-app>


然后在tomcat的安装路径下 conf/Catalina/localhost/  目录下新建tpcw.xml文件,文件内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/tpcw" docBase="/tpcw" reloadable="true"/>

做到这里就安装好了,可以运行了。可以访问http://127.0.0.1:8080/tpcw/TPCW_home_interaction页面测试是否安装成功。

运行TPC-W

  1.cd /home/liova/download/tpcw/tpc-w/dist/
  2.java rbe.RBE -EB rbe.EBTPCW1Factory 30 -OUT run1.m -RU 100 -MI 1000 -RD 100 -WWW http://localhost:8080/tpcw/ -CUST 10000 -ITEM 10000
  命令的解释可参考/home/liova/download/tpcw/tpc-w/docs/use.html以及/home/liova/download/tpcw/tpc-w/dist
  /doc/readme-rbe.txt

  输出的结果在/home/liova/download/tpcw/tpc-w/dist/下的run1.m文件中(名字自己在参数的指定)


参考:
http://tcloud.sjtu.edu.cn/wiki/index.php/TPCW_INSTALL
http://tcloud.sjtu.edu.cn/wiki/index.php/Wooo:Building_TPCw
http://www.cnblogs.com/eastson/archive/2012/06/09/2543489.html
http://www.itpub.net/thread-1330311-1-1.html
http://blog.csdn.net/cybercode/article/details/6737415

posted on 2012-09-23 14:53 BIG森林 阅读(1250) 评论(0)  编辑 收藏 引用 所属分类: Ubuntu


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


<2012年5月>
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789

导航

统计

常用链接

留言簿(2)

随笔分类

随笔档案

搜索

最新评论

阅读排行榜

评论排行榜