gpt4 book ai didi

docker - 如何在Cassandra 4.0 Docker容器上启用完整查询日志记录?

转载 作者:行者123 更新时间:2023-12-02 19:14:06 26 4
gpt4 key购买 nike

我想运行一个启用了Full Query Logging (FQL)的运行Cassandra 4的Docker容器。到目前为止,我已经尝试构建以下Dockerfile:

FROM cassandra:4.0
RUN nodetool enablefullquerylog
但这失败,并显示以下错误:
nodetool: Failed to connect to '127.0.0.1:7199' - ConnectException: 'Connection refused (Connection refused)'.
我还尝试取消注释Docker容器上 full_query_logging_options中的 cassandra.yaml中的 /etc/cassandra/cassandra.yaml:
# default options for full query logging - these can be overridden from command line when executing
# nodetool enablefullquerylog
full_query_logging_options:
log_dir: /var/log/cassandra/fql.log
roll_cycle: HOURLY
block: true
max_queue_weight: 268435456 # 256 MiB
max_log_size: 17179869184 # 16 GiB
# archive command is "/path/to/script.sh %path" where %path is replaced with the file being rolled:
archive_command:
max_archive_retries: 10
理想情况下,我想在 cassandra.yaml中启用FQL而不必使用 nodetool命令,但这似乎是不可能的(鉴于已使用 nodetool启用了它,因此只能配置其选项)?
我也不确定如何更改 cassandra.yaml以便允许 nodetool连接。我注意到,在运行Cassandra 3的 cassandra Docker镜像中, nodetool命令有效;它只是在 cassandra:4.0图片中不起作用。从 Cassandra failed to connect看来,似乎需要在 listen_address中配置 broadcast_addresscassandra.yaml。在Cassandra 3 Docker容器中,我可以看到默认配置如下:
# Address or interface to bind to and tell other Cassandra nodes to connect to.
# You _must_ change this if you want multiple nodes to be able to communicate!
#
# Set listen_address OR listen_interface, not both.
#
# Leaving it blank leaves it up to InetAddress.getLocalHost(). This
# will always do the Right Thing _if_ the node is properly configured
# (hostname, name resolution, etc), and the Right Thing is to use the
# address associated with the hostname (it might not be).
#
# Setting listen_address to 0.0.0.0 is always wrong.
#
listen_address: 172.17.0.5

# Set listen_address OR listen_interface, not both. Interfaces must correspond
# to a single address, IP aliasing is not supported.
# listen_interface: eth0

# If you choose to specify the interface by name and the interface has an ipv4 and an ipv6 address
# you can specify which should be chosen using listen_interface_prefer_ipv6. If false the first ipv4
# address will be used. If true the first ipv6 address will be used. Defaults to false preferring
# ipv4. If there is only one address it will be selected regardless of ipv4/ipv6.
# listen_interface_prefer_ipv6: false

# Address to broadcast to other Cassandra nodes
# Leaving this blank will set it to the same value as listen_address
broadcast_address: 172.17.0.5
而在Cassandra 4容器中
# Address or interface to bind to and tell other Cassandra nodes to connect to.
# You _must_ change this if you want multiple nodes to be able to communicate!
#
# Set listen_address OR listen_interface, not both.
#
# Leaving it blank leaves it up to InetAddress.getLocalHost(). This
# will always do the Right Thing _if_ the node is properly configured
# (hostname, name resolution, etc), and the Right Thing is to use the
# address associated with the hostname (it might not be). If unresolvable
# it will fall back to InetAddress.getLoopbackAddress(), which is wrong for production systems.
#
# Setting listen_address to 0.0.0.0 is always wrong.
#
listen_address: localhost

# Set listen_address OR listen_interface, not both. Interfaces must correspond
# to a single address, IP aliasing is not supported.
# listen_interface: eth0

# If you choose to specify the interface by name and the interface has an ipv4 and an ipv6 address
# you can specify which should be chosen using listen_interface_prefer_ipv6. If false the first ipv4
# address will be used. If true the first ipv6 address will be used. Defaults to false preferring
# ipv4. If there is only one address it will be selected regardless of ipv4/ipv6.
# listen_interface_prefer_ipv6: false

# Address to broadcast to other Cassandra nodes
# Leaving this blank will set it to the same value as listen_address
# broadcast_address: 1.2.3.4
我不太了解 172.17.0.5的来源,以及为什么将 cassandra.yaml设置为该值将允许 nodetool在容器上工作。有什么想法如何在Cassandra 4容器上使用 nodetool启用FQL?

最佳答案

事实证明,默认情况下,构建容器时无法在nodetool中运行Dockerfile命令。相反,它们必须在正在运行的容器中“手动”运行。因此,我将Dockerfile修改为以下内容:

FROM cassandra:4.0
RUN mkdir /cassandra-fql && chmod 777 /cassandra-fql
COPY cassandra.yaml /etc/cassandra/cassandra.yaml
除了以下 cassandra.yaml之外, full_query_logging_options与默认代码相同:
# default options for full query logging - these can be overridden from command line when executing
# nodetool enablefullquerylog
full_query_logging_options:
log_dir: /cassandra-fql
roll_cycle: HOURLY
block: true
max_queue_weight: 268435456 # 256 MiB
max_log_size: 17179869184 # 16 GiB
# archive command is "/path/to/script.sh %path" where %path is replaced with the file being rolled:
# archive_command:
max_archive_retries: 10
然后,像这样运行容器后
docker run --name cassandra-fql -p 127.0.0.1:9042:9042 cassandra-fql
并将 docker exec插入其中,成功运行 nodetool enablefullquerylog

关于docker - 如何在Cassandra 4.0 Docker容器上启用完整查询日志记录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64635412/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com