使用指定日志传输 Amazon CLI - ElastiCache 适用于 Redis 的 Amazon
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

使用指定日志传输 Amazon CLI

慢日志

创建一个向日志传送缓慢 CloudWatch 日志的复制组。

对于 Linux、macOS 或 Unix:

aws elasticache create-replication-group \ --replication-group-id test-slow-log \ --replication-group-description test-slow-log \ --engine redis \ --cache-node-type cache.r5.large \ --num-cache-clusters 2 \ --log-delivery-configurations '{ "LogType":"slow-log", "DestinationType":"cloudwatch-logs", "DestinationDetails":{ "CloudWatchLogsDetails":{ "LogGroup":"my-log-group" } }, "LogFormat":"json" }'

对于 Windows:

aws elasticache create-replication-group ^ --replication-group-id test-slow-log ^ --replication-group-description test-slow-log ^ --engine redis ^ --cache-node-type cache.r5.large ^ --num-cache-clusters 2 ^ --log-delivery-configurations '{ "LogType":"slow-log", "DestinationType":"cloudwatch-logs", "DestinationDetails":{ "CloudWatchLogsDetails":{ "LogGroup":"my-log-group" } }, "LogFormat":"json" }'

修改复制组以将慢速日志传送到 CloudWatch 日志

对于 Linux、macOS 或 Unix:

aws elasticache modify-replication-group \ --replication-group-id test-slow-log \ --apply-immediately \ --log-delivery-configurations ' { "LogType":"slow-log", "DestinationType":"cloudwatch-logs", "DestinationDetails":{ "CloudWatchLogsDetails":{ "LogGroup":"my-log-group" } }, "LogFormat":"json" }'

对于 Windows:

aws elasticache modify-replication-group ^ --replication-group-id test-slow-log ^ --apply-immediately ^ --log-delivery-configurations ' { "LogType":"slow-log", "DestinationType":"cloudwatch-logs", "DestinationDetails":{ "CloudWatchLogsDetails":{ "LogGroup":"my-log-group" } }, "LogFormat":"json" }'

修改复制组以禁用慢日志传递

对于 Linux、macOS 或 Unix:

aws elasticache modify-replication-group \ --replication-group-id test-slow-log \ --apply-immediately \ --log-delivery-configurations ' { "LogType":"slow-log", "Enabled":false }'

对于 Windows:

aws elasticache modify-replication-group ^ --replication-group-id test-slow-log ^ --apply-immediately ^ --log-delivery-configurations ' { "LogType":"slow-log", "Enabled":false }'

引擎日志

创建将引擎日志传送到 CloudWatch 日志的复制组。

对于 Linux、macOS 或 Unix:

aws elasticache create-replication-group \ --replication-group-id test-slow-log \ --replication-group-description test-slow-log \ --engine redis \ --cache-node-type cache.r5.large \ --num-cache-clusters 2 \ --log-delivery-configurations '{ "LogType":"engine-log", "DestinationType":"cloudwatch-logs", "DestinationDetails":{ "CloudWatchLogsDetails":{ "LogGroup":"my-log-group" } }, "LogFormat":"json" }'

对于 Windows:

aws elasticache create-replication-group ^ --replication-group-id test-slow-log ^ --replication-group-description test-slow-log ^ --engine redis ^ --cache-node-type cache.r5.large ^ --num-cache-clusters 2 ^ --log-delivery-configurations '{ "LogType":"engine-log", "DestinationType":"cloudwatch-logs", "DestinationDetails":{ "CloudWatchLogsDetails":{ "LogGroup":"my-log-group" } }, "LogFormat":"json" }'

修改复制组以将引擎日志传送到 Firehose

对于 Linux、macOS 或 Unix:

aws elasticache modify-replication-group \ --replication-group-id test-slow-log \ --apply-immediately \ --log-delivery-configurations ' { "LogType":"engine-log", "DestinationType":"kinesis-firehose", "DestinationDetails":{ "KinesisFirehoseDetails":{ "DeliveryStream":"test" } }, "LogFormat":"json" }'

对于 Windows:

aws elasticache modify-replication-group ^ --replication-group-id test-slow-log ^ --apply-immediately ^ --log-delivery-configurations ' { "LogType":"engine-log", "DestinationType":"kinesis-firehose", "DestinationDetails":{ "KinesisFirehoseDetails":{ "DeliveryStream":"test" } }, "LogFormat":"json" }'

修改复制组以切换到引擎格式

对于 Linux、macOS 或 Unix:

aws elasticache modify-replication-group \ --replication-group-id test-slow-log \ --apply-immediately \ --log-delivery-configurations ' { "LogType":"engine-log", "LogFormat":"json" }'

对于 Windows:

aws elasticache modify-replication-group ^ --replication-group-id test-slow-log ^ --apply-immediately ^ --log-delivery-configurations ' { "LogType":"engine-log", "LogFormat":"json" }'

修改复制组以禁用引擎日志传递

对于 Linux、macOS 或 Unix:

aws elasticache modify-replication-group \ --replication-group-id test-slow-log \ --apply-immediately \ --log-delivery-configurations ' { "LogType":"engine-log", "Enabled":false }'

对于 Windows:

aws elasticache modify-replication-group ^ --replication-group-id test-slow-log ^ --apply-immediately ^ --log-delivery-configurations ' { "LogType":"engine-log", "Enabled":false }'