- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个使用 spring (4.2.9.RELEASE)、hibernate (5.1.3.Final) 和 mysql 复制驱动程序的 Web 应用程序,在 Tomcat 上运行。所有查询都将发送到主服务器,而不会发送到副本。这是我在上下文中的资源:
<Resource auth="Container"
driverClassName="com.mysql.jdbc.ReplicationDriver"
defaultAutoCommit="false"
initialSize="3"
logAbandoned="false"
maxActive="200"
maxIdle="5"
maxWait="10000"
name="jdbc/powerptc"
removeAbandoned="true"
testOnBorrow="true"
type="javax.sql.DataSource"
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
username="xxxxxxx"
password="xxxxxx"
url="jdbc:mysql:replication://localhost:3306,slave.test.net:3306/powerptc?autoReconnect=true&allowSlavesDownConnections=true&readFromMasterWhenNoSlaves=true"
validationQuery="SELECT 1"/>
在我的服务层中,我的只读方法设置如下...
@Override
@Transactional(readOnly = true)
public List<Location> getAll(long customerId) {
return dao.getAll(customerId);
}
当调用此方法(作为入口点)时,我所有的查询都会转到主服务器而不是从服务器。
我一直在寻找这个问题的答案,我认为问题是 hibernate 没有将底层连接设置为只读,因此复制驱动程序将所有查询发送到主服务器。所以我的问题是,spring/hibernate 应该将连接设置为 readOnly 还是我需要使用 AOP 或类似方法来执行此操作?似乎有些帖子说它应该将连接设置为只读,而其他人则说不应该。有人可以为我澄清一下,这样我就有希望解决我的问题。提前致谢!
最佳答案
事实证明,当您直接使用 JPA 时,一切都能完美运行。该应用程序仍在使用 Hibernate 的 SessionFactory,因此当我将所有内容切换到 EntityManager 时,一切正常,无需 AOP 拦截连接获取。我刚刚用 @Transactional(readOnly = true) 标记了我的服务层,一切正常。
关于java - 带有 com.mysql.jdbc.ReplicationDriver 的 MySql Master/Slave Spring Hibernate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44135920/
我想知道一个服务器是否可以同时是slave和master。我们的问题是我们有很多移动单元需要同步到主服务器,但它们只需要主服务器上 100 个表中的 6 个。除了延迟同步和增加数据成本之外,所有额外的
此站点上的许多帖子(例如 this、this 或 this)讨论了如何检测 Android 上丢失的蓝牙连接。本质上,一个人可以注册 Action 的广播 BluetoothAdapter.ACTIO
我有主从复制,我们有很多记录插入主服务器,以至于从服务器更新速度不够快。我们有 innodb,也许 slave 上的复制是单线程的。我想知道我们是否可以在数据库方面做些什么,而不是在编码或表结构等方面
正如标题所说,“从机启动”和“从机启动”有什么区别?当我接受DBA面试时,他问了这个问题,我搜索了google但没有找到答案,有人知道吗? 最佳答案 没有区别.. Slave start; 已弃用,现
我在设置主从配置时遇到困难。 Master Database 在 Ubuntu(亚马逊 AWS 实例)上运行并成功设置主复制。 我有本地主机作为从属服务器。 (Windows 机器)。 主数据库快照
我的权限被拒绝,但不知道为什么。从我的 Jenkins 大师那里,我能够使用 ssh-rsa-key 运行以下命令 scp /var/cache/jenkins/war/WEB-INF/slave.j
我计划在一台主服务器和几台从服务器上使用 MySQL 设置服务器。我会在其中一个从服务器上定期执行数据 EBS 的一致备份服务器(我总是会先停止数据库,然后在完成后重新启动它)。 从站故障转移 如果其
如果我使用 —expect-slaves 3 运行 headless Locust master,如果我连接 5 个 slave,master 会接受并使用所有连接的 slave 吗? 最佳答案 答案
当在有从属的从属的环境中使用 Redis 的复制功能时,connected_slaves 计数器是否会增加主控、充当主控的从属或两者?引用示例图:https://imgur.com/Ge1WLzX 在
我想配置slave以启用写入(slave-read-only no)。用例是启用临时缓存。 但是,文档中的这段让我担心: Normally slave nodes will redirect clie
我想设置一个 Linux 节点作为 Jenkins 主节点的从属节点。我正在浏览 the tutorial为 Linux 机器设置它。 Have master launch slave agent v
我现有的 jenkins 主从连接断开了。我尝试通过 scp 命令建立连接。 关于主人: scp ~/ .ssh/id_rsa.pub jenkins@:/tmp 在奴隶上: • ssh-keyg
所以我从从属虚拟机列表中删除了 vm4,当我运行以下命令时它不会访问它 hdfs dfsadmin -report 结果是: ubuntu@anmol-vm1-new:~$ hdfs dfsadmin
一.安装环境 这里也顺便记录一下如何在windows7上卸载解压版MySQL5.6数据库,如果无需卸载请忽略下一步,直接看第三步即可 二.windows7卸载解压版MySQL5.6 1.使
我已按照有关如何设置 Redis 主服务器集群的说明进行操作,但完成后我无法看到为什么服务器无法相互看到。这是我组装的第二个版本,我被困在同一个地方。我真的可以使用一些以前从未在 REDIS 上工作过
我有一个本地 Jenkins 服务器,我已经设置并为其创建了作业。我正在尝试注册新的 slave/build 机器,但 Jenkins 拒绝提供 slave.jar 或 slave-agent.jnl
我正在尝试在大型 redis 队列中使用哨兵进行故障转移(12 个哨兵,500 多个分片,每个分片一个主站和一个从站)。我遇到了一个非常奇怪的问题,我的哨兵反复向某些 redis 节点发出命令 +fi
我如何配置jenkins master slavemaster在linux上,slave在windows上我需要通过master在slave上执行一个文件我对 Jenkins 不太了解,所以我需要完整
如何将系统配置为有一个主多从,用 gmake 构建普通的 c 代码?从站如何从主站访问工作区?我想 NFS 共享是可行的,但如果这是不可能的任何 其他 选项? http://wiki.hudson-c
有没有人尝试过使用 Jenkins Rest/API 或任何其他方式在 Jenkins slave 的配置中添加或更新环境变量的方法。 使用 Jenkins Swarm 插件,我创建了一个从站(它使用
我是一名优秀的程序员,十分优秀!