数据库配置通过ROTT folder plugin在/dotserver/tomcat-X.xx/webapps/ROOT/META-INF/context.xm文件中完成,一次只能使用一种数据库,在URL中必须正确的参数,如服务器地址(IP)、端口号、数据库实例名、用户名、密码。
DotCMS会积极使用缓存的方式去限制前台网站流量,数据库是DotCMS的重要一部分,而数据库性能对DotCMS至关重要。尤其是在编写环境。有很多中方法可以调整你正在使用的数据库,在/dotserver/tomcat-X.xx/webapps/root/META-INF/context.xml文件中你可以调DotCMS的连接数,同样在这你可以配置池子中的连接数量,连接池像一种连接的储藏仓库,每次DotCMS需要连接的时候从池子中取出一个连接,使用完成后再放回去,当没有连接时必须等待,直到有空闲的连接为止。
下边是添加配置
<!-- POSTGRESQL -->
<Resource name="jdbc/dotCMSPool" auth="Container"
type="javax.sql.DataSource" driverClassName="org.postgresql.Driver"
url="jdbc:postgresql://localhost/dotcms"
username="postgres" password="xxxxxx" maxTotal="60" maxIdle="10" maxWaitMillis="60000"
removeAbandonedOnBorrow="true" removeAbandonedOnMaintenance="true" removeAbandonedTimeout="60" logAbandoned="true"
timeBetweenEvictionRunsMillis="30000" validationQuery="SELECT 1" testOnBorrow="true" testWhileIdle="true"/>
可以设置数据库连接池的最大值,如果你的网站比较大,你可以增大连接池量,尽可能的在server.xml中配置你的连接器让连接池的大小接近你的线程数量,这将会保证每一个潜在用户的连接。
数据库参数定义及知识集
默认的情况下DotCMS使用H2数据库引擎,在下载DotCMS最新版本后,DotCMS启动不需要任何配置及数据库安装就能运行,但是H2数据库仅仅在开发环境和评估目的中推荐使用,在正式生产环境中不建议使用。
Postgres不支持程序语音"out-of-the-box",要启用程序语言,使用下边的postgres命令在创建DotCMS数据库前:
createlang plpgsql template1
create database dotcms_zip default character set = utf8 default collate = utf8_general_ci;
如果MySQL要开启日志功能
log-bin = /path/to/log-bin/file
binlog-format=row
在修改完my.cnf(unix和linux环境中)或my.ini(windows环境中)后重新启动数据库服务。
*MySQL DB Backup Note:从MySQL5之后,mysqldump将备份所有的触发器,存储过程及函数除外,下边有两个参数控制这个:
–routines – FALSE by default
–triggers – TRUE by default
如果想用DotCMS的存储过程清除/备份数据库备份请使用-routines的命令:
mysqldump --routines > outputfile.sql
这样就可以确保存储过程会被执行在dump/backup中。
*MySQL DB Upgrade Note:当更新MySQL到新版本后会出现下边的权限问题:
ERROR reindex.ReindexThread: Unable to index record
com.dotmarketing.exception.DotDataException: User does not have access to metadata required to determine stored procedure parameter types. If rights can not be granted, configure connection with "noAccessToProcedureBodies=true" to have driver generate parameters that represent INOUT strings irregardless of actual parameter types.
at com.dotmarketing.common.db.DotConnect.loadResult(DotConnect.java:197)
at com.dotmarketing.common.db.DotConnect.loadObjectResults(DotConnect.java:805)
at com.dotmarketing.common.business.journal.DistributedJournalFactoryImpl.findContentReindexEntriesToReindex(DistributedJournalFactoryImpl.java:329)
at com.dotmarketing.common.business.journal.DistributedJournalAPIImpl.findContentReindexEntriesToReindex(DistributedJournalAPIImpl.java:65)
at com.dotmarketing.common.reindex.ReindexThread.fillRemoteQ(ReindexThread.java:211)
at com.dotmarketing.common.reindex.ReindexThread.getNextDocToIndex(ReindexThread.java:221)
at com.dotmarketing.common.reindex.ReindexThread.run(ReindexThread.java:86)
Caused by: java.sql.SQLException: User does not have access to metadata required to determine stored procedure parameter types. If rights can not be granted, configure connection with "noAccessToProcedureBodies=true" to have driver generate param
在MySQL中,用户需要特殊的权限才能使用在mysql.procedure表中的存储过程,解决方案参考下边几个步骤:
1、确保context.xml中的数据库用户是MySQL的超级用户,
2、如果不是超级用户,请通过以下存储过程授权
grant select on mysql.proc to 'dotcms'@'localhost';
flush privileges;
3、在DotCMS的context.xml文件中增加noAccessToProcedureBodies=true属性
jdbc:mysql://xxx.xxx.xxx.xxx:3306/db_user?useUnicode=true&noAccessToProcedureBodies=true</connection-url>
设置这个属性能够解决用户不能访问存储过程的限制。
ALTER DATABASE dotcms SET READ_COMMITTED_SNAPSHOT ON;
GO
ALTER DATABASE dotcms SET ALLOW_SNAPSHOT_ISOLATION ON;
GO
通过以下的查询语句测试配置
SELECT sd.is_read_committed_snapshot_on,sd.snapshot_isolation_state_desc
FROM sys.databases AS sd
WHERE sd.[name] = 'dotcms';
如果你想了解更多的关于锁和隔离级别信息请看 http://msdn.microsoft.com/en-us/library/ms345124.aspx. 你能从Atlassian 获取更多SQLServer这样的问题.http://confluence.atlassian.com/display/CONFKB/Database+Deadlock+on+Microsoft+SQL+Server
1.9.2 dotCMS前注意:有一个问题,快照隔离状态没被捡起,即使在数据库设置。其次,如果您需要执行SQL可能锁定表或行而其他人连接到数据库确保你运行“快照”设置事务隔离级别。如果你在dotCMS代码编写一个插件,你让你的连接从DBConnection工厂已经在为你做。
在Oracle中启动DotCMS时需要这些权限,注意:这些权限可以是宽松的,但你要确保你的用户拥有这些权限可以启动DotCMS。
CREATE USER "DOTCMS" PROFILE "DEFAULT" IDENTIFIED BY "XXXXXXXX" ACCOUNT UNLOCK;
GRANT "CONNECT" TO "DOTCMS";
GRANT "AQ_ADMINISTRATOR_ROLE" TO "DOTCMS";
GRANT "AQ_USER_ROLE" TO "DOTCMS";
GRANT "AUTHENTICATEDUSER" TO "DOTCMS";
GRANT "CTXAPP" TO "DOTCMS";
GRANT "DBA" TO "DOTCMS";
GRANT "DELETE_CATALOG_ROLE" TO "DOTCMS";
GRANT "EJBCLIENT" TO "DOTCMS";
GRANT "EXECUTE_CATALOG_ROLE" TO "DOTCMS";
GRANT "EXP_FULL_DATABASE" TO "DOTCMS";
GRANT "GATHER_SYSTEM_STATISTICS" TO "DOTCMS";
GRANT "HS_ADMIN_ROLE" TO "DOTCMS";
GRANT "IMP_FULL_DATABASE" TO "DOTCMS";
GRANT "JAVADEBUGPRIV" TO "DOTCMS";
GRANT "JAVAIDPRIV" TO "DOTCMS";
GRANT "JAVASYSPRIV" TO "DOTCMS";
GRANT "JAVAUSERPRIV" TO "DOTCMS";
GRANT "JAVA_ADMIN" TO "DOTCMS";
GRANT "JAVA_DEPLOY" TO "DOTCMS";
GRANT "LOGSTDBY_ADMINISTRATOR" TO "DOTCMS";
GRANT "MGMT_USER" TO "DOTCMS";
GRANT "OEM_ADVISOR" TO "DOTCMS";
GRANT "OEM_MONITOR" TO "DOTCMS";
GRANT "OLAP_DBA" TO "DOTCMS";
GRANT "OLAP_USER" TO "DOTCMS";
GRANT "RECOVERY_CATALOG_OWNER" TO "DOTCMS";
GRANT "RESOURCE" TO "DOTCMS";
GRANT "SCHEDULER_ADMIN" TO "DOTCMS";
GRANT "SELECT_CATALOG_ROLE" TO "DOTCMS";
GRANT "WM_ADMIN_ROLE" TO "DOTCMS";
GRANT "XDBADMIN" TO "DOTCMS";
GRANT "XDBWEBSERVICES" TO "DOTCMS";
ALTER USER "DOTCMS" DEFAULT ROLE ALL;
EXIT
Oracle在Oracle 11G R2.0版本上有些获取模板的问题,除了11G其他的版本安装需要这个功能:
ORA-00600: internal error code, arguments: [rwoirw: check ret val], [], [], [], [], [], [], [], [], [], [], []
00600. 00000 - "internal error code, arguments: [%s], [%s], [%s], [%s], [%s], [%s], [%s], [%s]"
当出现下边错误时需要实现这个应急措施:
Add a database trigger to the Role and Policy Modeler Oracle database to set the Oracle parameter "_replace_virtual_columns=false". Run the following from a SQL*Plus session connected to the Role and Policy Modeler Oracle database with administrative privilege (that is, as SYSTEM or SYS):
-- BEGIN
CREATE OR REPLACE TRIGGER WORKAROUNDORA9965278 AFTER
LOGON ON DATABASE BEGIN
EXECUTE IMMEDIATE 'ALTER SESSION SET "_replace_virtual_columns"=false';
END;
/
-- END