Discussion:
Logrotate for bind9
Blason R
2018-07-04 13:50:53 UTC
Permalink
Hi There,

I am not getting appropriate results for my custom daily logrorate for
bind9 logs on Ubuntu.

Can someone please help me with the settings which would include below
stuff


1. Should rotate daily
2. Compress
3. create new file
4. keep last 180 entries



Do I need stop bind9 while logs are being rotated? What is the correct
procedure to start logs in new file?
Anand Buddhdev
2018-07-04 14:00:04 UTC
Permalink
Post by Blason R
Hi There,
I am not getting appropriate results for my custom daily logrorate for
bind9 logs on Ubuntu.
It's more useful if you show us your logrotate snippet, so we can point
out what is wrong with it.
Post by Blason R
Can someone please help me with the settings which would include below
stuff
1. Should rotate daily
daily
Post by Blason R
2. Compress
compress
Post by Blason R
3. create new file
Usually not needed, because BIND creates the log file itself.
Post by Blason R
4. keep last 180 entries
rotate 180
Post by Blason R
Do I need stop bind9 while logs are being rotated? What is the correct
procedure to start logs in new file?
You don't have to stop BIND to rotate log files. Instead, you just run
"rndc reconfig" and that causes BIND to reopen its log files. If it
finds that the files have been moved (by logrotate) it will create new
log files.

Anand
_______________________________________________
Please visit https://lists.isc.org/mailman/listinfo/bind-users to unsubscribe from this list

bind-users mailing list
bind-***@lists.isc.org
https://lists.isc.org/mailman/listinfo/bind-users
Tom
2018-07-04 15:43:36 UTC
Permalink
Post by Anand Buddhdev
Post by Blason R
Hi There,
I am not getting appropriate results for my custom daily logrorate for
bind9 logs on Ubuntu.
It's more useful if you show us your logrotate snippet, so we can point
out what is wrong with it.
Post by Blason R
Can someone please help me with the settings which would include below
stuff
1. Should rotate daily
daily
Post by Blason R
2. Compress
compress
Post by Blason R
3. create new file
Usually not needed, because BIND creates the log file itself.
Post by Blason R
4. keep last 180 entries
rotate 180
Post by Blason R
Do I need stop bind9 while logs are being rotated? What is the correct
procedure to start logs in new file?
You don't have to stop BIND to rotate log files. Instead, you just run
"rndc reconfig" and that causes BIND to reopen its log files. If it
finds that the files have been moved (by logrotate) it will create new
log files.
...or you use "copytruncate", so the file will be copied and the other
stuff (compress, rotate 180, etc..) and then truncated, so BIND has
still the same filedescriptors open, but the logfile is rotated :-).
This way, you don't need to "rndc reconfig".
Kind regards,
Tom
Post by Anand Buddhdev
Anand
_______________________________________________
Please visit https://lists.isc.org/mailman/listinfo/bind-users to unsubscribe from this list
bind-users mailing list
https://lists.isc.org/mailman/listinfo/bind-users
_______________________________________________
Please visit https://lists.isc.org/mailman/listinfo/bind-users to unsubscribe from this list

bind-users mailing list
bind-***@lists.isc.org
https://lists.isc.org/mailman/listinfo/bind-users
Anand Buddhdev
2018-07-04 15:57:44 UTC
Permalink
On 04/07/2018 17:43, Tom wrote:

Hi Tom,
Post by Tom
...or you use "copytruncate", so the file will be copied and the other
stuff (compress, rotate 180, etc..) and then truncated, so BIND has
still the same filedescriptors open, but the logfile is rotated :-).
This way, you don't need to "rndc reconfig".
Sorry, but this is not good advice, and I strongly urge everyone not to
follow it.

Copying a file takes a finite amount of time, so the copy may not have
all the latest logs, and those are lost when the original is truncated.
The bigger the log file, the higher the chance of losing log messages.

The logrotate man page also notes this possibility of losing log
messages, and this option should only be used as a last resort, where
there's no way to tell a program to reopen its log file. BIND has no
such limitation, and so "rndc reconfig" is the right way to handle
reopening its log file.

