- 浏览: 295849 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (155)
- Liferay portal研究 (23)
- spring研究 (7)
- Displaytag (2)
- Flash Builder (0)
- 搜索引擎 (12)
- 杂项 (17)
- SCM管理 (7)
- Jquery (5)
- Linux (7)
- Oracle (10)
- httpd集成 (3)
- Maven2 (5)
- 企业管理 (1)
- tomcat高级 (4)
- dos命令 (1)
- ldap (2)
- Java (8)
- webservice (1)
- jetty代码研究 (3)
- OpenCMS (1)
- JMX (2)
- hibernate (5)
- Ant (1)
- js tree (4)
- Quartz (0)
- CMS (1)
- springside (1)
- proxool (1)
- freemarker (1)
- Cookie (1)
- CAS SSO (4)
- mysql (1)
- php (1)
- js (2)
- Asset (1)
- openmeeting (1)
- h2数据库 (2)
- wcf vs java ws (1)
最新评论
-
22199143:
...
当在重启Tomcat容器时 Exception in Thread "HouseKeeper" java.lang.NullPointerException -
liuqq:
一直用Oracle开发,几乎没有接触过其他数据库。使用Mysq ...
The Nested Set Model -
yjsxxgm:
yjsxxgm 写道FFFFFFFFFFFFFFFWWW
java 访问wcf -
yjsxxgm:
FFFFFFFFFFFFFFF
java 访问wcf -
hjp222:
scanIntervalSeconds 是重新启动,并非真正的 ...
Jetty 热部署
Database sharding is a way of scaling your database horizontally. For a given table or set of tables, you split up the data that is stored and fetched based on a given hash or something like that. Google, Facebook, and Wikipedia all use database sharding.
Table of Contents [-+]
Benefits
- One database does not get overloaded
- Smaller queries (since each table has less data now)
- Better overall throughput under load because all your IO is not going through one database server.
Sharded Portal Instances
At present, sharding exists in Liferay from version 5.2.3+ for handling data across multiple portal instances. Here's what you do to get it up.
- After you have a normally working development environment, make sure your hosts file is setup to allow virtual hosting (for our convenience, I will call the hosts abc1.com, abc2.com, abc3.com, etc.).
- Use the create-minimal SQL script (from our Downloads section) to create three database schemas: lportal, lportal1, and lportal2. Be careful and use the scripts for your liferay portal version, otherwise, it won't work. By default, the configuration files are setup for three schemas called default, one and two, but you can configure it for more. All this configuration is set up in the file portal-impl/src/META-INF/shard-data-source-spring.xml . As you will see, we will include this file in the property spring.configs in the next step. In case we want to modify it we just should write our own file in the Extension Environment and include it in this property instead of the default one.
- In your portal-ext.properties, you will need to set the following:
- Enable META-INF/shard-data-source-spring.xml under spring.configs.
- Configure the jdbc schema settings for jdbc.default.*, jdbc.one.*, and jdbc.two.*.
- Enable the shard names: shard.available.names=default,one,two
- Don't forget to set the appropriate username and password for each schema.
- Startup the server and create several (2-3) portal instances (e.g., abc1.com, abc2.com, abc3.com).
- Using your favorite database browser, do a query on each of your schemas for the User_ table, and you will notice that the data is now distributed across different schemas. That's it!
Additional Settings
- Remember that default, one, and two are default values defined in portal-impl/src/META-INF/shard-data-source-spring.xml and portal-ext.properties. If you want to change it, make sure to propagate the changes to the spring XML file as well as portal-ext.properties.
- If you want to manually select the shard (via the GUI when creating portal instances), you need to enable in your portal-ext.properties file: shard.selector=com.liferay.portal.dao.shard.ManualShardSelector. Otherwise, the shard for the data will be chosen using a round robin technique.
======================================================================
Hi,
Multiple tenants are using one portal, but each tenant requires a separate datasource (database). So upon each incoming request we need to perform a context switch each time a Hibernate Session is needed. I have browsed the source fairly extensively and found what I believe is the best place to hook in for this context switch:
com.liferay.portal.dao.orm.hibernate.SessionFactoryImpl#openSession() {
...
if (PropsValues.SPRING_HIBERNATE_SESSION_DELEGATED) {
session = _sessionFactoryImplementor.getCurrentSession();
}
else {
session = _sessionFactoryImplementor.openSession();
}
I found that SPRING_HIBERNATE_SESSION_DELEGATED maps to the following property:
# Set this property to false to manually open and close sessions
spring.hibernate.session.delegated=true
Per what I read in docs and code I can set this property to false, which I have done:
spring.hibernate.session.delegated=false
Docs say to also change the following property to reference my replacement class:
# Set the bean name for the Liferay session factory.
spring.hibernate.session.factory=com.blah.blah.BlahSessionFactoryImplementor
I have done this in portal-ext.properties in:
tomcat-6.0.18/webapps/ROOT/WEB-INF/classes/portal-ext.properties
I have also placed my class here:
tomcat-6.0.18/webapps/ROOT/WEB-INF/classes/com/blah/blah/BlahSessionFactoryImplementor.class
When I start the portal I see that the ext properties get loaded. But my class is apparently not loaded. I have tried to log output when openSession() is called but I see no logging to the console. I also have added an explicit exception throw from the method in case logging is not setup correctly. I see no indication that an exception is thrown. The portal runs normally. I am sure my class is not being used.
1. Is this the correct way to override the session factory? If so, what could be the problem?
2. If not, what should I do?
Thanks!
Vaughn
Multiple tenants are using one portal, but each tenant requires a separate datasource (database). So upon each incoming request we need to perform a context switch each time a Hibernate Session is needed. I have browsed the source fairly extensively and found what I believe is the best place to hook in for this context switch:
com.liferay.portal.dao.orm.hibernate.SessionFactoryImpl#openSession() {
...
if (PropsValues.SPRING_HIBERNATE_SESSION_DELEGATED) {
session = _sessionFactoryImplementor.getCurrentSession();
}
else {
session = _sessionFactoryImplementor.openSession();
}
I found that SPRING_HIBERNATE_SESSION_DELEGATED maps to the following property:
# Set this property to false to manually open and close sessions
spring.hibernate.session.delegated=true
Per what I read in docs and code I can set this property to false, which I have done:
spring.hibernate.session.delegated=false
Docs say to also change the following property to reference my replacement class:
# Set the bean name for the Liferay session factory.
spring.hibernate.session.factory=com.blah.blah.BlahSessionFactoryImplementor
I have done this in portal-ext.properties in:
tomcat-6.0.18/webapps/ROOT/WEB-INF/classes/portal-ext.properties
I have also placed my class here:
tomcat-6.0.18/webapps/ROOT/WEB-INF/classes/com/blah/blah/BlahSessionFactoryImplementor.class
When I start the portal I see that the ext properties get loaded. But my class is apparently not loaded. I have tried to log output when openSession() is called but I see no logging to the console. I also have added an explicit exception throw from the method in case logging is not setup correctly. I see no indication that an exception is thrown. The portal runs normally. I am sure my class is not being used.
1. Is this the correct way to override the session factory? If so, what could be the problem?
2. If not, what should I do?
Thanks!
Vaughn
发表评论
-
ogl的入门
2010-03-30 08:24 1416http://jxb8901.iteye.com/blog/2 ... -
jaas 入门
2010-03-04 17:10 1911本例是认证的实现,JAAS定义了可插拔的认证机制,使认证逻辑独 ... -
JAAS HelloWorld
2010-03-04 17:09 1264Examples: JAAS HelloWorld Thes ... -
liferay sso
2010-01-28 16:18 2336基于Liferay的CAS SSO ... -
liferay 权限
2010-01-04 13:49 1587liferay的权限很多资料说 ... -
liferay多数据源
2009-12-15 15:46 1787Configure MySQL Master/Slave ... -
杂项2
2009-11-18 21:44 920function <portlet:namespace ... -
Simple Apache CXF web service integration
2009-11-18 20:24 1199For those who wants to use the ... -
LiferayCounter机制
2009-10-24 14:08 1060public long increment(String na ... -
lifery 老的资源
2009-10-23 14:40 879http://docs.liferay.com/portal/ ... -
liferay portal 的开发目录结构
2009-10-17 11:59 1732portal-kenel.jar 不依赖任何非标准jar(只依 ... -
liferay 常用urls
2009-10-16 22:43 955http://blog.csdn.net/smilingleo ... -
liferay 调用webservice
2009-10-16 22:34 4548Liferay是基于SOA理念设计的,很容易通过Web Ser ... -
Liferay权限管理的讲解
2009-10-12 21:37 1542这篇文章讲解了liferay中使用的权限管理系统的内部细节,涉 ... -
ServiceContext Pattern
2009-10-12 21:30 1036The Service Context is an objec ... -
Liferay性能调优
2009-10-12 21:25 2206CONTRIBUTIONS WANTED Corné|Corn ... -
Liferay重要对象-Layout
2009-10-12 21:19 2227A layout is an instance of a si ... -
liferay常用配置
2009-10-12 20:47 1165在实际需求中,如果是做网站那我们有时候会有这样的需求,即希望用 ... -
liferay学习系列(3)
2009-10-11 20:16 1250在一个Portlet中链接到另一个Portlet 这个问题,应 ... -
liferay学习系列(2)
2009-10-07 20:31 6968想做个用户积分管理,类似于论坛积分的概念,首先在用户管理里面添 ...
相关推荐
1、创建数据库 首先我们创建相应的数据库 create database sharding_0; create database sharding_1; 这样我们就创建了两个数据库sharding_0和sharding_1; 脚本在项目里面
Oracle Sharding Database(分片数据库)是一项数据库水平分割的技术,它能够通过将数据分布在多个数据库服务器中,从而实现大规模并发访问和高效数据管理。Oracle Sharding 是Oracle数据库提供的解决方案,使得应用...
此时,分库(database sharding)和分表(table sharding)成为有效的解决方案。分库是将数据分散到多个数据库中,而分表则是将一个大表拆分成多个小表,通常在相同的数据库内进行。 在"sharding_demo-master"这个...
水平切分可以进一步细分为分库(Database Sharding)和分表(Table Sharding)两种主要类型: 1. **分库(Database Sharding)**:将整个数据库中的表按照一定的规则拆分成多个子集,并将这些子集分别存储在不同的...
《简单分库中间件simple-sharding的探索与实践》 在大数据时代,数据库的扩展性和性能成为了企业系统架构的关键挑战之一。"simple-sharding",正如其名,是一款旨在简化数据库分片操作的中间件,它作为一个轻量级的...
假如您有一个应用程序,随着业务越来越有起色,系统所牵涉到的数据量也就越来越大,此时您要涉及到对...由于许多系统的瓶颈都处在数据存储上,因此一种叫做“数据分片(DatabaseSharding)”的数据架构方式应运而生,本
1. 数据库切分: Database Sharding 是一种将大型数据库拆分成多个小的逻辑数据库的技术,以便提高数据库的性能和可扩展性。 2. Hibernate Shards:Hibernate Shards 是一个基于 Java 的开源框架,用于实现数据库...
这种方法通常分为分库(Database Sharding)和分表(Table Sharding)两种方式: 1. **分库**:即将一个大数据库拆分成多个小数据库,每个数据库负责一部分数据的存储和管理。这可以有效缓解单个数据库的压力,避免...
数据库切分(Database Sharding)作为一种重要的技术手段,被广泛应用于大数据量场景下,其目的是通过将一个大型数据库分割成多个较小的部分来提高系统的可扩展性和性能。 **数据库切分**主要是指将一个大的数据库...
1. **分库(Database Sharding)**:将一个大数据库拆分成多个小数据库,每个数据库负责一部分业务数据。这样可以降低单一数据库的压力,提高读写性能,同时有利于实现高可用性和灾难恢复。 2. **分表(Table ...
2. **数据库分片(Database Sharding)** 面对大数据和高并发的挑战,Oracle引入了分片技术,通过将数据分布在多个独立的数据库实例上,实现了水平扩展,确保了大规模业务场景下的高性能和高可用性。 3. **内存...
Oracle Sharding是一种架构,它是Oracle Database 12c Release 2(版本12.2)中的一种特性,专门为在线事务处理(OLTP)应用程序设计。在Sharding架构中,数据被水平地分布在多个独立的Oracle数据库中,这些独立的...
- **Database Optimization:** Techniques like indexing, query optimization, and database sharding can enhance the scalability of a Django application. #### 9. GIS (Jeremy Dunck) **Introduction:** ...
- **数据库路由(Database Sharding)**:根据特定规则(如用户ID或地理区域)将数据分散到多个数据库。 - **读写分离**:主数据库负责写操作,从数据库处理读请求,减少主库压力。 - **数据复制**:数据在多个...
"database-sharding"项目是Google Code上一个已迁移的开源项目,专注于提供数据库分片的解决方案。尽管描述中提到这只是测试,但我们可以深入探讨数据库分片这一主题,以及它在Java环境中的实现。 数据库分片是一种...
- **Database Sharding:** 数据分片,用于水平扩展数据库。 - **JSON Support:** 对JSON数据的支持,便于处理半结构化数据。 以上内容涵盖了Oracle面试中可能遇到的一些重要知识点和技术细节,希望能帮助您更好地...
Sharding-JDBC是阿里巴巴开源的一款轻量级的Java框架,用于实现数据库的水平拆分,它是基于JDBC的中间件,可以在不修改业务代码的情况下,透明地实现数据分片和读写分离。 1. 数据库分库分表概念: 分库是指将一个...
在Go-PG-Sharding项目中,Go语言的并发特性使得处理多个数据库分片变得轻而易举,同时其标准库中的net/http和database/sql等模块为实现高效的数据库操作提供了便利。 PostgreSQL,又名PG,是一款强大的开源对象关系...
Database sharding —— Design a distributed cache framework like Redis —— Design a CDN - Design a service like TinyURL 一般 IT 相关主题 What is Docker and why use it ? VM vs Docker What is Docker ...