分表,集群任务总结
1.分表对Mysql主从的影响
场景:esfpicture数据库已建好,并且已分表,历史数据已插入到对应的分表,现在需要插入增量数据;
在esfpicture数据库,分表esfpicture0-esfpicture99都会放在esfpicture数据库.这个数据库默认是没有做主从同步的,如果在执行如果下的sql,会导致主从数据同步出现中断,因为从数据库也会执行这样一条sql,但是从执行会出错;
INSERT INTO esfpicture0 SELECT * FROM public.`esfpicture` WHERE hid%100=0;
2.在应用分表实体bean反射时,注意”serialVersionUID”
实体bean的第一个字段都是serialVersionUID”,在应用反射获取到Field集合时,需要过滤掉第一个字段;并且第二个字段必须为主键;
3.应用的接口注入
Spring版本需使用3.x版本,并且接口需添加cache参数,配置如下:
<beanid="esfpictureManager" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiTemplate">
<ref bean="shardJndiTemplate" />
</property>
<property name="jndiName" value="esfpictureManager/remote" />
<property name="cache" value="false"></property>
</bean>
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
java.lang.RuntimeException: cluster invocation failed, last exception was:
org.jboss.aspects.remoting.ClusterChooserInterceptor.invoke(ClusterChooserInterceptor.java:166)
org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
4.部分接口的修改没有到位。有的查询可以走分表查询,有的需要修改调用的业务。
5.ejb 实体bean注解需要添加库名
@Table(name = "esfpicture.esfpicture")