AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

    • 主页
    • 系统&网络
    • Ubuntu
    • Unix
    • DBA
    • Computer
    • Coding
    • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / dba / 问题

问题[replication](dba)

Martin Hope
KMT
Asked: 2025-03-15 12:14:06 +0800 CST

MariaDB v10.11 与 v10.1 复制性能

  • 7

我们正在将 MariaDB 10.1 主从网络升级到 MariaDB 10.11。我们分两个阶段进行 - 将所有从属服务器升级到 v10.11,然后在以后引入使用 v10.11 的新主服务器。

应用程序与新版本完全兼容,没有任何问题。我在同一网络中设置了新的生产从属服务器 (v10.11),使用与生产相同的 Linode 实例类型 (50 vcpu、128GB RAM)。数据库大小约为 500GB。

新的 v10.11 实例与其他 v10.1 从属实例具有相同的 InnoDB 配置设置。所有实例的 innodb_buffer_pool_size=100G。启动复制时,这些实例中的滞后不断增加。我注意到这些实例的 CPU 使用率低于 50%,每秒查询数低于 4k。当旧版本 (v10.1) 通常存在滞后时,其 CPU 使用率通常高于 120%,每秒查询数高于 15k,几分钟后就会赶上主版本。

v10.11 中的 seconds_behind_master 几乎变成了 3-4 天。在一个新的从属服务器中,我增加了 slave_parallel_thread=12,情况有所改善。它的 CPU 达到约 300%,每秒查询平均约为 20k。但另一个 v10.11 的 slave_parallel_therads=0 仍比主服务器落后几天。它没有充分利用 CPU - 只有 40-50% 的 CPU。每秒查询数低于 4k。MariaDB v10.1 从属服务器以 slave_parallel_threads=0 运行,我从未遇到过这么长的延迟。就像我说的,延迟通常会在几分钟内稳定下来。

我一直尝试调整一些设置,重新启动一些从属设备,重建从属设备,但都没有任何效果。

一些问题/疑虑 -

  1. 为什么 MariaDB 10.1 在复制方面表现优于新版 MariaDB 10.11。v10.1 - 未启用 slave_parallel_threads
  2. 新版 v10.11 中的 CPU 利用率比 v10.1 低得多,每秒查询数更高

有人经历过这种情况吗?

所有从属设备(v10.1 和 v10.11)均具有以下设置 -

wait_timeout = 60
interactive_timeout = 60

max_connections = 1000

innodb_buffer_pool_size = 100G
max_allowed_packet = 1G

innodb_strict_mode=OFF
sql_mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

innodb_data_file_path=ibdata1:500M:autoextend

read_rnd_buffer_size = 256M
sort_buffer_size = 256M
join_buffer_size = 256M

tmp_table_size= 1536M
max_heap_table_size= 1536M

skip_slave_start
slave-type-conversions=ALL_NON_LOSSY

read_buffer_size = 20M
#innodb_additional_mem_pool_size = 256M

innodb_log_file_size = 1G
innodb_buffer_pool_instances = 40
skip_name_resolve = 1

tmp_table_size= 1536M
max_heap_table_size= 1536M

server_id=114
#slave-type-conversions=ALL_NON_LOSSY

max_connect_errors = 1000000
log_warnings = 2

####
read_buffer_size = 20M
#innodb_additional_mem_pool_size = 256M

query_cache_type=0

设置图

replication
  • 1 个回答
  • 45 Views
Martin Hope
Areeb
Asked: 2024-11-14 19:37:55 +0800 CST

副本未启动

  • 4

我正在尝试设置主从副本。这是为了在接下来的几天内从第一个节点到第二个节点进行无停机迁移。

主节点已设置完毕,配置已更新,我添加了密钥文件。对辅助节点执行了相同操作。

我还初始化了复制,并将辅助节点添加到复制中。我可以看到 ping 和正常运行时间,但辅助节点卡在“启动”状态。

但是,辅助节点上没有副本配置。此外,它一遍又一遍地在错误日志中重复此操作。

辅助节点(日志):

