setup NTP on ubuntu 14.04 for utc timezone

apt-get install ntp ntpdate

apt-get install ntp ntpdate

cat /etc/ntp.conf
driftfile /var/lib/ntp/ntp.drift
statistics loopstats peerstats clockstats
filegen loopstats file loopstats type day enable
filegen peerstats file peerstats type day enable
filegen clockstats file clockstats type day enable
server 0.ubuntu.pool.ntp.org
server 1.ubuntu.pool.ntp.org
server 2.ubuntu.pool.ntp.org
server 3.ubuntu.pool.ntp.org
server ntp.ubuntu.com
restrict -4 default kod notrap nomodify nopeer noquery
restrict -6 default kod notrap nomodify nopeer noquery
restrict 127.0.0.1
restrict ::1


service ntp restart

service cron stop && service cron start

Check ntp stats
================

#ntpq -pn

-p : Print a list of the peers known to the server as well as a summary of their state.
-n : Output all host addresses in dotted-quad numeric format rather than converting to the canonical host names.


# ntpq -pn

     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*131.107.13.100  .ACTS.           1 u   39   64  377    6.668   -1.887   2.894
+199.101.100.221 130.207.244.240  2 u   12   64  377   89.209   -8.376   1.750
-129.250.35.251  129.250.36.26    2 u   36   64  377   25.029   -8.342   3.061
+129.6.15.28     .ACTS.           1 u   34   64  377   78.681   -4.869  27.612
-91.189.89.199   170.224.124.217  2 u   40   64  377  141.474   -6.736   2.311


watch command linux

 By default watch command runs a command or script for every two seconds by default, we can increase or decrease the interval by using -n option
minimum is 0.1 second

#watch -n 0.1 -t  lsof -i

-t = supresses the time on top of display

postfix header check

https://www.howtoforge.com/community/threads/howto-spam-control-for-postfix.48608/
http://mattshaw.org/news/how-to-filter-mail-with-postfix-header_checks/

https://posluns.com/guides/header-checks/
https://www.howtoforge.com/community/threads/postfix-header-checks.80/

ispconfig3 setup on debian jessie remove default page setting

https://www.howtoforge.com/tutorial/perfect-server-debian-8-jessie-apache-bind-dovecot-ispconfig-3

+ remove /etc/apache2/sites-enabled/000-default..conf
or echo >  /etc/apache2/sites-enabled/000-default..conf

python pip install without cache

From documentation at https://pip.pypa.io/en/latest/reference/pip_install.html#caching:
Starting with v6.0, pip provides an on by default cache which functions similarly to that of a web browser. While the cache is on by default and is designed do the right thing by default you can disable the cache and always access PyPI by utilizing the --no-cache-dir option.

pip install pillow --no-cache-dir













install nethogs on centos 7

I’ve just found that ‘nethogs’, a bandwidth monitoring software is not covered in the EPEL for Centos 7. This is a memo for how to install nethogs on CentOS 7.

1. Install the dependencies necessary.
yum install libpcap-devel -y
2. Download and install the RPM package.
rpm -ivh http://cdn.kanachan.me.uk/dl/rpms/nethogs/nethogs-0.8.0-1.el6.x86_64.rpm

pflogsumm postfix mail log analyzer pflog


yum install perl-Date-Calc

sudo curl -O http://jimsun.linxnet.com/downloads/pflogsumm-1.1.3.tar.gz

tar -xzf pflogsumm-1.1.3.tar.gz

mv pflogsumm-1.1.3 pflogsumm

chmod +x pflogsumm/pflogsumm.pl

perl   /usr/local/pflogsumm/pflogsumm.pl   /var/log/maillog

# generate log summary for yesterday

[root@mail ~]# perl /usr/sbin/pflogsumm -d yesterday /var/log/maillog


To run cronjob for pflogsumm

crontab -e

# send mail log summary at AM 1:00 everyday to root

00 01 * * * perl /usr/sbin/pflogsumm -e -d yesterday /var/log/maillog | mail -s 'Logwatch for Postfix' root

http://jimsun.linxnet.com/postfix_contrib.html

https://www.dropbox.com/s/rkbp13lz4eon988/pflogsumm-1.1.3.tar.gz?dl=0

start a daemon at startup ubuntu

  • To start a daemon at startup:
    update-rc.d service_name defaults
    
  • To remove:
    update-rc.d -f service_name remove
    
defaults => default run levels 2,3,4 and 5
Example:
update-rc.d tomcat7 defaults

difference between use of port 25 465 and 587

port 25 is used for transmitting email between MTA's also known as SMTP relaying.

port 465 is no longer used on ssl-smtp(although port 465 was never published as an official SMTP transmission or submission channel by the IETF ) and IANA has now assigned 465 to new service called "urd".

