opencms 安装细节探讨

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
云数据库 RDS PostgreSQL,集群系列 2核4GB
简介:

引入:

因为项目需求,我们要用到openCMS。虽然以前用过很多类似的内容管理系统类似Vignette,Fatwire,但是openCMS虽然大体功能差不多,具体并没用过,所以这里做了一些研究,会陆续把这些研究心得分享出来。这里先从openCMS安装讲起,虽然简单,但也有一些值得探讨的问题。


安装亮点1:不可以重复配置openCMS。

我们知道,第一次运行openCMS需要做配置,配置的请求URL是:http://localhost:8080/opencms/setup/ ,但是运行第一次之后就不可以运行第二次了,理由是在安装过程中,它会去调用CmsSetupBean类的prepareSetup10()方法:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/**
      * Prepares step 10 of the setup wizard.<p>
      */
    publicvoidprepareStep10() {
  
         if  (isInitialized()) {
             // lock the wizard for further use 
             lockWizard();
             // save Properties to file "opencms.properties" 
             saveProperties(getProperties(),CmsSystemInfo.FILE_PROPERTIES,  false );
  
             setSchemaGeneration( false );
             m_peristenceConfigurator.save();
         }
     }

而这个方法会去调用lockWizard()方法后保存opencms.properties让其生效,lockWizard方法的实现就是把opencms.properties中key为wizard.enabled设为false:

1
2
3
4
publicvoidlockWizard() {
  
         setExtProperty( "wizard.enabled" , CmsStringUtil.FALSE);
}

这会导致我们的opencms.properties被更改:

1
2
3
4
5
6
7
#
# Enable/Disable OpenCms Setup Wizard
# The wizard sets the flag to false after the setup.
# To use the wizard again, reset it manually to true.
# By setting no value, wizard can always be used.
#################################################################################
wizard.enabled=false

而下次运行时候,它会去判断此属性,判断点在CmsAutoSetup类的main()方法中调用的run()方法的第一行:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
/**
      * Performs the setup.<p>
      * @throws Exception 
      */
    publicvoidrun() throwsException {
  
         if  (m_bean.getWizardEnabled()) {
  
             longtimeStarted = System.currentTimeMillis();
  
             CmsSetupTests setupTests =  new  CmsSetupTests();
           
         }
}



安装亮点2: 正确设置max_allowed_packet这个mysql系统变量的大小。

