Selasa, 25 Agustus 2020

Logrotate sample script to moving old archieve log to directory in different disk

  Tidak ada komentar

Log rotate sample script

/var/log/SoaPlan.err {
    daily
    rotate 28
    missingok
    notifempty
#    olddir /var/log/PaymentRobot
#    compress
    dateext
    compress
#    compresscmd /bin/bzip2
     compresscmd /usr/bin/bzip2
    compressext .bz2
    copytruncate
    sharedscripts
#    postrotate
    lastaction
        day=$(date +%Y%m%d)
        daytime=$(date +%Y%m%d-%H:%M:%S)
        mv SoaPlan.err-$day.bz2 /var/log/soaplan/SoaPlan.err-$daytime.bz2
    endscript
}


Command to compress file using bzip2

How to compress decompress file using bzip2

  Tidak ada komentar

File size before compressed

   0 -rw-------   1 root   root      0 Aug 16 03:12 maillog-20200823
512K -rw-------   1 root   root   287K Aug 26 11:10 messages
211M -rw-------   1 root   root   211M Aug  2 03:28 messages-20200802
225M -rw-------   1 root   root   225M Aug  9 03:46 messages-20200809
200M -rw-------   1 root   root   200M Aug 16 03:12 messages-20200816
164M -rw-------   1 root   root   164M Aug 23 03:10 messages-20200823
3.8M -rw-------   1 root   root   3.8M Aug 26 10:58 messages-20200826.bz2
   0 drwxr-xr-x.  2 root   root    132 Jul 13 16:47 ntopng

Command to compress file using bzip2
[root@loadbalancer12 log]# bzip2 -z messages-20200802
[root@loadbalancer12 log]#

The result of file after compressed
   0 -rw-------   1 root   root      0 Aug 16 03:12 maillog-20200823
512K -rw-------   1 root   root   377K Aug 26 11:13 messages
 10M -rw-------   1 root   root    10M Aug  2 03:28 messages-20200802.bz2
225M -rw-------   1 root   root   225M Aug  9 03:46 messages-20200809
200M -rw-------   1 root   root   200M Aug 16 03:12 messages-20200816
164M -rw-------   1 root   root   164M Aug 23 03:10 messages-20200823
3.8M -rw-------   1 root   root   3.8M Aug 26 10:58 messages-20200826.bz2
   0 drwxr-xr-x.  2 root   root    132 Jul 13 16:47 ntopng


Some files size after compression using bzip2
   0 -rw-------   1 root   root      0 Aug 16 03:12 maillog-20200823
512K -rw-------   1 root   root   455K Aug 26 11:16 messages
 10M -rw-------   1 root   root    10M Aug  2 03:28 messages-20200802.bz2
9.7M -rw-------   1 root   root   9.7M Aug  9 03:46 messages-20200809.bz2
9.0M -rw-------   1 root   root   9.0M Aug 16 03:12 messages-20200816.bz2
7.5M -rw-------   1 root   root   7.5M Aug 23 03:10 messages-20200823.bz2
3.8M -rw-------   1 root   root   3.8M Aug 26 10:58 messages-20200826.bz2
   0 drwxr-xr-x.  2 root   root    132 Jul 13 16:47 ntopng

Command to decompress file that compressed using bzip2
[root@loadbalancer12 log]# bzip2 -d messages-20200802.bz2
[root@loadbalancer12 log]#
File result after decompression
   0 -rw-------   1 root   root      0 Aug 16 03:12 maillog-20200823
512K -rw-------   1 root   root   458K Aug 26 11:16 messages
211M -rw-------   1 root   root   211M Aug  2 03:28 messages-20200802
9.7M -rw-------   1 root   root   9.7M Aug  9 03:46 messages-20200809.bz2
9.0M -rw-------   1 root   root   9.0M Aug 16 03:12 messages-20200816.bz2
7.5M -rw-------   1 root   root   7.5M Aug 23 03:10 messages-20200823.bz2
3.8M -rw-------   1 root   root   3.8M Aug 26 10:58 messages-20200826.bz2
   0 drwxr-xr-x.  2 root   root    132 Jul 13 16:47 ntopng


Jumat, 14 Agustus 2020

How to reset password rootdn Ldap

  Tidak ada komentar

 Export rootdn configuration to file

[root@cognos ~]# ldapsearch -H ldapi:// -LLL -Q -Y EXTERNAL -b "cn=config" "(olcRootDN=*)" dn olcRootDN olcRootPW | tee ~/newpasswd.ldif
dn: olcDatabase={0}config,cn=config
olcRootDN: cn=config
olcRootPW: {SSHA}1g3T4jH5NhFOmIHwLHAinajpXTUlJHyx

dn: olcDatabase={2}bdb,cn=config
olcRootDN: cn=cognos,dc=wachid,dc=com
olcRootPW: {SSHA}FIu/Nv95MMiMH/rEMk4A4cVCGIYKVQ8+

[root@cognos ~]#
Check the exported configuration
[root@cognos ~]# cat newpasswd.ldif
dn: olcDatabase={2}bdb,cn=config
olcRootDN: cn=cognos,dc=wachid,dc=com
olcRootPW: {SSHA}FIu/Nv95MMiMH/rEMk4A4cVCGIYKVQ8+

[root@cognos ~]#
Create new ldap password to exported configuration
[root@cognos ~]# slappasswd -h {SSHA} >> newpasswd.ldif
New password:
Re-enter new password:
[root@cognos ~]#
[root@cognos ~]# vi newpasswd.ldif
[root@cognos ~]#

 Modify the old password using modified exported configuration file

[root@cognos ~]# ldapmodify -H ldapi:// -Y EXTERNAL -f ~/newpasswd.ldif
SASL/EXTERNAL authentication started
SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASL SSF: 0
modifying entry "olcDatabase={2}bdb,cn=config"

[root@cognos ~]#

 Testing the ldap using new password

[root@cognos ~]# ldapsearch -h localhost -b "dc=wachid,dc=com" -D "cn=cognos,dc=wachid,dc=com" -W
Enter LDAP Password:
# extended LDIF
#
# LDAPv3
# base <dc=wachid,dc=com> with scope subtree
# filter: (objectclass=*)
# requesting: ALL
#

# wachid.com
dn: dc=wachid,dc=com
objectClass: dcObject
objectClass: organization
o: wachid.com
dc: wachid

# users, wachid.com
dn: ou=users,dc=wachid,dc=com
objectClass: organizationalUnit
objectClass: top
ou: users

# groups, wachid.com
dn: ou=groups,dc=wachid,dc=com
objectClass: organizationalUnit
objectClass: top
ou: groups

# userwachidgrp, groups, wachid.com
dn: cn=userwachidgrp,ou=groups,dc=wachid,dc=com
objectClass: top
objectClass: posixGroup
gidNumber: 100
cn: userwachidgrp

# userwachid, users, wachid.com
dn: uid=userwachid,ou=users,dc=wachid,dc=com
objectClass: top
objectClass: account
objectClass: posixAccount
objectClass: shadowAccount
cn: menhub
uid: menhub
uidNumber: 16859
gidNumber: 100
homeDirectory: /home/userwachid
loginShell: /bin/bash
gecos: menhub
userPassword:: e1NTSEF9Rkl1L052OTVNTWlNSC9yRU1rNEE0Y1ZDR0lZS1ZROCs=
shadowLastChange: 0
shadowMax: 0
shadowWarning: 0
..
..
# search result
search: 2
result: 0 Success

# numResponses: 14
# numEntries: 13
[root@cognos ~]#