The RFC proposed a split of the traditional message submission and message relay concept. The RFC defined that message submission should occur over port 587 to ensure new policy and security requirements don't interfere with the traditional relay traffic over message relay port 25.
Port 587 is for msa - it is almost like standard SMTP port. SSL encryption may be started by STARTTLS command at SMTP level if server supports it and your ISP does not filter server's EHLO reply (reported 2014 Nov). MSA should accept email after authentication (e.g. after SMTP AUTH). It helps to stop outgoing spam when netmasters of DUL ranges can block outgoing connections to SMTP port (port 25)

REDHAT CLUSTER part 3 - Adding cluster resources and services

Make sure selinux is disabled or in permissive for testing


Adding cluster resources and services

Cluster SERVICE = 1 or more RESOURCES            

resource are defined within <rm>  </rm> eg.

<rm>
<resources> ...
...
</resources>
</rm>

cluster resources are configured with resource scripts and located at /usr/share/cluster along with cluster resources



[root@c1 cluster]# ls /usr/share/cluster/
apache.metadata                 lvm.metadata          oralistener.metadata
apache.sh                       lvm.sh                oralistener.sh
...
..


On any one node for example im on node 3 edit /etc/cluster/cluster.conf





 [root@c3 cluster]# cat cluster.conf

<?xml version="1.0"?>
<cluster config_version="4" name="hacluster">
    <logging debug="off"/>
    <clusternodes>
        <clusternode name="c1" nodeid="1"/>
        <clusternode name="c2" nodeid="2"/>
        <clusternode name="c3" nodeid="3"/>
    </clusternodes>
    <rm>
        <failoverdomains>
            <failoverdomain name="simple" nofailback="1" ordered="0" restricted="0">
                <failoverdomainnode name="c1"/>
                <failoverdomainnode name="c2"/>
                <failoverdomainnode name="c3"/>
            </failoverdomain>
        </failoverdomains>
        <resources>
            <ip address="192.168.0.88" family="IPv4" prefer_interface="eth1"/>
            <apache config_file="conf/httpd.conf" name="apache" server_root="/etc/httpd" shutdown_wait="60"/>
        </resources>
    </rm>
</cluster>

validate configuration

[root@c3]# ccs_config_validate
Configuration validates

Distribute cluster conf with below command and enter ricci user password for all nodes respectively

[root@c3]# cman_tool version -r
You have not authenticated to the ricci daemon on c3
Password:
You have not authenticated to the ricci daemon on c2
Password:
You have not authenticated to the ricci daemon on c1
Password:

SERVICES

We can configure a web server cluster service with respect to the configured IP address and Apache web server resources with the following CMAN configuration file syntax:
 Make sure to increase config_version here i have number "8"

[root@c1 ~]# ccs_config_dump
<?xml version="1.0"?>
<cluster config_version="8" name="hacluster">
    <logging debug="off"/>
    <clusternodes>
        <clusternode name="c1" nodeid="1"/>
        <clusternode name="c2" nodeid="2"/>
        <clusternode name="c3" nodeid="3"/>
    </clusternodes>
    <rm>
        <failoverdomains>
            <failoverdomain name="simple" nofailback="1" ordered="0" restricted="0">
                <failoverdomainnode name="c1"/>
                <failoverdomainnode name="c2"/>
                <failoverdomainnode name="c3"/>
            </failoverdomain>
        </failoverdomains>
        <resources>
            <ip address="192.168.0.88" family="IPv4" prefer_interface="eth0"/>
            <apache config_file="conf/httpd.conf" name="apache" server_root="/etc/httpd" shutdown_wait="60"/>
        </resources>

        <service autostart="1" name="webserver" recovery="relocate">
            <ip ref="192.168.0.88"/>
            <apache ref="apache"/>
        </service>

    </rm>
    <cman nodename="c1" cluster_id="10117"/>
</cluster>

[root@c3 ~]# clustat
Cluster Status for hacluster @ Fri Aug 28 17:00:32 2015
Member Status: Quorate

 Member Name                             ID   Status
 ------ ----                             ---- ------
 c1                                          1 Online, rgmanager
 c2                                          2 Online, rgmanager
 c3                                          3 Online, Local, rgmanager

 Service Name                   Owner (Last)                   State        
 ------- ----                   ----- ------                   -----        
 service:webserver              c3                             started 

[root@c3 ~]# ip ad | grep inet
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host
    inet 192.168.0.77/24 brd 192.168.0.255 scope global eth0
    inet 192.168.0.88/24 scope global secondary eth0 #virtual ip
    inet6 fe80::a00:27ff:fe2e:2480/64 scope link