{"t":{"$date":"2024-11-14T11:35:14.018+00:00"},"s":"I",  "c":"CONNPOOL", "id":22576,   "ctx":"ReplNetwork","msg":"Connecting","attr":{"hostAndPort":"Ubuntu-2204-jammy-amd64-base:27017"}}
{"t":{"$date":"2024-11-14T11:35:14.818+00:00"},"s":"W",  "c":"SHARDING", "id":7012500, "ctx":"QueryAnalysisConfigurationsRefresher","msg":"Failed to refresh query analysis configurations, will try again at the next interval","attr":{"error":"PrimarySteppedDown: No primary exists currently"}}
{"t":{"$date":"2024-11-14T11:35:15.000+00:00"},"s":"W",  "c":"QUERY",    "id":23799,   "ctx":"ftdc","msg":"Aggregate command executor error","attr":{"error":{"code":26,"codeName":"NamespaceNotFound","errmsg":"Unable to retrieve storageStats in $collStats stage :: caused by :: Collection [local.oplog.rs] not found."},"stats":{},"cmd":{"aggregate":"oplog.rs","cursor":{},"pipeline":[{"$collStats":{"storageStats":{"waitForLock":false,"numericOnly":true}}}],"$db":"local"}}}
{"t":{"$date":"2024-11-14T11:35:15.000+00:00"},"s":"W",  "c":"QUERY",    "id":23799,   "ctx":"ftdc","msg":"Aggregate command executor error","attr":{"error":{"code":26,"codeName":"NamespaceNotFound","errmsg":"Unable to retrieve storageStats in $collStats stage :: caused by :: Collection [config.transactions] not found."},"stats":{},"cmd":{"aggregate":"transactions","cursor":{},"pipeline":[{"$collStats":{"storageStats":{"waitForLock":false,"numericOnly":true}}}],"$db":"config"}}}
{"t":{"$date":"2024-11-14T11:35:15.001+00:00"},"s":"W",  "c":"QUERY",    "id":23799,   "ctx":"ftdc","msg":"Aggregate command executor error","attr":{"error":{"code":26,"codeName":"NamespaceNotFound","errmsg":"Unable to retrieve storageStats in $collStats stage :: caused by :: Collection [config.image_collection] not found."},"stats":{},"cmd":{"aggregate":"image_collection","cursor":{},"pipeline":[{"$collStats":{"storageStats":{"waitForLock":false,"numericOnly":true}}}],"$db":"config"}}}
{"t":{"$date":"2024-11-14T11:35:15.018+00:00"},"s":"I",  "c":"CONNPOOL", "id":22576,   "ctx":"ReplNetwork","msg":"Connecting","attr":{"hostAndPort":"Ubuntu-2204-jammy-amd64-base:27017"}}
{"t":{"$date":"2024-11-14T11:35:16.000+00:00"},"s":"W",  "c":"QUERY",    "id":23799,   "ctx":"ftdc","msg":"Aggregate command executor error","attr":{"error":{"code":26,"codeName":"NamespaceNotFound","errmsg":"Unable to retrieve storageStats in $collStats stage :: caused by :: Collection [local.oplog.rs] not found."},"stats":{},"cmd":{"aggregate":"oplog.rs","cursor":{},"pipeline":[{"$collStats":{"storageStats":{"waitForLock":false,"numericOnly":true}}}],"$db":"local"}}}
{"t":{"$date":"2024-11-14T11:35:16.000+00:00"},"s":"W",  "c":"QUERY",    "id":23799,   "ctx":"ftdc","msg":"Aggregate command executor error","attr":{"error":{"code":26,"codeName":"NamespaceNotFound","errmsg":"Unable to retrieve storageStats in $collStats stage :: caused by :: Collection [config.transactions] not found."},"stats":{},"cmd":{"aggregate":"transactions","cursor":{},"pipeline":[{"$collStats":{"storageStats":{"waitForLock":false,"numericOnly":true}}}],"$db":"config"}}}
{"t":{"$date":"2024-11-14T11:35:16.001+00:00"},"s":"W",  "c":"QUERY",    "id":23799,   "ctx":"ftdc","msg":"Aggregate command executor error","attr":{"error":{"code":26,"codeName":"NamespaceNotFound","errmsg":"Unable to retrieve storageStats in $collStats stage :: caused by :: Collection [config.image_collection] not found."},"stats":{},"cmd":{"aggregate":"image_collection","cursor":{},"pipeline":[{"$collStats":{"storageStats":{"waitForLock":false,"numericOnly":true}}}],"$db":"config"}}}
{"t":{"$date":"2024-11-14T11:35:16.018+00:00"},"s":"I",  "c":"CONNPOOL", "id":22576,   "ctx":"ReplNetwork","msg":"Connecting","attr":{"hostAndPort":"Ubuntu-2204-jammy-amd64-base:27017"}}

主服务器上的 rs.config()

