mirror of
https://github.com/systemd/systemd
synced 2024-10-15 04:24:19 +00:00
journald: add Storage= setting to control where the journal is stored
This commit is contained in:
parent
29252e9e5b
commit
e156d769c3
16
TODO
16
TODO
|
@ -22,6 +22,14 @@ Bugfixes:
|
||||||
|
|
||||||
Features:
|
Features:
|
||||||
|
|
||||||
|
* reexec journald across initrd transition
|
||||||
|
|
||||||
|
* nspawn: bind mount /var/log/journal from the host
|
||||||
|
|
||||||
|
* The current Storage=auto logic is borked, since people cannot mount
|
||||||
|
/var/log/journal via NFS since the mount point has to exist and we
|
||||||
|
already take that as signal to store our stuff there.
|
||||||
|
|
||||||
* rename systemd-udev.service to systemd-udevd.service
|
* rename systemd-udev.service to systemd-udevd.service
|
||||||
|
|
||||||
* document that journal data is primarily ASCII, UTF-8 where necessary and binary only where nothing else makes sense.
|
* document that journal data is primarily ASCII, UTF-8 where necessary and binary only where nothing else makes sense.
|
||||||
|
@ -110,8 +118,6 @@ Features:
|
||||||
|
|
||||||
* don't delete /tmp/systemd-namespace-* before a process is gone down
|
* don't delete /tmp/systemd-namespace-* before a process is gone down
|
||||||
|
|
||||||
* don't delete /run/users/lennart if lennart is still logged in even if aging is used
|
|
||||||
|
|
||||||
* vconsole: implement setterm -store -foreground xxx --background zzz
|
* vconsole: implement setterm -store -foreground xxx --background zzz
|
||||||
|
|
||||||
* ExecOnFailure=/usr/bin/foo
|
* ExecOnFailure=/usr/bin/foo
|
||||||
|
@ -170,8 +176,6 @@ Features:
|
||||||
|
|
||||||
* journal: store euid in journal if it differs from uid
|
* journal: store euid in journal if it differs from uid
|
||||||
|
|
||||||
* support chrony in addition to ntpd in timedated
|
|
||||||
|
|
||||||
* There's currently no way to cancel fsck (used to be possible via C-c or c on the console)
|
* There's currently no way to cancel fsck (used to be possible via C-c or c on the console)
|
||||||
|
|
||||||
* journal: sanely deal with entries which are larger than the individual file size, but where the componets would fit
|
* journal: sanely deal with entries which are larger than the individual file size, but where the componets would fit
|
||||||
|
@ -236,8 +240,6 @@ Features:
|
||||||
|
|
||||||
* when an instanced service exits, remove its parent cgroup too if possible.
|
* when an instanced service exits, remove its parent cgroup too if possible.
|
||||||
|
|
||||||
* automatically escape unit names passed on the service (i.e. think "systemctl start serial-getty.service@serial/by-path/jshdfjsdfhkjh" being automatically escaped as necessary.
|
|
||||||
|
|
||||||
* if we can not get user quota for tmpfs, mount a separate tmpfs instance
|
* if we can not get user quota for tmpfs, mount a separate tmpfs instance
|
||||||
for every user in /run/user/$USER with a configured maximum size
|
for every user in /run/user/$USER with a configured maximum size
|
||||||
|
|
||||||
|
@ -417,3 +419,5 @@ Regularly:
|
||||||
Scheduled for removal (or fixing):
|
Scheduled for removal (or fixing):
|
||||||
|
|
||||||
* xxxOverridable dependencies
|
* xxxOverridable dependencies
|
||||||
|
|
||||||
|
* journald.conf: ImportKernel=
|
||||||
|
|
|
@ -286,6 +286,46 @@
|
||||||
traditional syslog service.
|
traditional syslog service.
|
||||||
</para></listitem>
|
</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><varname>Storage=</varname></term>
|
||||||
|
|
||||||
|
<listitem><para>Controls where to
|
||||||
|
store journal data. One of
|
||||||
|
<literal>volatile</literal>,
|
||||||
|
<literal>permanent</literal>,
|
||||||
|
<literal>auto</literal> and
|
||||||
|
<literal>none</literal>. If
|
||||||
|
<literal>volatile</literal> journal
|
||||||
|
log data will be stored only in
|
||||||
|
memory, i.e. below the
|
||||||
|
<filename>/run/log/journal</filename>
|
||||||
|
hierarchy (which is created if
|
||||||
|
needed). If
|
||||||
|
<literal>permanent</literal> data will
|
||||||
|
be stored preferably on disk,
|
||||||
|
i.e. below the
|
||||||
|
<filename>/var/log/journal</filename>
|
||||||
|
hierarchy (which is created if
|
||||||
|
needed), with a fallback to
|
||||||
|
<filename>/run/log/journal</filename>
|
||||||
|
(which is created if needed), during
|
||||||
|
early boot and if the disk is not
|
||||||
|
writable. <literal>auto</literal> is
|
||||||
|
similar to
|
||||||
|
<literal>permanent</literal> but the
|
||||||
|
directory
|
||||||
|
<filename>/var/log/journal</filename>
|
||||||
|
is not created if needed, so that its
|
||||||
|
existance controls where log data
|
||||||
|
goes. <literal>none</literal> turns
|
||||||
|
off all storage, all log data received
|
||||||
|
will be dropped. Forwarding to other
|
||||||
|
targets, such as the console, the
|
||||||
|
kernel log buffer or a syslog daemon
|
||||||
|
will still work however. Defaults to
|
||||||
|
<literal>auto</literal>.</para></listitem>
|
||||||
|
</varlistentry>
|
||||||
</variablelist>
|
</variablelist>
|
||||||
|
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|
|
@ -34,3 +34,4 @@ Journal.MaxLevelStore, config_parse_level, 0, offsetof(Server, max_leve
|
||||||
Journal.MaxLevelSyslog, config_parse_level, 0, offsetof(Server, max_level_syslog)
|
Journal.MaxLevelSyslog, config_parse_level, 0, offsetof(Server, max_level_syslog)
|
||||||
Journal.MaxLevelKMsg, config_parse_level, 0, offsetof(Server, max_level_kmsg)
|
Journal.MaxLevelKMsg, config_parse_level, 0, offsetof(Server, max_level_kmsg)
|
||||||
Journal.MaxLevelConsole, config_parse_level, 0, offsetof(Server, max_level_console)
|
Journal.MaxLevelConsole, config_parse_level, 0, offsetof(Server, max_level_console)
|
||||||
|
Journal.Storage, config_parse_storage, 0, offsetof(Server, storage)
|
||||||
|
|
|
@ -111,6 +111,16 @@ struct StdoutStream {
|
||||||
LIST_FIELDS(StdoutStream, stdout_stream);
|
LIST_FIELDS(StdoutStream, stdout_stream);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const char* const storage_table[] = {
|
||||||
|
[STORAGE_AUTO] = "auto",
|
||||||
|
[STORAGE_VOLATILE] = "volatile",
|
||||||
|
[STORAGE_PERMANENT] = "permanent",
|
||||||
|
[STORAGE_NONE] = "none"
|
||||||
|
};
|
||||||
|
|
||||||
|
DEFINE_STRING_TABLE_LOOKUP(storage, Storage);
|
||||||
|
DEFINE_CONFIG_PARSE_ENUM(config_parse_storage, storage, Storage, "Failed to parse storage setting");
|
||||||
|
|
||||||
static int server_flush_to_var(Server *s);
|
static int server_flush_to_var(Server *s);
|
||||||
|
|
||||||
static uint64_t available_space(Server *s) {
|
static uint64_t available_space(Server *s) {
|
||||||
|
@ -397,7 +407,6 @@ static void server_vacuum(Server *s) {
|
||||||
free(p);
|
free(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (s->runtime_journal) {
|
if (s->runtime_journal) {
|
||||||
if (asprintf(&p, "/run/log/journal/%s", ids) < 0) {
|
if (asprintf(&p, "/run/log/journal/%s", ids) < 0) {
|
||||||
log_error("Out of memory.");
|
log_error("Out of memory.");
|
||||||
|
@ -625,9 +634,7 @@ static void dispatch_message_real(
|
||||||
|
|
||||||
retry:
|
retry:
|
||||||
f = find_journal(s, realuid == 0 ? 0 : loginuid);
|
f = find_journal(s, realuid == 0 ? 0 : loginuid);
|
||||||
if (!f)
|
if (f) {
|
||||||
log_warning("Dropping message, as we can't find a place to store the data.");
|
|
||||||
else {
|
|
||||||
r = journal_file_append_entry(f, NULL, iovec, n, &s->seqnum, NULL, NULL);
|
r = journal_file_append_entry(f, NULL, iovec, n, &s->seqnum, NULL, NULL);
|
||||||
|
|
||||||
if ((r == -E2BIG || /* hit limit */
|
if ((r == -E2BIG || /* hit limit */
|
||||||
|
@ -1955,12 +1962,23 @@ static int system_journal_open(Server *s) {
|
||||||
|
|
||||||
sd_id128_to_string(machine, ids);
|
sd_id128_to_string(machine, ids);
|
||||||
|
|
||||||
if (!s->system_journal) {
|
if (!s->system_journal &&
|
||||||
|
(s->storage == STORAGE_PERMANENT ||
|
||||||
|
s->storage == STORAGE_AUTO)) {
|
||||||
|
|
||||||
|
/* If in auto mode: first try to create the machine
|
||||||
|
* path, but not the prefix.
|
||||||
|
*
|
||||||
|
* If in permanent mode: create /var/log/journal and
|
||||||
|
* the machine path */
|
||||||
|
|
||||||
|
if (s->storage & STORAGE_PERMANENT)
|
||||||
|
(void) mkdir("/var/log/journal/", 0755);
|
||||||
|
|
||||||
/* First try to create the machine path, but not the prefix */
|
|
||||||
fn = strappend("/var/log/journal/", ids);
|
fn = strappend("/var/log/journal/", ids);
|
||||||
if (!fn)
|
if (!fn)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
(void) mkdir(fn, 0755);
|
(void) mkdir(fn, 0755);
|
||||||
free(fn);
|
free(fn);
|
||||||
|
|
||||||
|
@ -1988,7 +2006,8 @@ static int system_journal_open(Server *s) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!s->runtime_journal) {
|
if (!s->runtime_journal &&
|
||||||
|
(s->storage != STORAGE_NONE)) {
|
||||||
|
|
||||||
fn = join("/run/log/journal/", ids, "/system.journal", NULL);
|
fn = join("/run/log/journal/", ids, "/system.journal", NULL);
|
||||||
if (!fn)
|
if (!fn)
|
||||||
|
@ -2048,6 +2067,10 @@ static int server_flush_to_var(Server *s) {
|
||||||
|
|
||||||
assert(s);
|
assert(s);
|
||||||
|
|
||||||
|
if (s->storage != STORAGE_AUTO &&
|
||||||
|
s->storage != STORAGE_PERMANENT)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (!s->runtime_journal)
|
if (!s->runtime_journal)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,15 @@
|
||||||
#include "journal-rate-limit.h"
|
#include "journal-rate-limit.h"
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
|
|
||||||
|
typedef enum Storage {
|
||||||
|
STORAGE_AUTO,
|
||||||
|
STORAGE_VOLATILE,
|
||||||
|
STORAGE_PERMANENT,
|
||||||
|
STORAGE_NONE,
|
||||||
|
_STORAGE_MAX,
|
||||||
|
_STORAGE_INVALID = -1
|
||||||
|
} Storage;
|
||||||
|
|
||||||
typedef struct StdoutStream StdoutStream;
|
typedef struct StdoutStream StdoutStream;
|
||||||
|
|
||||||
typedef struct Server {
|
typedef struct Server {
|
||||||
|
@ -86,9 +95,16 @@ typedef struct Server {
|
||||||
int max_level_syslog;
|
int max_level_syslog;
|
||||||
int max_level_kmsg;
|
int max_level_kmsg;
|
||||||
int max_level_console;
|
int max_level_console;
|
||||||
|
|
||||||
|
Storage storage;
|
||||||
} Server;
|
} Server;
|
||||||
|
|
||||||
/* gperf lookup function */
|
/* gperf lookup function */
|
||||||
const struct ConfigPerfItem* journald_gperf_lookup(const char *key, unsigned length);
|
const struct ConfigPerfItem* journald_gperf_lookup(const char *key, unsigned length);
|
||||||
|
|
||||||
|
int config_parse_storage(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
|
||||||
|
|
||||||
|
const char *storage_to_string(Storage s);
|
||||||
|
Storage storage_from_string(const char *s);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -18,3 +18,4 @@
|
||||||
#HandlePowerKey=no-session
|
#HandlePowerKey=no-session
|
||||||
#HandleSleepKey=tty-session
|
#HandleSleepKey=tty-session
|
||||||
#HandleLidSwitch=off
|
#HandleLidSwitch=off
|
||||||
|
#Storage=auto
|
||||||
|
|
Loading…
Reference in a new issue