Regards,
Anand
_______________________________________________
Please visit https://lists.isc.org/mailman/listinfo/bind-users to unsubscribe from this list

bind-users mailing list
bind-***@lists.isc.org
https://lists.isc.org/mailman/listinfo/bind-users
Blason R
2018-07-05 06:44:25 UTC
Permalink
What exactly are those? Well what I wated to achieve here is to rotate the
logs daily and start new file; then compress
Why not use Bind logging option?
Post by Blason R
Hi There,
I am not getting appropriate results for my custom daily logrorate for
bind9 logs on Ubuntu.
Can someone please help me with the settings which would include below
stuff
1. Should rotate daily
2. Compress
3. create new file
4. keep last 180 entries
Do I need stop bind9 while logs are being rotated? What is the correct
procedure to start logs in new file?
_______________________________________________
Please visit https://lists.isc.org/mailman/listinfo/bind-users to
unsubscribe from this list
bind-users mailing list
https://lists.isc.org/mailman/listinfo/bind-users
Browne, Stuart via bind-users
2018-07-05 07:53:22 UTC
Permalink
How about a clear, direct example of using external service 'logrotate' (this is from one of my redhat systems, but the same concept applies to Ubuntu/Debian):

[***@dns-nomnom1.den ~]$ cat /etc/logrotate.d/named
/var/log/named/*.log {
compress
create 0644 named named
daily
dateext
missingok
notifempty
rotate 30
sharedscripts
postrotate
/usr/sbin/rndc reconfig > /dev/null 2>/dev/null || true
endscript
}

We put our logs in the custom location of '/var/log/named/'; if you put them somewhere else, you'll need to change that. The other settings are direct references to Anand's email. Finally, you'll want to change the 30 to 180 to keep 180 different days worth of logs.

BIND internally doesn't have the concept based rotation, only size-based rotation. In order to achieve per-day logs, you'll need to use the external tool 'logrotate' (or similar) for your rotation. If you do that, you'll want to disable BIND's rotation in the logs configuration (if you're using that currently), so not this:

logging {
channel ns_log {
file "/var/log/named/named.log" versions 3 size 256M;
severity dynamic;
print-time yes;
print-severity yes;
print-category yes;
};
...
category default { ns_log; };
category general { ns_log; };
category config { ns_log; };
};

But this:

logging {
channel ns_log {
file "/var/log/named/named.log";
severity dynamic;
print-time yes;
print-severity yes;
print-category yes;
};
...
category default { ns_log; };
category general { ns_log; };
category config { ns_log; };
};

Hope this clarifies the idea a little for you.

Stuart

From: bind-users [mailto:bind-users-***@lists.isc.org] On Behalf Of Blason R
Sent: Thursday, 5 July 2018 4:44 PM
To: ***@gmail.com
Cc: bind-users
Subject: Re: Logrotate for bind9

What exactly are those? Well what I wated to achieve here is to rotate the logs daily and start new file; then compress

On Thu, Jul 5, 2018 at 6:21 AM Rohan Henry <***@gmail.com<mailto:***@gmail.com>> wrote:
Why not use Bind logging option?

On Jul 4, 2018 8:51 AM, "Blason R" <***@gmail.com<mailto:***@gmail.com>> wrote:
Hi There,

I am not getting appropriate results for my custom daily logrorate for bind9 logs on Ubuntu.

Can someone please help me with the settings which would include below stuff

1. Should rotate daily
2. Compress
3. create new file
4. keep last 180 entries


Do I need stop bind9 while logs are being rotated? What is the correct procedure to start logs in new file?

_______________________________________________
Please visit https://lists.isc.org/mailman/listinfo/bind-users<https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.isc.org_mailman_listinfo_bind-2Dusers&d=DwMFaQ&c=MOptNlVtIETeDALC_lULrw&r=udvvbouEjrWNUMab5xo_vLbUE6LRGu5fmxLhrDvVJS8&m=x_efXEDdzrHXkr39lk-t7Ive0PUrBu39XyHVKIxYr-c&s=I6mnsNje8UKA-DWyQZnQG_y1ejr_e49gbkmN5JNAZrs&e=> to unsubscribe from this list

bind-users mailing list
bind-***@lists.isc.org<mailto:bind-***@lists.isc.org>
https://lists.isc.org/mailman/listinfo/bind-users<https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.isc.org_mailman_listinfo_bind-2Dusers&d=DwMFaQ&c=MOptNlVtIETeDALC_lULrw&r=udvvbouEjrWNUMab5xo_vLbUE6LRGu5fmxLhrDvVJS8&m=x_efXEDdzrHXkr39lk-t7Ive0PUrBu39XyHVKIxYr-c&s=I6mnsNje8UKA-DWyQZnQG_y1ejr_e49gbkmN5JNAZrs&e=>
Blason R
2018-07-05 11:49:52 UTC
Permalink
Corrext I needed a settings like this; I was trying mulitple options but
wasnt working. Let me try this!!

Thanks for providing the same.
Post by Browne, Stuart via bind-users
How about a clear, direct example of using external service 'logrotate'
(this is from one of my redhat systems, but the same concept applies to
/var/log/named/*.log {
compress
create 0644 named named
daily
dateext
missingok
notifempty
rotate 30
sharedscripts
postrotate
/usr/sbin/rndc reconfig > /dev/null 2>/dev/null || true
endscript
}
We put our logs in the custom location of '/var/log/named/'; if you put
them somewhere else, you'll need to change that. The other settings are
direct references to Anand's email. Finally, you'll want to change the 30
to 180 to keep 180 different days worth of logs.
BIND internally doesn't have the concept based rotation, only size-based
rotation. In order to achieve per-day logs, you'll need to use the external
tool 'logrotate' (or similar) for your rotation. If you do that, you'll
want to disable BIND's rotation in the logs configuration (if you're using
logging {
channel ns_log {
file "/var/log/named/named.log" versions 3 size 256M;
severity dynamic;
print-time yes;
print-severity yes;
print-category yes;
};
...
category default { ns_log; };
category general { ns_log; };
category config { ns_log; };
};
logging {
channel ns_log {
file "/var/log/named/named.log";
severity dynamic;
print-time yes;
print-severity yes;
print-category yes;
};
...
category default { ns_log; };
category general { ns_log; };
category config { ns_log; };
};
Hope this clarifies the idea a little for you.
Stuart
Of *Blason R
*Sent:* Thursday, 5 July 2018 4:44 PM
*Cc:* bind-users
*Subject:* Re: Logrotate for bind9
What exactly are those? Well what I wated to achieve here is to rotate the
logs daily and start new file; then compress
Why not use Bind logging option?
Hi There,
I am not getting appropriate results for my custom daily logrorate for
bind9 logs on Ubuntu.
Can someone please help me with the settings which would include below
stuff
1. Should rotate daily
2. Compress
3. create new file
4. keep last 180 entries
Do I need stop bind9 while logs are being rotated? What is the correct
procedure to start logs in new file?
_______________________________________________
Please visit https://lists.isc.org/mailman/listinfo/bind-users
<https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.isc.org_mailman_listinfo_bind-2Dusers&d=DwMFaQ&c=MOptNlVtIETeDALC_lULrw&r=udvvbouEjrWNUMab5xo_vLbUE6LRGu5fmxLhrDvVJS8&m=x_efXEDdzrHXkr39lk-t7Ive0PUrBu39XyHVKIxYr-c&s=I6mnsNje8UKA-DWyQZnQG_y1ejr_e49gbkmN5JNAZrs&e=>
to unsubscribe from this list
bind-users mailing list
https://lists.isc.org/mailman/listinfo/bind-users
<https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.isc.org_mailman_listinfo_bind-2Dusers&d=DwMFaQ&c=MOptNlVtIETeDALC_lULrw&r=udvvbouEjrWNUMab5xo_vLbUE6LRGu5fmxLhrDvVJS8&m=x_efXEDdzrHXkr39lk-t7Ive0PUrBu39XyHVKIxYr-c&s=I6mnsNje8UKA-DWyQZnQG_y1ejr_e49gbkmN5JNAZrs&e=>
Loading...