{
  set: 'rs0',
  date: ISODate('2024-11-14T11:36:01.498Z'),
  myState: 1,
  term: Long('3'),
  syncSourceHost: '',
  syncSourceId: -1,
  heartbeatIntervalMillis: Long('2000'),
  majorityVoteCount: 1,
  writeMajorityCount: 1,
  votingMembersCount: 1,
  writableVotingMembersCount: 1,
  optimes: {
    lastCommittedOpTime: { ts: Timestamp({ t: 1731584161, i: 5 }), t: Long('3') },
    lastCommittedWallTime: ISODate('2024-11-14T11:36:01.474Z'),
    readConcernMajorityOpTime: { ts: Timestamp({ t: 1731584161, i: 5 }), t: Long('3') },
    appliedOpTime: { ts: Timestamp({ t: 1731584161, i: 5 }), t: Long('3') },
    durableOpTime: { ts: Timestamp({ t: 1731584161, i: 5 }), t: Long('3') },
    writtenOpTime: { ts: Timestamp({ t: 1731584161, i: 5 }), t: Long('3') },
    lastAppliedWallTime: ISODate('2024-11-14T11:36:01.474Z'),
    lastDurableWallTime: ISODate('2024-11-14T11:36:01.474Z'),
    lastWrittenWallTime: ISODate('2024-11-14T11:36:01.474Z')
  },
  lastStableRecoveryTimestamp: Timestamp({ t: 1731584157, i: 2 }),
  electionCandidateMetrics: {
    lastElectionReason: 'electionTimeout',
    lastElectionDate: ISODate('2024-11-14T09:11:55.719Z'),
    electionTerm: Long('3'),
    lastCommittedOpTimeAtElection: { ts: Timestamp({ t: 0, i: 0 }), t: Long('-1') },
    lastSeenWrittenOpTimeAtElection: { ts: Timestamp({ t: 1731575489, i: 10 }), t: Long('2') },
    lastSeenOpTimeAtElection: { ts: Timestamp({ t: 1731575489, i: 10 }), t: Long('2') },
    numVotesNeeded: 1,
    priorityAtElection: 1,
    electionTimeoutMillis: Long('10000'),
    numCatchUpOps: Long('0'),
    newTermStartDate: ISODate('2024-11-14T09:11:55.790Z'),
    wMajorityWriteAvailabilityDate: ISODate('2024-11-14T09:11:55.803Z')
  },
  members: [
    {
      _id: 0,
      name: 'Ubuntu-2204-jammy-amd64-base:27017',
      health: 1,
      state: 1,
      stateStr: 'PRIMARY',
      uptime: 8656,
      optime: { ts: Timestamp({ t: 1731584161, i: 5 }), t: Long('3') },
      optimeDate: ISODate('2024-11-14T11:36:01.000Z'),
      optimeWritten: { ts: Timestamp({ t: 1731584161, i: 5 }), t: Long('3') },
      optimeWrittenDate: ISODate('2024-11-14T11:36:01.000Z'),
      lastAppliedWallTime: ISODate('2024-11-14T11:36:01.474Z'),
      lastDurableWallTime: ISODate('2024-11-14T11:36:01.474Z'),
      lastWrittenWallTime: ISODate('2024-11-14T11:36:01.474Z'),
      syncSourceHost: '',
      syncSourceId: -1,
      infoMessage: '',
      electionTime: Timestamp({ t: 1731575515, i: 1 }),
      electionDate: ISODate('2024-11-14T09:11:55.000Z'),
      configVersion: 10,
      configTerm: 3,
      self: true,
      lastHeartbeatMessage: ''
    },
    {
      _id: 1,
      name: 'XXXXXXXXXXXXXXX:27017',
      health: 1,
      state: 0,
      stateStr: 'STARTUP',
      uptime: 1925,
      optime: { ts: Timestamp({ t: 0, i: 0 }), t: Long('-1') },
      optimeDurable: { ts: Timestamp({ t: 0, i: 0 }), t: Long('-1') },
      optimeWritten: { ts: Timestamp({ t: 0, i: 0 }), t: Long('-1') },
      optimeDate: ISODate('1970-01-01T00:00:00.000Z'),
      optimeDurableDate: ISODate('1970-01-01T00:00:00.000Z'),
      optimeWrittenDate: ISODate('1970-01-01T00:00:00.000Z'),
      lastAppliedWallTime: ISODate('1970-01-01T00:00:00.000Z'),
      lastDurableWallTime: ISODate('1970-01-01T00:00:00.000Z'),
      lastWrittenWallTime: ISODate('1970-01-01T00:00:00.000Z'),
      lastHeartbeat: ISODate('2024-11-14T11:36:00.038Z'),
      lastHeartbeatRecv: ISODate('1970-01-01T00:00:00.000Z'),
      pingMs: Long('9'),
      lastHeartbeatMessage: '',
      syncSourceHost: '',
      syncSourceId: -1,
      infoMessage: '',
      configVersion: -2,
      configTerm: -1
    }
  ],
  ok: 1,
  '$clusterTime': {
    clusterTime: Timestamp({ t: 1731584161, i: 5 }),
    signature: {
      hash: Binary.createFromBase64('XXXXXXXXXX', 0),
      keyId: Long('XXXXXXXXXXXX')
    }
  },
  operationTime: Timestamp({ t: 1731584161, i: 5 })
}