在opencms安装过程中,它会对一些DB变量做检查,其代码如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/**
      * Returns an optional warning message ifneeded, <code>null</code> if not.<p>
     
      * @param db the selected database key
     
      * @return html warning, or <code>null</code> if no warning
      */
    publicString checkVariables(String db) {
  
         StringBuffer html =  new  StringBuffer( 512 );
         if  (m_con ==  null ){
             return  null // prior error,trying to get a connection
         }
         Exception exception =  null ;
         if  (db.equals( "mysql" )){
             String statement =  "SELECT @@max_allowed_packet;" ;
             Statement stmt =  null ;
             ResultSet rs =  null ;
             longmaxAllowedPacket =  0 ;
             try  {
                 stmt = m_con.createStatement();
                 rs = stmt.executeQuery(statement);
                 if  (rs.next()) {
                     maxAllowedPacket = rs.getLong( 1 );
                 }
             catch  (Exception e) {
                 exception = e;
             finally  {
                 if  (stmt !=  null ){
                     try  {
                         stmt.close();
                     catch  (SQLException e) {
                         // ignore
                     }
                 }
             }
             if  (exception ==  null ){
                 intmegabyte =  1024  1024 ;
                 if  (maxAllowedPacket >  0 ) {
                     html.append( "<p>MySQL system variable <code>'max_allowed_packet'</code>is set to " );
                     html.append(maxAllowedPacket);
                     html.append( " Byte (" );
                     html.append((maxAllowedPacket / megabyte) +  "MB).</p>\n" );
                 }
                 html.append( "<p>Please note that it will not be possible for OpenCms tohandle files bigger than this value in the VFS.</p>\n" );
                 intrequiredMaxAllowdPacket =  16 ;
                 if  (maxAllowedPacket < (requiredMaxAllowdPacket * megabyte)){
                     m_errors.add( "<p><b>Your <code>'max_allowed_packet'</code>variable is set to less than "
                         + (requiredMaxAllowdPacket* megabyte)
                         " Byte("
                         + requiredMaxAllowdPacket
                         "MB).</b></p>\n"
                         "<p>The required value for running OpenCms isat least "
                         + requiredMaxAllowdPacket
                         "MB."
                         "Please change your MySQL configuration (in the<code>my.ini</code> or <code>my.cnf</code>file).</p>\n" );
                 }
             else  {
                 html.append( "<p><i>OpenCms was not able to detect the value of your<code>'max_allowed_packet'</code>variable.</i></p>\n" );
                 html.append( "<p>Please note that it will not be possible for OpenCms tohandle files bigger than this value.</p>\n" );
                 html.append( "<p><b>The recommended value for running OpenCms is 16MB,please set it in your MySQL configuration (in your<code>my.ini</code> or <code>my.cnf</code>file).</b></p>\n" );
                 html.append(CmsException.getStackTraceAsString(exception));
             }
         }
         if  (html.length() ==  0 ) {
             return  null ;
         }
         return  html.toString();
     }

从这里可以看出,对于数据库是mysql的情形,它会先去执行数据库查询读取max_allowed_packet的值,这个变量主要让mysql限制服务器接受的单个数据包的大小(因为在openCMS中,经常要存富文本内容,所以这个值还是要设置大点为好),并且如果它<16MB, 则报错our max_allowed_packet variable is set to less than 16MB。而默认的mysql这个值配置是4MB,所以第一次setup出错。我们在my.ini中将其改为30MB,这样才过了这关:

wKiom1R6f1XxxiwOAAEsVJYPJ_0634.jpg



安装亮点3:opencms中资产的存储。

opencms中,这些资产都是以BLOB形式存储的:

wKioL1R6f4GSuLD4AAK72Iz3D_c513.jpg





本文转自 charles_wang888 51CTO博客,原文链接:http://blog.51cto.com/supercharles888/1584636,如需转载请自行联系原作者
相关实践学习
如何快速连接云数据库RDS MySQL
本场景介绍如何通过阿里云数据管理服务DMS快速连接云数据库RDS MySQL,然后进行数据表的CRUD操作。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
打赏
0
0
0
0
235
分享
相关文章
超好用!5款完全免费、支持全平台的笔记软件
好记忆不如一个烂笔头,对于这句话,我深以为然。 我觉得养成做笔记的习惯,对于工作和学习都能够提供很大的帮助。
超好用!5款完全免费、支持全平台的笔记软件
|
11月前
分款5款有趣又有用的小软件
今天我为大家推荐五款不同类型的软件,它们都是免费的,而且有着各自的特色和优势。
84 0
强烈推荐这5款功能强大的小软件
今日的栽种,明日的果实,今天继续分享五个功能强大的小软件。
188 1
软件丨最终的笔记软件
上次发现了钉钉出了个人版,试了下其实确实挺合适个人使用的,不过也有不少限制!
143 0
5款很少人知道的小众软件,先收藏再下载!
今天推荐5款十分小众的软件,知道的人不多,但是每个都是非常非常好用的,有兴趣的小伙伴可以自行搜索下载。
133 0
五款电脑上的小众软件,简洁干净,功能强悍,值得收藏
电脑上的各类软件有很多,除了那些常见的大众化软件,还有很多不为人知的小众软件,专注于实用功能,简洁干净、功能强悍。
202 0
Lattics:一款简单易用、好看强大的「类脑式」知识管理工具,笔记应用与写作软件二合一
如何快速找到一款适合自己的个人知识管理工具呢? 数据安全第一:你的数据你做主; 知识管理体系:树状结构+网状结构; 简单易用:不折腾,让工具服务自己。 基于这些标准,这篇文章筛选并介绍了新一代知识管理神器 Lattics。主要介绍了这个产品的特色与功能。
637 0
泼辣修图2023软件最新版功能介绍
无论你是入门新手还是摄影专家,泼辣修图都可以满足你的一切需求。对于入门新手而言,泼辣修图搭载的先进自动增强工具和富有创意的图像滤镜,可以帮助他们快速雕琢图像的每一个细节。对于摄影专家而言,图层混合、局部调整、曲线工具等等功能则是他们青睐有加的专业特性。泼辣修图专业版是一款强大的专业修图软件,拥有上百款调色工具还有丰富的图层素材, 更有智能的人像修饰面板,具备物体识别的智能蒙板,高效的滤镜管理系统和强大的文字
327 0
五款几乎没人知道的小众软件,按需下载
分享是一种神奇的东西,它使快乐增大,它使悲伤减小,坚持分享一些好用的软件给大家。
301 0
五款几乎没人知道的小众软件,按需下载
分享5款小众软件,大家按需下载
今天推荐一些可以大幅度提升办公效率的小软件,安全无毒,下载简单,最重要的是没有广告!
184 0
分享5款小众软件,大家按需下载
AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等