出家如初,成佛有余

在jira中集成tinymce 支持wysiwyg功能

Posted in Uncategorized by chuanliang on 2008/02/18

    由于我使用的3.9版本的jira本身的编辑器缺省为textarea,在录入缺陷及添加备注时候很不是方便,捣腾了一上午终于把TinyMCE 集成到jira中作为wysiywg编辑器,记录一下过程,其实基本上是按照文章WYSIWYG Editor in Jira 描写的步骤做的,只是按照自己所用的3.9版本的安装包调整了安装步骤及细节。

1、系统环境:

jira版本:atlassian-jira-enterprise-3.9-standalone

jira安装路径:/opt/jira (实际上是tomcat路径,jira的webapp应用在/opt/jira/atlassian-jira下)

2、安装步骤

  • http://tinymce.moxiecode.com/下载TinyMCE
  • 把TinyMCE解压到/opt/jira/atlassian-jira/includes/js
  • 在/opt/jira/atlassian-jira/includes/decorators/header.jsp中添加TinyMCE的js代码,采用的是TinyMCE的Full Feature的代码,可以参看tinymce的文档,按照自己要求调整一下TinyMCE的属性。
 <script language="JavaScript" type="text/javascript" src="<%=request.getContextPath()%>/includes/js/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
<script language="javascript" type="text/javascript">
tinyMCE.init({
        mode : "textareas",
        theme : "advanced",
        plugins : "table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,zoom,flash,searchreplace,print,contextmenu",
        theme_advanced_buttons1_add_before : "save,separator",
        theme_advanced_buttons1_add : "fontselect,fontsizeselect",
        theme_advanced_buttons2_add : "separator,insertdate,inserttime,preview,zoom,separator,forecolor,backcolor",
        theme_advanced_buttons2_add_before: "cut,copy,paste,separator,search,replace,separator",
        theme_advanced_buttons3_add_before : "tablecontrols,separator",
        theme_advanced_buttons3_add : "emotions,iespell,flash,advhr,separator,print",
        theme_advanced_toolbar_location : "top",
        theme_advanced_toolbar_align : "left",
        theme_advanced_statusbar_location : "bottom",
        plugin_insertdate_dateFormat : "%Y-%m-%d",
        plugin_insertdate_timeFormat : "%H:%M:%S",
        height:"350px",
        width:"550px",
        extended_valid_elements : "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]",
});
</script>

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

  • 修改国际化资源文件/opt/jira/atlassian-jira/WEB-INF/lib/language_default.jar 中的com/atlassian/jira/web/action/JiraWebActionSupport和/opt/jira/atlassian-jira/WEB-INF/lib/language_zh_CN.jar中的com/atlassian/jira/web/action/JiraWebActionSupport_zh_CN.properties,添加如下的内容。
admin.renderer.plugin.wysiwyg.renderer.name=Wysiwyg Style Renderer
admin.renderer.plugin.wysiwyg.renderer.desc=A renderer that will renderer content as entered into a wysiwyg editor.
  • 修改/opt/jira/atlassian-jira/WEB-INF/classes/system-renderers-plugin.xml,添加如下内容
<jira-renderer system="true" key="jira-wysiwyg-renderer" name="Wysiwyg Style Renderer"
i18n-name-key="admin.renderer.plugin.wysiwyg.renderer.name"
class="com.atlassian.jira.issue.fields.renderer.wysiwyg.WysiwygRenderer">
<description key="admin.renderer.plugin.wysiwyg.renderer.desc">A renderer that will renderer content from a wysiwyg editor.</description>
<resource type="velocity" name="edit" location="templates/plugins/renderers/wysiwyg/wysiwyg-renderer-edit.vm"/>
</jira-renderer>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
  • 创建/opt/jira/atlassian-jira/WEB-INF/classes/com/atlassian/jira/issue/fields/renderer/wysiwyg/WysiwygRenderer.java ,内容如下
package com.atlassian.jira.issue.fields.renderer.wysiwyg;

import com.atlassian.jira.issue.fields.renderer.JiraRendererPlugin;
import com.atlassian.jira.issue.fields.renderer.IssueRenderContext;
import com.atlassian.jira.plugin.renderer.JiraRendererModuleDescriptor;
import com.atlassian.jira.util.JiraKeyUtils;

