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

xlpyo6sf  于 2021-06-09  发布在  Cassandra
关注(0)|答案(1)|浏览(434)

我想运行一个运行Cassandra4的docker容器,并启用完全查询日志记录(fql)。到目前为止,我已经尝试建立以下 Dockerfile :

FROM cassandra:4.0
RUN nodetool enablefullquerylog

但此操作失败,并出现以下错误:

nodetool: Failed to connect to '127.0.0.1:7199' - ConnectException: 'Connection refused (Connection refused)'.

我还尝试取消注解 full_query_logging_optionscassandra.yaml 位于 /etc/cassandra/cassandra.yaml 在docker容器上:


# 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 无需使用 nodetool 命令,但这似乎是不可能的(只有在使用 nodetool )?
我也不知道如何改变 cassandra.yaml 为了允许 nodetool 连接。我注意到 cassandra 运行cassandra 3的docker图像 nodetool 指挥工作;只是在黑暗中不起作用 cassandra:4.0 形象。从Cassandra连接失败,似乎需要的是配置 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

而在Cassandra4号集装箱里


# 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 在容器上工作。你知道怎么用吗 nodetool 在cassandra 4容器上启用fql?

ttisahbt

ttisahbt1#

结果是,默认情况下,您不能运行 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 他成功了。

相关问题