Logstash JDBC last_run 元数据文件未更新

Logstash JDBC last_run metadata file not updating

我们在 linux 中使用 logstash 执行初始 运行 作业,然后为每个 JDBC 输入创建 last_run 元数据文件。这很好用,但我们注意到最后一个 运行 元数据文件是用 root 的所有者和 root 的组关联创建的。配置文件通过 SSH 执行到名为 logstash 的用户下的服务器。

sudo time /usr/share/logstash/bin/logstash -f /home/ubuntu/manual-pipeline.conf --path.settings /etc/logstash/ --path.data /var/lib/log

然后我们有另一个 logstash 配置,我们运行将其作为服务。唯一的区别是它包含计划作业,这些作业将使用我们第一个配置中相同的最后一个 运行 元数据文件。我们注意到,当它能够更新最后一个 运行 元数据时,文件的所有者是 logstash。我们现在有许多元数据文件在根目录下,但没有得到更新。如果我们手动将所有者更新为 logstash,那么计划的作业能够毫无问题地更新文件。

sudo chown logstash .last_run

我们所有的元数据文件都存储在 /etc/logstash 中,我们将其配置为所有者 root 和组 logstash。我们使用相同的 SSH 连接 运行 连接 manual-pipeline.conf 并将 scheduled-pipeline.conf 复制到 /etc/logstash/conf.d 并使用 sudo service logstash start.

启动服务

logstash用户只有logstashadm组。我还要补充一点,我们只使用来自最后一个 运行 元数据的时间戳,并且我们在 SQL 查询的 where 子句中使用 :sql_last_value

问题:

抱歉,如果信息到处都是。我只是 logstash 和所有这些的新手。如果有帮助,我相信我们正在使用 Logstash 5.4.1。

Why is the initial creation of the last run metadata files owned by root? Can we configure this?

最后的 运行 元数据文件将由 运行s logstash 的用户拥有,如果它们首先由 root 用户拥有,那么某人 运行 logstash 为 root,使用 sudo。

Why is our service using the logstash user and not root? (I'm new to this)

这是默认设置,logstash 服务使用用户 logstash,而不是 root。出于安全原因,建议不要 运行 以 root 身份登录。

We know we can work around this by changing the owner but is there a better solution to this problem?

在您的示例中,您使用的 sudo 没有 -u logstash 参数,因此它将 运行 作为 root 用户,而不是 logstash 用户。

您应该尝试 运行 logstash 作为 logstash 用户,只需确保 logstash 用户可以访问目录 /home/ubuntu 中的配置文件或移动此文件到 logstash 用户有权访问的另一个目录。