/**
* A simple text renderer for jira..
*/
public class WysiwygRenderer implements JiraRendererPlugin
{
public static final String RENDERER_TYPE = "jira-wysiwyg-renderer";

private JiraRendererModuleDescriptor jiraRendererModuleDescriptor;

public String render(String value, IssueRenderContext context)
{ return JiraKeyUtils.linkBugKeys(value); }
public String renderAsText(String value, IssueRenderContext context)
{ return value; }
public String getRendererType()
{ return RENDERER_TYPE; }
public Object transformForEdit(Object rawValue)
{ return rawValue; }
public Object transformFromEdit(Object editValue)
{ return editValue; }
public void init(JiraRendererModuleDescriptor jiraRendererModuleDescriptor)
{ this.jiraRendererModuleDescriptor = jiraRendererModuleDescriptor; }
public JiraRendererModuleDescriptor getDescriptor()
{ return jiraRendererModuleDescriptor; }
}
  • .csharpcode, .csharpcode pre
    {
    font-size: small;
    color: black;
    font-family: consolas, “Courier New”, courier, monospace;
    background-color: #ffffff;
    /*white-space: pre;*/
    }
    .csharpcode pre { margin: 0em; }
    .csharpcode .rem { color: #008000; }
    .csharpcode .kwrd { color: #0000ff; }
    .csharpcode .str { color: #006080; }
    .csharpcode .op { color: #0000c0; }
    .csharpcode .preproc { color: #cc6633; }
    .csharpcode .asp { background-color: #ffff00; }
    .csharpcode .html { color: #800000; }
    .csharpcode .attr { color: #ff0000; }
    .csharpcode .alt
    {
    background-color: #f4f4f4;
    width: 100%;
    margin: 0em;
    }
    .csharpcode .lnum { color: #606060; }

    编译WysiwygRenderer.java

export classpath=/opt/jira/atlassian-jira/WEB-INF/lib/atlassian-bandana-0.1.13.jar:/opt/jira/atlassian-jira/WEB-INF/lib/atlassian-cache-servlet-0.5.4.jar:/opt/jira/atlassian-jira/WEB-INF/lib/atlassian-configurableobjects-0.4.22.jar:/opt/jira/atlassian-jira/WEB-INF/lib/atlassian-core-2007-04-23.jar:/opt/jira/atlassian-jira/WEB-INF/lib/atlassian-extras-0.7.29.jar:/opt/jira/atlassian-jira/WEB-INF/lib/atlassian-jdk-utilities-0.1.jar:/opt/jira/atlassian-jira/WEB-INF/lib/atlassian-jira-rpc-plugin-3.9-1.jar:/opt/jira/atlassian-jira/WEB-INF/lib/atlassian-jira-subversion-plugin-0.9.10.jar:/opt/jira/atlassian-jira/WEB-INF/lib/atlassian-johnson-2006-11-03.jar:/opt/jira/atlassian-jira/WEB-INF/lib/atlassian-mail-2007_03_23.jar:/opt/jira/atlassian-jira/WEB-INF/lib/atlassian-ofbiz-0.3.8.jar:/opt/jira/atlassian-jira/WEB-INF/lib/atlassian-plugins-2006-11-10.jar:/opt/jira/atlassian-jira/WEB-INF/lib/atlassian-profiling-1.1.4.jar:/opt/jira/atlassian-jira/WEB-INF/lib/atlassian-renderer-2007.01.17.jar:/opt/jira/atlassian-jira/WEB-INF/lib/atlassian-scheduler-2007-04-05.jar:/opt/jira/atlassian-jira/WEB-INF/lib/atlassian-tagutil-0.1.jar:/opt/jira/atlassian-jira/WEB-INF/lib/atlassian-trackback-2007-01-25.jar:/opt/jira/atlassian-jira/WEB-INF/lib/atlassian-velocity-0.3.19.jar:.:$JAVA_HOME/lib/tools.jar:/opt/jira/atlassian-jira/WEB-INF/classes ;

cd /opt/jira/atlassian-jira/WEB-INF/classes;

javac com/atlassian/jira/issue/fields/renderer/wysiwyg/WysiwygRenderer.java

  • 创建/opt/jira/atlassian-jira/templates/plugins/renderers/wysiwyg/wysiwyg-renderer-js.vm ,内容如下
tinyMCE.init(
{ mode : "textareas" }

);
  • 创建/opt/jira/atlassian-jira/templates/plugins/renderers/wysiwyg/wysiwyg-renderer-edit.vm,内容如下
    .csharpcode, .csharpcode pre
    {
    font-size: small;
    color: black;
    font-family: consolas, “Courier New”, courier, monospace;
    background-color: #ffffff;
    /*white-space: pre;*/
    }
    .csharpcode pre { margin: 0em; }
    .csharpcode .rem { color: #008000; }
    .csharpcode .kwrd { color: #0000ff; }
    .csharpcode .str { color: #006080; }
    .csharpcode .op { color: #0000c0; }
    .csharpcode .preproc { color: #cc6633; }
    .csharpcode .asp { background-color: #ffff00; }
    .csharpcode .html { color: #800000; }
    .csharpcode .attr { color: #ff0000; }
    .csharpcode .alt
    {
    background-color: #f4f4f4;
    width: 100%;
    margin: 0em;
    }
    .csharpcode .lnum { color: #606060; }

<DIV style="width:90%">
#if($singleLine)
<input style="width:100%"
type="text"
name="$fieldId"
value="$textutils.htmlEncode($!value)"
id="$fieldId"
class="textfield"
#if($maxlength)maxlength="$maxlength"#end
/>
#else
<textarea style="width:100%"
name="$fieldId"
id="$fieldId"
#if($rows)rows="$rows"#end
#if($wrap)wrap="$wrap"#end
#if($cols)cols="$cols"#end
#if($accesskey)accesskey="$accesskey"#end
class="textarea"
>$textutils.htmlEncode($!value)</textarea>
#end
</DIV>
<script language="javascript" type="text/javascript">
tinyMCE.execCommand('mceAddControl', true, "$fieldId");
</script>

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

  • 重启tomcat
  • 以管理员登录jira管理界面,查看Renderer是否生效

  菜单项System->Plugins->Renderer Plugin->Wysiwyg Style Renderer

  • 配置Renderer:

菜单项Issue Fields->Field Configurations->View Field Configurations->Default Field Configuration,点击在Comment和Description的Renderer属性后,进入”Edit Field Renderer”属性页,选择Wysiwyg Style Renderer皆可。

jira

wysiwyg

3、参考文章

http://confluence.atlassian.com/display/JIRACOM/WYSIWYG+Editor+in+Jira 

http://tinymce.moxiecode.com/documentation.php

Advertisements

apache与jira集成

Posted in Uncategorized by chuanliang on 2008/02/14

  由于jira与deki知识库(mindtouch deki wiki 安装配置指南)安装在同一台机器上,80端口已被架设deki的apache占用,原本懒得将apache和tomcat集成,打算直接用8080端口访问jira算了,安装完成后发现路由器上没有做8080端口影射的,不能直接从公网访问,放假了网管还没有上班,看来还是只有借助jk2将apache和tomcat集成,以便能够从外网直接通过80端口访问jira服务。记录一下架设过程。

1、环境说明

操作系统:Redhat AS4

php:5.2.5,用于deki

httpd:httpd-2.0.52-25.ent ,as4缺省安装版本

数据库:mysql 5.0.5

Jira:atlassian-jira-enterprise-3.9-standalone

Tomcat(jira自带) :5.5.20

JDK:1.6.0_01

2、安装apache和php

apache采用AS4的httpd 2.0.52的缺省安装包,安装路径为/etc/httpd

php5.2.5 安装过程参看mindtouch deki wiki 安装配置指南

3、安装jira

jira的安装路径为/opt/jira

  • 修改缺省的hsql数据库,采用mysql,同时将缺省Context修改为jira,以便以http://ip/jira方式访问

  修改/opt/jira/conf/server.xml,将如下内容

<Context path=”” docBase=”${catalina.home}/atlassian-jira” reloadable=”false”>
  <Resource name=”jdbc/JiraDS” auth=”Container” type=”javax.sql.DataSource”
    username=”sa”
    password=””
    driverClassName=”org.hsqldb.jdbcDriver”
    url=”jdbc:hsqldb:${catalina.home}/database/jiradb”
    minEvictableIdleTimeMillis=”4000″
    timeBetweenEvictionRunsMillis=”5000″
    maxActive=”20″ />

修改为

<Context path=”/jira” docBase=”${catalina.home}/atlassian-jira” reloadable=”true” crossContext=”true”>
  <Resource name=”jdbc/JiraDS” auth=”Container” type=”javax.sql.DataSource”
    username=”root”
    password=””
    driverClassName=”com.mysql.jdbc.Driver”
    url=”jdbc:mysql://localhost/jira?autoReconnect=true&amp;useUnicode=true&amp;characterEncoding=UTF8″
    minEvictableIdleTimeMillis=”4000″
    timeBetweenEvictionRunsMillis=”5000″
    maxActive=”20″ />

  • 取消jk2协议的注释

<!– To connect to an external web server (typically Apache) –>
<!– Define an AJP 1.3 Connector on port 8009 –>
    <Connector port=”8009″
      enableLookups=”false” redirectPort=”8443″ protocol=”AJP/1.3″ />

  • 上传mysql 的driver mysql-connector-java-5.0.5.jar到common/lib/下
  • 修改/opt/jira/atlassian-jira/WEB-INF/classes/entityengine.xml,修改ofbiz的实体引擎的Datasource数据库类型为mysql

    <datasource name=”defaultDS” field-type-name=”mysql”
      helper-class=”org.ofbiz.core.entity.GenericHelperDAO”
      check-on-start=”true”
      use-foreign-keys=”false”
      use-foreign-key-indices=”false”
      check-fks-on-start=”false”
      check-fk-indices-on-start=”false”
      add-missing-on-start=”true”
      check-indices-on-start=”true”>
        <jndi-jdbc jndi-server-name=”default” jndi-name=”java:comp/env/jdbc/JiraDS”/>
<!– Orion format: <jndi-jdbc jndi-server-name=”default” jndi-name=”jdbc/JiraDS”/> –>
<!– JBoss format: <jndi-jdbc jndi-server-name=”default” jndi-name=”java:/DefaultDS”/> –>
<!– Weblogic format: <jndi-jdbc jndi-server-name=”default” jndi-name=”JiraDS”/> –>
    </datasource>

NrqqMtMXgitAOknSLGRrfsaoRmOaAOBIXwBmivsMNxvIUTb
mj2KfRo<HPcFdS2zJdF61oBI2L09vXHct>jJtNVA3pOOw8L
NmRuuqrRqRRNOmQRpRXWQOpmQRqoMropnsvtUvUsXOvwvos
tUUnntvqmuopqvmvUUnntvqmuopqvmvUUvbbmXvkZlj

  • 安装jira 的subversion插件

要在jira中集成subversion,使用JIRA Subversion Plugin。很奇怪的是,在官方的version compatibility table上竟然没有针对3.9版本的subversion插件,好在下面的变更历史中有一段关于v3.9的说明

0.9.10 released

Contains a fix for SVN-133 (commit data does not follow Project Permission Scheme – honoring current assignee and reporter) and upped source dependencies for JIRA v3.9.

因此看来对应jira 3.9版本的subversion的插件需要使用0.9.10版本,下载地址为:
atlassian-jira-subversion-plugin-0.9.10.zip

安装过程很简单:

把javasvn-1.0.5.jar,ganymed.jar,atlassian-jira-subversion-plugin-0.9.10.jar复制到/opt/jira/atlassian-jira/WEB-INF/lib下。

修改subversion-jira-plugin.properties的svn.root、svn.username、svn.password,上传到/opt/jira/atlassian-jira/WEB-INF/classes下

4、编译安装 JK2 2.0.4

wget http://archive.apache.org/dist/tomcat/tomcat-connectors/jk2/jakarta-tomcat-connectors-jk2-src-current.tar.gz

tar zxvf jakarta-tomcat-connectors-jk2-src-current.tar.gz

cd jakarta-tomcat-connectors-jk2-2.0.4-src/jk/native2/

./configure –with-apxs2=/usr/bin/apxs

make

cd ../build/jk2/apache2

apxs -n jk2 -i mod_jk2.so

修改/etc/httpd/conf/httpd.conf,在httpd.conf中的LoadModule部分添加jk2_module

  LoadModule jk2_module modules/mod_jk2.so

同时修改DirectoryIndex

DirectoryIndex index.html index.html.var,index.php,index.jsp

5、创建JK2 的配置文件

需要手工创建JK2所用的2个配置文件:

  • /opt/jira/conf/jk2.properties

touch //opt/jira/conf/jk2.properties

内容如下:

# list of needed handlers.
handler.list=channelSocket,request
# Override the default port for the channelSocket
channelSocket.port=8009

 

  • /etc/httpd/conf/workers2.properties

touch /etc/httpd/conf/workers2.properties

内容如下:

[channel.socket:localhost:8009]
port=8009
host=localhost
[ajp13:localhost:8009]
channel=channel.socket:localhost:8009
[uri:/jira/*]
worker=ajp13:localhost:8009

# Define the log file location and file size
[shm]
file=/etc/httpd/logs/shm.file
size=1048576

6、重启jira及apache

apachectl restart

killall -9 java; sleep 5;/opt/jira/bin/startup.sh

访问jira:http://ip/jira

或者http://ip:8080/jira

 

Technorati 标签: ,,,,
Tagged with: , , , ,

学习电信BOSS系统好榜样-电子商务系统建设思考4:客户、组织机构、人员权限域思考

Posted in Uncategorized by chuanliang on 2008/02/10

  公司需要搭建新的融合电子商务及电信增值业务功能的系统,与以前单纯的电子商务系统或电信系统架构设计的需求相比较,此种融合了互联网和电信业务的需求的系统架构过程倒具有较大的挑战性,也比较有趣。尤其在商业模式尚需要进一步细化的情况下,怎样在模型搭建时候能够尽量考虑到未来业务模式的变迁,能够较好支撑未来业务的发展需求,不至于后续大动干戈。

  领域模型上总体上分为如下几个域:

  • 客户、组织机构、人员权限域
  • 产品域
  • 定价域
  • 计费/交易域
  • 帐务/结算域
  • 资源域
  • internet域
  • 统计及经营分析域

先思考一下客户、组织机构、人员权限域及产品域的模型。

人员权限及产品模型

mysql 数据库cpu 占用99.9%问题调优札记

Posted in Uncategorized by chuanliang on 2008/02/09

  新公司的系统一直很不稳定,店面销售人员经常报登不上系统或速度奇慢的情况,怀疑可能是代码存在数据库连接泄露及内存泄露现象,离春节只有几天时间,也来不急进行代码调优,只有从配置层面看有那些手段来采用,以便暂且缓解一下服务器压力,降低系统的故障率。为了第一时间能够知道服务器故障,基于nagios搭建了服务器监控程序,这样系统有故障时候,能够用短信方式通知系统故障,及时解决。

1、系统情况:

  操作系统:Redhat AS4

  数据库:mysql 4.1.18

  应用服务器:JBoss 3.2.7

  服务器: 4 x3.00GHz的Intel Xeon CPU

  数据库和应用服务器都部署在同一台服务器上。

  简单跟踪了一下,发现平常内存、io负载都不大,数据库连接数也不多。只是很奇怪的是mysql的cpu负载始终是99.9%,但整个系统的速度还行,开始怀疑是JVM、数据库参数、索引没有优化导致的,因此先着手对java虚拟机参数及数据库参数进行了调整。

2、java虚拟机调优

  • 调整虚拟机的参数

  JAVA_OPTS=”$JAVA_OPTS -Xms512m -Xmx1024m -server -XX:MaxPermSize=300m -XX:MaxNewSize=300m”

  • 调整jboss的数据库连接池,修改最大连接数及连接回收时间

<min-pool-size>20</min-pool-size>

<max-pool-size>300</max-pool-size>

<idle-timeout-minutes>1</idle-timeout-minutes>

<min-pool-size>20</min-pool-size>

3、数据库调优

  • 对所有的表,优化及增加索引。

发现一个好用的mysql工具navicat,感觉比ems 好用,用这东西增加索引方便多了。

  • 调整mysql参数

原来是基于my-medium.cnf 修改的参数,由于担心是大数据量查询sort区等不够及程序存在内存泄露问题,因此基于my-huge.cnf进行调整。

[client]
port            = 3306
socket          = /var/lib/mysql/mysql.sock
[mysqld]
port            = 3306
socket          = /var/lib/mysql/mysql.sock
skip-locking
key_buffer = 256M
max_allowed_packet = 1M
table_cache = 256
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 2M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size= 32M
thread_concurrency = 8
max_connections=300

#skip-networking

#log-bin

server-id       = 1

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash
#safe-updates

[isamchk]
key_buffer = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M

[myisamchk]
key_buffer = 128M
sort_buffer_size = 128M
read_buffer = 2M
write_buffer = 2M

[mysqlhotcopy]
interactive-timeout

调整后,支撑了3天左右,除了mysql的cpu占用始终是99%外,系统整体运行基本正常,忙于其他事情,没有继续跟踪。没想到大年初一接了一堆报警短信,执行查看了系统参数,发现系统竟然没有swap区,欣喜一阵,可能是这原因吧,于是临时建立swap区。

4、增加swap区

  • 在/swap下生成1G的文件

     # mkdir /swap

  # dd if=/dev/zero of=/swap/swapfile bs=500M count=2

  • 创建为swap文件

  #mkswap /swap

  • 让swap生效

  #swapon /swap

  • 查看一下swap

  #swapon -s

  • 把新增的swap文件加到fstab文件中让系统引导时自动启动

  #vi /etc/fstab

  /swap/swapfile swap swap defaults 0 0

    增加后,重启应用及服务,mysql的cpu占用还是持续性为99.9%,而且运行上一段时间还是出现无法登录的情况。远程登录到系统,发现内存、io、swap区占用都很正常,数据库连接数也很正常,而且在停止mysql和jboss后,直接重启jboss,不能正常启动成功,需要等上一会儿,怀疑是文件句柄及tcp连接尚未正常释放。联系以前遇到的情况,怀疑与操作系统允许的最大句柄数有关。

用ulimit -a|grep open 命令查看了结果为:

open files                      (-n) 1024

用cat /proc/sys/fs/file-max查看结果为:

379816

由于数据库和jboss同时部署在同一台服务器上,在负荷较小的情况下用lsof -u root |wc -l查看root用户的句柄数仍然为700多,因此在负荷较高的情况下,用户的最大句柄数1024是有点小。

5、修改操作系统句柄数

5.1、修改操作系统的最大限制数

  • 修改 /etc/sysctl.conf

    增加fs.file-max = 8061540

  • 在/etc/pam.d/login 中添加  

    session     required      /lib/security/pam_limits.so

  • 在/etc/security/limits.conf 中添加
    root              –        nofile           1006154

  修改root用户的句柄数(包括hard和soft)限制为1006154

  • 修改 /etc/rc.local   添加
    echo 8061540 > /proc/sys/fs/file-max

 

5.2、修改用户最大限制数

考虑到重启服务器的风险,先暂时修改一下启动jboss的root用户的/root/.bash_profile,增加如下内容:

ulimit -n 65535

重启jboss和mysql。

连续观察了几天,发现cpu始终占用99.9%的情况解决掉了,继续观察中。

 

6、参考文档

http://www.bea.com.cn/support_pattern/Too_Many_Open_Files_Pattern.html

http://kbase.redhat.com/faq/FAQ_80_1540.shtm

appfuse2.0安装札记

Posted in Uncategorized by chuanliang on 2008/02/05

  需要研究一下新版本的appfuse2.0对struts2+spring+hibernate架构的实现方式,看对于新架构的搭建有无参考价值。appfuse2.0 完全采用了maven来作为项目配置管理工具,与appfuse1.x主要采用ant作为核心工具有很大的差异,记录一下appfuse安装过程,供以后查阅。

1、下载并安装Maven 2.0.8

下载并安装Maven 2.0.8,在环境变量中配置MAVEN_HOME并把maven的bin目录(%MAVEN_HOME%bin)添加到环境变量PATH中。

假定maven安装到c:maven下

2、下载appfuse2.0.1并解压appfuse

https://appfuse.dev.java.net/files/documents/1397/77082/appfuse-dependencies-2.0.1.zip

假定解压到d:/program/appfuse-dependencies-2.0.1下。

3、修改%maven_home%/conf/settings.xml

修改settings.xml中的localRepository,指向appfuse的解压目录

<settings>
  <!– localRepository
   | The path to the local repository maven will use to store artifacts.
   |
   | Default: ~/.m2/repository
   –>
   <localRepository>d:/program/appfuse-dependencies-2.0.1</localRepository>

由于ant 1.7存在的bug(Problem with appfuse:gen in windows ),因此如果用的是ant 1.7,确认一下$USER_HOME/.m2/repository是否存在,不存在手工创建,并把修改后的settings.xml 拷贝到~.m2repository下不然在执行后续操作mvn appfuse:full-source时候会报如下错误
java.lang.IllegalArgumentException: When not aligning with a user install you mu
st specify a local repository location using the setLocalRepositoryDirectory( Fi
le ) method.
        at org.apache.maven.embedder.MavenEmbedder.createMavenSettings(MavenEmbe
dder.java:699)
        at org.apache.maven.embedder.MavenEmbedder.start(MavenEmbedder.java:628)

        at org.appfuse.mojo.installer.InstallSourceMojo.addModuleDependencies(In
stallSourceMojo.java:341)
        at org.appfuse.mojo.installer.InstallSourceMojo.addModuleDependencies(In
stallSourceMojo.java:303)
        at org.appfuse.mojo.installer.InstallSourceMojo.execute(InstallSourceMoj
o.java:142)
        at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPlugi
nManager.java:443)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(Defa
ultLifecycleExecutor.java:539)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandalone
Goal(DefaultLifecycleExecutor.java:493)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(Defau
ltLifecycleExecutor.java:463)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHan
dleFailures(DefaultLifecycleExecutor.java:311)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegmen
ts(DefaultLifecycleExecutor.java:278)
        at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLi
fecycleExecutor.java:143)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:334)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:125)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:280)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)

        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
[INFO] ————————————————————————

4、运行如下命令,生成struts2.0的项目

mvn archetype:create -DarchetypeGroupId=org.appfuse.archetypes -DarchetypeArtifactId=appfuse-basic-struts -DremoteRepositories=http://static.appfuse.org/releases -DarchetypeVersion=2.0.1 -DgroupId=com.yeeach.framework -DartifactId=myproject

myproject的项目文件生成到%MAVEN_HOME%confmyproject下

5、修改c:mavenconfmyprojectpom.xml里mysql的密码

6、在c:mavenconfmyproject下运行 mvn jetty:run-war,生成项目的war目录

如果要执行mvn tomcat:run-war,可以安装maven的tomcat plugin,可以参看

http://appfuse.org/display/APF/FAQ#FAQ-useexistingtomcat

可以直接利用mvn jetty:run-war生成的war文件,拷贝到tomcat目录下部署也可以

7、生成appfuse 2.0的代码

mvn appfuse:full-source

8、生成eclipse project

mvn eclipse:eclipse

9、参考文档

一个appfuse的eclipse插件:http://candy4appfuse.sourceforge.net/

http://appfuse.org/display/APF/FAQ#FAQ-useexistingtomcat

Technorati 标签: ,,,,
Tagged with: , , , ,

mindtouch deki wiki 安装配置指南

Posted in Uncategorized by chuanliang on 2008/02/01

1 环境说明

操作系统:

Redhat AS4

数据库:

mysql 5.0.51。由于使用了存储过程,必须使用myq 5.0.51以上版本,自带的版本太低。

php

5.2.5,必须使用5.0以上php版本,自带的版本太低。

mono

wget http://www.go-mono.com/download-stable/rhel-4-i386/mono.zip

mkdir mono

mv mono.zip mono/

rpm -ivh *rpm

httpd

httpd-2.0.52-25.ent

httpd-manual-2.0.52-25.ent

system-config-httpd-1.3.1-1

httpd-devel-2.0.52-25.ent

httpd-suexec-2.0.52-25.ent

gd

gd-2.0.28-4.4E.1

gd-devel-2.0.28-4.4E.1

zlib

zlib-devel-1.2.1.2-1.2

zlib-1.2.1.2-1.2

png

libpng-1.2.7-1.el4.2

libpng10-1.0.16-1

libpng-devel-1.2.7-1.el4.2

libpng10-devel-1.0.16-1

jpeg

libjpeg-devel-6b-33

libjpeg-6b-33

curl

curl-7.12.1-8.rhel4

curl-devel-7.12.1-8.rhel4

freetype

freetype-2.1.9-1

freetype-demos-2.1.9-1

freetype-devel-2.1.9-1

freetype-utils-2.1.9-1

ImageMagick

ImageMagick-c++-6.0.7.1-14

ImageMagick-devel-6.0.7.1-14

xloadimage-4.1-36.RHEL4

ImageMagick-perl-6.0.7.1-14

ImageMagick-6.0.7.1-14

ImageMagick-c++-devel-6.0.7.1-14

wv

libwvstreams-3.75.0-2

wvdial-1.54.0-3

links

symlinks-1.2-22

elinks-0.9.2-3.2

2 安装步骤

2.1 、卸载系统缺省的mysql库

2.2 、卸载缺省的php库

2.3 、安装PHP5

./configure –with-apxs2=/usr/sbin/apxs

–with-mysql=/usr

–with-mysqli=/usr/bin/mysql_config

–with-libxml-dir=/usr

–enable-dba

–with-openssl

–with-regex=php

–enable-bcmath

–with-gnu-ld

–with-tsrm-pthreads

–enable-ftp

–with-gettext

–enable-zend-multibyte

–enable-mbstring=all

–with-curl=/usr

–with-gd=/usr

–with-jpeg-dir=/usr

–with-png-dir=/usr

–with-zlib-dir=/usr

–with-freetype-dir=/usr

make

make install

2.4 、修改httpd.conf

AddType application/x-httpd-php .php

AddType application/x-httpd-php3 .php3

AddType application/x-httpd-php4 .php4

AddType application/x-httpd-php-source .phps

2.5 、修改php.ini

拷贝php.ini-dist为php.ini

cp php.ini-dist `php -i|grep php.ini|awk -F “=>” ‘{print $2}’`/php.ini

修改php.ini的如下内容:

session.save_path=/tmp

memory_limit = 128M

post_max_size = 64M

upload_max_filesize = 64M

2.6 、安装mysql

2.7 、安装mono

wget http://www.go-mono.com/download-stable/rhel-4-i386/mono.zip

mkdir mono

mv mono.zip mono/

rpm -ivh *rpm

2.8 、为mono创建/var/www/.wapi

mkdir /var/www/.wapi

chown apache /var/www/.wapi

2.9 、安装deki

wget http://downloads.sourceforge.net/dekiwiki/Deki_Wiki_1.8.3c_Hayes_source.tar.gz

tar xvzf Deki_Wiki_1.8.2b_Hayes_source.tar.gz

cd Deki_Wiki_1.8.3c_Hayes_source

mkdir /var/www/deki-hayes

cp -r web/* /var/www/deki-hayes/

service httpd restart

2.10 、编辑config/dekihost,修改apache用户www-data为apache

#!/bin/bash

# path to your wiki

DEKI_PATH=/var/www/deki-hayes

# this should match your Apache ServerName directive

DEKI_SERVERNAME=deki-hayes

prog=”MindTouch Deki Host Service”

start(){

if [ -f $DEKI_PATH/bin/mindtouch.host.sh ]; then

su -s /bin/bash apache — $DEKI_PATH/bin/mindtouch.host.sh start

fi

}

stop(){

if [ -f $DEKI_PATH/bin/mindtouch.host.sh ]; then

su -s /bin/bash apache — $DEKI_PATH/bin/mindtouch.host.sh stop

fi

}

status(){

testDream

}

以下内容省略

2.11 、配置自动启动

cp config/dekihost /etc/init.d/

ln -s /etc/init.d/dekihost /etc/rc3.d/S86dekihost

ln -s /etc/init.d/dekihost /etc/rc5.d/S86dekihost

2.12 、创建deki的log文件

touch /var/log/deki-api.log

chown apache /var/log/deki-api.log

2.13 、编辑/etc/httpd/conf/httpd.conf,在文件后增加如下内容

NameVirtualHost *:80

#

# NOTE: NameVirtualHost cannot be used without a port specifier

# (e.g. :80) if mod_ssl is being used, due to the nature of the

# SSL protocol.

#

#

# VirtualHost example:

# Almost any Apache directive may go into a VirtualHost container.

# The first VirtualHost section is used for requests without a known

# server name.

#

<VirtualHost *:80>

ServerName deki-hayes

ErrorLog /var/log/httpd/error.log

CustomLog /var/log/httpd/access.log common

DocumentRoot “/var/www/deki-hayes”

RewriteEngine On

RewriteCond %{REQUEST_URI} ^/$

RewriteRule ^/$ /index.php?title= [L,NE]

RewriteCond %{REQUEST_URI} ^/@gui/[^.]+$

RewriteRule ^/@gui/(.*)$ /proxy.php?path=$1 [L,QSA,NE]

RewriteCond %{REQUEST_URI} !^/(@api|editor|skins|config|@gui)/

RewriteCond %{REQUEST_URI} !^/index.php

RewriteCond %{REQUEST_URI} !^/favicon.ico$

RewriteCond %{REQUEST_URI} !^/robots.txt$

RewriteCond %{QUERY_STRING} ^$ [OR] %{REQUEST_URI} ^/Special:Search

RewriteRule ^/(.*)$ /index.php?title=$1 [L,QSA,NE]

# deki-api uses encoded slashes in query parameters so AllowEncodedSlashes must be On

AllowEncodedSlashes On

# mod_proxy rules

ProxyPass /@api http://localhost:8081

ProxyPassReverse /@api http://localhost:8081

SetEnv force-proxy-request-1.0 1

SetEnv proxy-nokeepalive 1

</VirtualHost>

2.14 、修改目录权限

chown -R apache /var/www/deki-hayes

apachectl restart

2.15 、授权apache能够创建/usr/local/var/目录,用于存放lucene index

mkdir -p /usr/local/var

chown apache /usr/local/var

2.16 、登录http://ip/config/index.php,通过页面安装deki

2.17 、页面安装完成后,自行如下操作

cd /var/www/deki-hayes/config

mkdir /etc/dekiwiki

chown apache /etc/dekiwiki

cp mindtouch.deki.startup.xml /etc/dekiwiki

cp LocalSettings.php /var/www/deki-hayes/

cp AdminSettings.php /var/www/deki-hayes/

cp mindtouch.host.sh /var/www/deki-hayes/bin/

/etc/init.d/dekihost start

3 参考资料

http://wiki.opengarden.org/Deki_Wiki/Installation_and_Upgrade/1.8_Hayes_Official_Install_and_Upgrade_Guide/CentOS_5

Technorati 标签: ,,,