辅助服务器上的 rs.config()

MongoServerError[NotYetInitialized]: no replset config has been received  
replication
  • 1 个回答
  • 15 Views
Martin Hope
Danish Ahamed
Asked: 2024-08-20 15:18:11 +0800 CST

对于 pitr 恢复和逻辑复制,wal_level 是否可以设置为 logical ?

  • 5

我的数据库集群目前使用逻辑复制,并将 wal_level 设置为 logical。如何在不更改 wal_level 的情况下将时间点恢复 (PITR) 集成到此设置中?如果可能的话,我还想知道这种方法的任何潜在缺点。

replication
  • 1 个回答
  • 10 Views
Martin Hope
Yossi Geretz
Asked: 2024-05-15 03:47:53 +0800 CST

为什么我无法为主数据库创建超过 1 个地理副本?

  • 6

我有一个高级服务级别的主数据库。

在此输入图像描述

我正在尝试为不同的区域创建第二个地理副本。主要副本位于东海岸,第一个副本位于中南部,现在我正在尝试在 West 2 创建第二个副本。

文献指出,我可以为单个主节点创建最多四个副本。(我已经看到提到这需要高级服务级别的事实,因此我已将数据库提升到高级级别。)

https://learn.microsoft.com/en-us/azure/azure-sql/database/active-geo-replication-overview?view=azuresql#configuring-secondary-database

最多可以为主节点创建四个地理辅助节点。如果只有一个辅助节点并且发生故障,则应用程序将面临更高的风险,直到创建新的辅助节点。如果存在多个辅助节点,即使其中一个辅助节点发生故障,应用程序仍将受到保护。额外的辅助节点也可用于横向扩展只读工作负载。

我已经创建了第一个副本,现在我正在尝试在不同的区域创建第二个副本。我一直收到同样的错误:

已达到复制限制。数据库“test”不能有超过 1 个复制关系。(代码:GeoReplicaLimitReached)

不能有多个复制关系吗?但文献说我最多应该有四个?

这是数据库配置的更完整快照。

在此输入图像描述

谢谢你的建议!

replication
  • 1 个回答
  • 17 Views
Martin Hope
Yossi Geretz
Asked: 2024-04-13 03:10:45 +0800 CST

我在将数据库用户从一个 Azure SQL Server 复制到另一个 Azure SQL Server 时遇到问题。EXECUTE 权限被拒绝

  • 5

我正在尝试使用此处的说明 -

https://learn.microsoft.com/en-US/troubleshoot/sql/database-engine/security/transfer-logins-passwords- Between-instances

在托管我的主数据库的服务器和托管我的只读副本的服务器之间复制登录名。这对我来说很重要,因为我希望当前正在查询生产数据库的所有用户开始查询只读副本。

我能够在主服务器上的 master 数据库中创建存储过程,但是当我尝试按照说明执行存储过程时,我收到以下错误:

执行 sp_help_revlogin

消息 229,级别 14,状态 5,过程 sp_help_revlogin,第 1 行 [批处理起始行 0] 对对象“sp_help_revlogin”、数据库“master”、架构“dbo”的 EXECUTE 权限被拒绝。

在此输入图像描述

我该如何克服这个问题?

我正在使用 Azure 的托管 SQL 数据库,并以管理员身份登录服务器(使用定义为 Microsoft Entra 管理员的帐户)。

谢谢你的建议!

replication
  • 1 个回答
  • 11 Views
Martin Hope
Yossi Geretz
Asked: 2024-04-12 06:51:29 +0800 CST

我可以在不同的服务器上使用不同的名称创建主 Azure SQL Server 数据库的只读副本吗?

  • 6

我在美国东部数据中心的 Azure 托管 SQL Server 上有一个名为myAppDB的数据库。我在美国中南部数据中心创建了一个新的 SQL Server。然后,我在美国东部的服务器上创建了myAppDB的地理副本到美国中南部的服务器。有效!我已经验证新数据库实际上是从 SSMS 读取的,并且随着主数据库通过正在进行的事务更新而传输数据。

问题是,创建副本的 Azure 界面不允许指定副本的数据库名称。

在此输入图像描述

所以现在我在两台不同的服务器上有两个不同的数据库,它们都具有相同的名称 - myAppDB。从物理上讲,这是可行的,但就可用性而言,如果我在具有两个数据库服务器连接的 SSMS 中工作,则会令人困惑,因为无论我访问哪个数据库,SSMS 都会报告myAppDB。我更愿意将副本命名为myAppDB_Read之类的名称,以便让我的工作环境更加清晰。有什么办法可以实现这一点吗?(我已经尝试过重命名数据库的标准方法,但收到一条错误消息,指出该操作无法执行,因为数据库处于复制关系中。)

谢谢你的建议!

replication
  • 1 个回答
  • 14 Views
Martin Hope
Furkan YIlmaZ
Asked: 2024-04-01 16:56:25 +0800 CST

分片集群 - 为什么我的数据没有在节点之间拆分?

  • 5

我创建了一个包含两个分片的集群。或者说我是这么想的。在我的设计中,第一台服务器有 mongos_router shard1 (3 个节点)和配置服务器。第二台服务器只有分片 2 个节点。配置分片后,我为每个数据库启用了分片。当我查看 sh.status() 的输出时,我看到以下输出:

...
  {
    database: {
      _id: 'wins_emission',
      primary: 'shard1rs',
      partitioned: false,
      version: {
        uuid: UUID('aebf94cf-6069-41ba-9a91-f91a944071b1'),
        timestamp: Timestamp({ t: 1711952615, i: 3000 }),
        lastMod: 1
      }
    },
    collections: {}
  },
  {
    database: {
      _id: 'wins_healthcheck',
      primary: 'shard2rs',
      partitioned: false,
      version: {
        uuid: UUID('663cb5f7-b7b3-4f40-9f52-2c3d1969fb65'),
        timestamp: Timestamp({ t: 1711952305, i: 4 }),
        lastMod: 1
      }
    },
...

我理解这是因为数据库将分布在分片之间。我预计节点之间的数据不会相同。例如,通知表有 17.7k 个文档。我希望这些文档能够在节点之间共享。就像 shard1-first 节点有 4k 一样,shard1-second 节点有 4k 等等。但它不是这样工作的。每个分片中的每个节点都有相同数量的 17.7k 。我可能会误解这一点。

我尝试在通知表的集合级别进行分片。我创建了一个散列分片键。然后执行sh.shardCollection()命令。现在,我的第一个分片在其自己的节点中有 4.7k 个文档,而 shard2 本身有 12.9k 个文档。现在这让我想到了这些问题。

  1. 我是否需要对每个集合进行分片才能使用分片集群?
  2. 我应该对每个集合进行分片,还是只对那些保存日志等大数据的集合进行分片?
  3. 为什么一个分片中的所有节点都有相同数量的文档。他们不应该自行分发数据吗?

任何帮助表示赞赏。

编辑1:特定集合的getShardDistribution的输出;

{
  data: '382.25MiB',
  docs: 7006,
  chunks: 3,
  'estimated data per chunk': '127.41MiB',
  'estimated docs per chunk': 2335
}
---
Shard shard2rs at shard2rs/172.16.114.129:27020,172.16.114.129:27021,172.16.114.129:27022
{
  data: '579.78MiB',
  docs: 10578,
  chunks: 1,
  'estimated data per chunk': '579.78MiB',
  'estimated docs per chunk': 10578
}
---
Totals
{
  data: '962.03MiB',
  docs: 17584,
  chunks: 4,
  'Shard shard1rs': [
    '39.73 % data',
    '39.84 % docs in cluster',
    '55KiB avg obj size on shard'
  ],
  'Shard shard2rs': [
    '60.26 % data',
    '60.15 % docs in cluster',
    '56KiB avg obj size on shard'
  ]
}


replication
  • 1 个回答
  • 27 Views
Martin Hope
Andrei Hristov
Asked: 2024-01-24 16:38:14 +0800 CST

MySQL 复制状态不报告 mysqld.cnf 参数

  • 5

我正在运行从 3 个主服务器到 1 个从服务器的多主复制。每个主服务器都有 2 个数据库,但我只复制其中 1 个数据库。

服务器版本:8.0.35-0ubuntu0.20.04.1(Ubuntu)

复制工作正常,但我的问题是,为什么当我运行

show replica status \G

我在状态报告中没有看到为每个通道的Replicate_Do_DB或replicate-wild-do-table设置的参数。如果我将它们设置为全局变量(不指定通道),它们会出现在报告中,但在每个通道设置时不会出现,知道为什么吗?

这是从 MySQL 配置文件 ( /etc/mysql/mysql.conf.d/mysqld.cnf ) 中摘录的内容:

master-info-repository=table
relay-log-info-repository=table

replicate-wild-do-table='src3_s#####':s#####v.%
replicate-wild-do-table='src2_b#####':b#####v.%
replicate-wild-do-table='src1_d#####':d#####v.%

这是“显示复制状态\G”的结果:

mysql> show replica status \G
*************************** 1. row ***************************
             Replica_IO_State: Waiting for source to send event
                  Source_Host: 101.114.110.113
                  Source_User: slave_user
                  Source_Port: 3306
                Connect_Retry: 60
              Source_Log_File: mysql###-bin.001307
          Read_Source_Log_Pos: 85496
               Relay_Log_File: plfamily-replication-slave-relay-bin-src1_#####.000086
                Relay_Log_Pos: 323
        Relay_Source_Log_File: mysql###-bin.001307
           Replica_IO_Running: Yes
          Replica_SQL_Running: Yes
              Replicate_Do_DB:
          Replicate_Ignore_DB: 
           Replicate_Do_Table:
       Replicate_Ignore_Table:
      Replicate_Wild_Do_Table:
  Replicate_Wild_Ignore_Table:
                   Last_Errno: 0
                   Last_Error:
                 Skip_Counter: 0
          Exec_Source_Log_Pos: 85496
              Relay_Log_Space: 86304
              Until_Condition: None
               Until_Log_File:
                Until_Log_Pos: 0
           Source_SSL_Allowed: No
           Source_SSL_CA_File:
           Source_SSL_CA_Path:
              Source_SSL_Cert:
            Source_SSL_Cipher:
               Source_SSL_Key:
        Seconds_Behind_Source: 0
Source_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error:
               Last_SQL_Errno: 0
               Last_SQL_Error:
  Replicate_Ignore_Server_Ids:
             Source_Server_Id: 1
                  Source_UUID: a604d2af-ed30-11ea-a99d-8657a156e939
             Source_Info_File: mysql.slave_master_info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
    Replica_SQL_Running_State: Replica has read all relay log; waiting for more updates
           Source_Retry_Count: 86400
                  Source_Bind:
      Last_IO_Error_Timestamp:
     Last_SQL_Error_Timestamp:
               Source_SSL_Crl:
           Source_SSL_Crlpath:
           Retrieved_Gtid_Set:
            Executed_Gtid_Set:
                Auto_Position: 0
         Replicate_Rewrite_DB:
                 Channel_Name: src1_d######
           Source_TLS_Version:
       Source_public_key_path:
        Get_Source_public_key: 0
            Network_Namespace:
*************************** 2. row ***************************
             Replica_IO_State: Waiting for source to send event
                  Source_Host: 237.239.251.262
                  Source_User: slave_user
                  Source_Port: 3306
                Connect_Retry: 60
              Source_Log_File: mysql###-bin.000002
          Read_Source_Log_Pos: 45872
               Relay_Log_File: plfamily-replication-slave-relay-bin-src2_#####.000029
                Relay_Log_Pos: 326
        Relay_Source_Log_File: mysql###-bin.000002
           Replica_IO_Running: Yes
          Replica_SQL_Running: Yes
              Replicate_Do_DB:
          Replicate_Ignore_DB: 
           Replicate_Do_Table:
       Replicate_Ignore_Table:
      Replicate_Wild_Do_Table:
  Replicate_Wild_Ignore_Table:
                   Last_Errno: 0
                   Last_Error:
                 Skip_Counter: 0
          Exec_Source_Log_Pos: 45872
              Relay_Log_Space: 921
              Until_Condition: None
               Until_Log_File:
                Until_Log_Pos: 0
           Source_SSL_Allowed: No
           Source_SSL_CA_File:
           Source_SSL_CA_Path:
              Source_SSL_Cert:
            Source_SSL_Cipher:
               Source_SSL_Key:
        Seconds_Behind_Source: 0
Source_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error:
               Last_SQL_Errno: 0
               Last_SQL_Error:
  Replicate_Ignore_Server_Ids:
             Source_Server_Id: 3
                  Source_UUID: ab801adf-ddb3-11eb-96b2-a27c967973a1
             Source_Info_File: mysql.slave_master_info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
    Replica_SQL_Running_State: Replica has read all relay log; waiting for more updates
           Source_Retry_Count: 86400
                  Source_Bind:
      Last_IO_Error_Timestamp:
     Last_SQL_Error_Timestamp:
               Source_SSL_Crl:
           Source_SSL_Crlpath:
           Retrieved_Gtid_Set:
            Executed_Gtid_Set:
                Auto_Position: 0
         Replicate_Rewrite_DB:
                 Channel_Name: src2_b#####
           Source_TLS_Version:
       Source_public_key_path:
        Get_Source_public_key: 0
            Network_Namespace:
*************************** 3. row ***************************
             Replica_IO_State: Waiting for source to send event
                  Source_Host: 134.148.228.213
                  Source_User: slave_user
                  Source_Port: 3306
                Connect_Retry: 60
              Source_Log_File: mysql####-bin.000002
          Read_Source_Log_Pos: 47931
               Relay_Log_File: plfamily-replication-slave-relay-bin-src3_s####.000025
                Relay_Log_Pos: 328
        Relay_Source_Log_File: mysql####-bin.000002
           Replica_IO_Running: Yes
          Replica_SQL_Running: Yes
              Replicate_Do_DB:
          Replicate_Ignore_DB: 
           Replicate_Do_Table:
       Replicate_Ignore_Table:
      Replicate_Wild_Do_Table:
  Replicate_Wild_Ignore_Table:
                   Last_Errno: 0
                   Last_Error:
                 Skip_Counter: 0
          Exec_Source_Log_Pos: 47931
              Relay_Log_Space: 925
              Until_Condition: None
               Until_Log_File:
                Until_Log_Pos: 0
           Source_SSL_Allowed: No
           Source_SSL_CA_File:
           Source_SSL_CA_Path:
              Source_SSL_Cert:
            Source_SSL_Cipher:
               Source_SSL_Key:
        Seconds_Behind_Source: 0
Source_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error:
               Last_SQL_Errno: 0
               Last_SQL_Error:
  Replicate_Ignore_Server_Ids:
             Source_Server_Id: 4
                  Source_UUID: ab801adf-ddb3-11eb-96b2-a27c967973a1
             Source_Info_File: mysql.slave_master_info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
    Replica_SQL_Running_State: Replica has read all relay log; waiting for more updates
           Source_Retry_Count: 86400
                  Source_Bind:
      Last_IO_Error_Timestamp:
     Last_SQL_Error_Timestamp:
               Source_SSL_Crl:
           Source_SSL_Crlpath:
           Retrieved_Gtid_Set:
            Executed_Gtid_Set:
                Auto_Position: 0
         Replicate_Rewrite_DB:
                 Channel_Name: src3_s######
           Source_TLS_Version:
       Source_public_key_path:
        Get_Source_public_key: 0
            Network_Namespace:
3 rows in set (0.00 sec)


replication
  • 1 个回答
  • 8 Views
Martin Hope
Kevin Meredith
Asked: 2023-12-16 22:19:51 +0800 CST

了解 AWS RDS 多可用区同步复制

  • 6

多可用区 AWS RDS文档指出:

在此输入图像描述

  1. 什么是“同步块级复制”?
  2. 鉴于这种复制是在磁盘级别,而不是数据库级别,这种形式是否与数据库复制一样可靠?
replication
  • 1 个回答
  • 21 Views
Martin Hope
Rafael
Asked: 2023-06-12 22:03:51 +0800 CST

Mongodb replicaset允许secondary写数据

  • 5

我很难理解 replicaSet 如何使用 2 个节点和一个仲裁器工作,在 3 个服务器和 ubuntu 22.04 中使用 MongoDB 6 社区。

我的实际情况是我在一个 replicaSet 中有 2 个服务器,其中第一个是主服务器(优先级 1)和一个优先级为 0.5 的辅助服务器(我是这样设置的,所以我总是可以将主服务器作为主服务器)。第三台服务器不存储任何作为仲裁器工作的数据。

我测试关闭我的主要,所以我的次要被选为主要没有问题。但是如果我试图在上面写任何数据,他不会保存直到我的主要回来。

我的想法是让我的辅助服务器作为备用服务器,以防我的主服务器因任何原因出现故障,这样我的应用程序就可以继续保存和读取。

我知道我可以使用 3 个服务器节点,所以我会有 2 个可写服务器来投票,考虑到这个数据库将有大约 1TB 的数据,我现在不能让第三个服务器保存相同数量的数据。

我尝试了一些关于写关注的命令,但我有两种不同的行为:

1 - 使用此命令,使用 mongodb Compass,似乎写入了新数据,但在主数据库返回之前不会列出:

db.adminCommand({ "setDefaultRWConcern": 1, "defaultWriteConcern": { "w": 1 } })

2 - 使用 mongodb Compass,显示“Iinserting Document”,但永远不会完成,直到 primary 返回:

db.adminCommand({ "setDefaultRWConcern": 1, "defaultWriteConcern": { "w": "majority" } })

更新连接方式:通过 PHP 应用程序,将 ssh 与mongosh带有连接字符串的 MongoDB Compass 结合使用(在 Wernfried 的帮助下): mongodb://rootuser:rootpasswd@primaryip:27017,secondaryip:27017/?replicaSet=myRepl&authSource=admin&readPreference=primaryPreferred

如果我关闭我的主服务器,次要服务器将被选为主要服务器,但在两个节点都在线之前我无法写入。

这就是我的 rs.conf() 现在的样子

{
   _id: 'rspd01',
   version: 13,
   term: 51,
   members: [
     {
        _id: 0,
        host: 'primaryIP:27017',
        arbiterOnly: false,
        buildIndexes: true,
        hidden: false,
        priority: 1,
        tags: {},
        secondaryDelaySecs: Long("0"),
        votes: 1
     },
     {
        _id: 1,
        host: 'secondaryIP:27017',
        arbiterOnly: false,
        buildIndexes: true,
        hidden: false,
        priority: 0.5,
        tags: {},
        secondaryDelaySecs: Long("0"),
        votes: 1
     },
     {
        _id: 2,
        host: 'arbiterIP:27017',
        arbiterOnly: true,
        buildIndexes: true,
        hidden: false,
        priority: 0,
        tags: {},
        secondaryDelaySecs: Long("0"),
        votes: 1
     }
   ],
   protocolVersion: Long("1"),
   writeConcernMajorityJournalDefault: true,
   settings: {
      chainingAllowed: true,
      heartbeatIntervalMillis: 2000,
      heartbeatTimeoutSecs: 10,
      electionTimeoutMillis: 10000,
      catchUpTimeoutMillis: -1,
      catchUpTakeoverDelayMillis: 30000,
      getLastErrorModes: {},
      getLastErrorDefaults: { w: 1, wtimeout: 0 },
      replicaSetId: ObjectId("64863fd09a9b54d4cd0da913")
   }
}

我可以使用任何命令来处理这个结构吗?

此致。

replication
  • 1 个回答
  • 31 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    连接到 PostgreSQL 服务器:致命:主机没有 pg_hba.conf 条目

    • 12 个回答
  • Marko Smith

    如何让sqlplus的输出出现在一行中?

    • 3 个回答
  • Marko Smith

    选择具有最大日期或最晚日期的日期

    • 3 个回答
  • Marko Smith

    如何列出 PostgreSQL 中的所有模式?

    • 4 个回答
  • Marko Smith

    列出指定表的所有列

    • 5 个回答
  • Marko Smith

    如何在不修改我自己的 tnsnames.ora 的情况下使用 sqlplus 连接到位于另一台主机上的 Oracle 数据库

    • 4 个回答
  • Marko Smith

    你如何mysqldump特定的表?

    • 4 个回答
  • Marko Smith

    使用 psql 列出数据库权限

    • 10 个回答
  • Marko Smith

    如何从 PostgreSQL 中的选择查询中将值插入表中?

    • 4 个回答
  • Marko Smith

    如何使用 psql 列出所有数据库和表?

    • 7 个回答
  • Martin Hope
    Jin 连接到 PostgreSQL 服务器:致命:主机没有 pg_hba.conf 条目 2014-12-02 02:54:58 +0800 CST
  • Martin Hope
    Stéphane 如何列出 PostgreSQL 中的所有模式? 2013-04-16 11:19:16 +0800 CST
  • Martin Hope
    Mike Walsh 为什么事务日志不断增长或空间不足? 2012-12-05 18:11:22 +0800 CST
  • Martin Hope
    Stephane Rolland 列出指定表的所有列 2012-08-14 04:44:44 +0800 CST
  • Martin Hope
    haxney MySQL 能否合理地对数十亿行执行查询? 2012-07-03 11:36:13 +0800 CST
  • Martin Hope
    qazwsx 如何监控大型 .sql 文件的导入进度? 2012-05-03 08:54:41 +0800 CST
  • Martin Hope
    markdorison 你如何mysqldump特定的表? 2011-12-17 12:39:37 +0800 CST
  • Martin Hope
    Jonas 如何使用 psql 对 SQL 查询进行计时? 2011-06-04 02:22:54 +0800 CST
  • Martin Hope
    Jonas 如何从 PostgreSQL 中的选择查询中将值插入表中? 2011-05-28 00:33:05 +0800 CST
  • Martin Hope
    Jonas 如何使用 psql 列出所有数据库和表? 2011-02-18 00:45:49 +0800 CST

热门标签

sql-server mysql postgresql sql-server-2014 sql-server-2016 oracle sql-server-2008 database-design query-performance sql-server-2017

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助
subwaysurfers
my femboy roommate

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve