简体   繁体   English

将mssql表事务记录到Redis

[英]Logging mssql tables transactions to redis

I have mssql database and tons of tables have update, delete triggers. 我有mssql数据库,并且大量的表都有更新,删除触发器。 All tables are inserting the changes into one Log table inside same database. 所有表都将更改插入同一数据库内的一个Log表中。 Also we have sql job which moves logs into another database which contains only log table. 另外,我们还有sql作业,它将日志移到另一个仅包含日志表的数据库中。 I want to make it faster this operation with NoSQL database like this: 我想像这样用NoSQL数据库使该操作更快:

MSSQL->
  MainDB->
    update/delete->
      triggers 
           collect before,update rows into xml 
           and insert as JSON into Redis db

I don't know this is faster than this: 我不知道这比这快:

MSSQL->
  MainDB->
    update/delete->
      triggers 
          collect before,update rows into xml 
          and insert into log table in the same db

If NoSQL would be faster than itself, how should I call Redis api from MSSQL Trigger? 如果NoSQL比自己快,我该如何从MSSQL Trigger调用Redis api?

This depends on what you want to use your logs for, but a few pieces of advice: 这取决于您要使用日志的目的,但是有一些建议:

  1. It sounds like you're going to have a lot of logs. 听起来您将有很多日志。 Among many other reasons not to use Redis for this, it is an in-memory datastore, and you are going to be wasting a ton of memory just to store logs, which I'm guessing you really don't need fast access to. 不使用Redis的原因还有很多,它是内存中的数据存储,您将浪费大量的内存仅用于存储日志,我猜您真的不需要快速访问。 Just fast writes. 只是快速写入。 You can get fast writes much more cheaply. 您可以便宜得多地获得快速写入。

  2. There are lots of great distributed logging frameworks that will do what you want ( Kafka , Fluentd , etc...). 有很多出色的分布式日志记录框架可以满足您的需求( KafkaFluentd等)。 FluentD is really easy to use and will let you configure your logging to run in a distributed manner that will be fast and disconnected from your database. FluentD确实非常易于使用,并且可以让您将日志配置为以分布式方式运行,该方式可以快速且与数据库断开连接。 It has many connectors that will let you stream your logs to various stores (MongoDB, MySQL, flat files, S3 etc...). 它具有许多连接器,可让您将日志流式传输到各种存储(MongoDB,MySQL,平面文件,S3等...)。 Your choice of datastore should depend on what you eventually want to do with your logs. 您对数据存储区的选择应取决于您最终希望对日志执行什么操作。

  3. Do you have to call the log from an MsSQL trigger? 您是否必须从MsSQL触发器调用日志? It's an unnecessary hit on your database, and you could easily call the log from your application instead. 这对数据库没有必要,您可以轻松地从应用程序中调用日志。 This will make the whole thing distributed per app box and take the load off your db. 这将使整个事情在每个应用程序框中分发,并减轻数据库的负担。

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

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