简体   繁体   English

使用 CRON 作业和 CURL 从本地系统同步 Laravel 本地 mysql 数据库与 LIVE 服务器数据库手动代码

[英]Sync Laravel Local mysql database with LIVE server database manual code from Local system using CRON job and CURL

I want local database sync with live database using CURL and CRON job in LARAVEL not using third party tool manual code我希望本地数据库与使用 CURL 和 LARAVEL 中的 CRON 作业的实时数据库同步,而不使用第三方工具手动代码

it is almost a complicated issue.这几乎是一个复杂的问题。 you need to pay attention to a bunch of concepts:你需要注意一堆概念:

CAP Theorem CAP定理

In the CAP theorem, also named Brewer's theorem, we know that any distributed data store can only provide two of the following three guarantees:在 CAP 定理(也称为 Brewer 定理)中,我们知道任何分布式数据存储都只能提供以下三个保证中的两个:

  • Consistency一致性

Every read receives the most recent write or an error.每次读取都会收到最近的写入或错误。

  • Availability可用性

Every request receives a (non-error) response, without the guarantee that it contains the most recent write.每个请求都会收到一个(非错误)响应,但不能保证它包含最近的写入。

  • Partition tolerance分区容错

The system continues to operate despite an arbitrary number of messages being dropped (or delayed) by the network between nodes.尽管节点之间的网络丢弃(或延迟)任意数量的消息,系统仍继续运行。

since you have Partition tolerance in your desired situation, so your problem is the choice between consistency and high availability.由于您在所需情况下具有分区容差,因此您的问题是在一致性和高可用性之间进行选择。

I mentioned this theorem to notice you that you cant have any guaranty for having them both in WHATEVER solution you asking for.我提到这个定理是为了注意到你不能保证在你要求的任何解决方案中都拥有它们。

anyway...反正...

the Databases availability and consistency issues are one of the tops arguments in the world of information technology.数据库的可用性和一致性问题是信息技术领域的顶级 arguments 之一。 there are several ways for achieving such a purpose, for example using:有几种方法可以实现这一目的,例如使用:

  • implementation clustering实现集群
  • master/slave - master/master - active/passive - active-active - etc architectures主/从 - 主/主 - 主动/被动 - 主动-主动 - 等架构
  • using changelogs for keeping two DB sync使用变更日志保持两个数据库同步
  • implementing CDC or some structure like it实施 CDC 或类似的结构
  • and every other solution.以及其他所有解决方案。

so I must say that your issue cant be satisfy without using third-party libraries of some system-level configuration, you cant do it with just a simple CURL.所以我必须说,如果不使用一些系统级配置的第三方库,你的问题就不能满足,你不能只用一个简单的 CURL 来解决。

but if you insist to do it with the nearest approach to curl, you can use NFS , by getting SQL backup and loading it instead of your local one.但是,如果您坚持使用最接近 curl 的方法来执行此操作,则可以使用NFS ,方法是获取 SQL 备份并加载它而不是本地备份。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM