Which one is chosen about Time Server? The NTPD(Network Time Protocol Daemon) will be best choice on Linux platform.
How to do it? The general process is that first install & configure ntpd, then correct the current time/zone on this server, adjust the firewall rule, configure ntpd on server boot, and verify whether the function is normal.
Install NTP via tarball
Prerequisite
To create a new ntp group with a specific groupid by using the groupadd –g 38 ntp command
Compile & Install
To download a recent NTP tarfile from NTP home page http://www.ntp.org/ and extract this compressed package in the /tmp directory by using the tar –zxvf ntp-4.2.6p5.tar.gz command
Set Permission and Parameter
To create a /var/lib/ntp directory next to set the directory permission to 755 by using the chmod 755 /var/lib/ntp command and change the UIG:GID for /var/lib/ntp to ntp:ntp by using the chown –v ntp:ntp /var/lib/ntp command
To create a /etc/sysconfig/ntpd directory and add some parameters for passing argument to the ntpd daemon at boot time.
To create a /etc/ntp/crypto directory, the /etc/ntp/crypto/pw & /etc/ntp/keys file and change the owner & permission to this directory
Install NTP via yum
To install ntpd by using the yum install ntp command
Configure NTP via tarball or yum
After finish the above one installation, we have to modify or add the /etc/ntp.conf file based on our environment by using vi /etc/ntp.conf command. (# 2)
The following expression is different result before- and after- modify the ntp.conf file.
AS-IS
Adjust iptables for NTP
To add a firewall rule by using the iptables command that will open the UDP port 123 for allowing this NTP server communicate with the internal client and external time server.
The following expression is different result before- and after- do the iptables command.
AS-IS
Start NTP automatically
If the ntp is installed via tarball, we need to create a /etc/init.d/ntpd file and add some content as follows next to set this file permission to 755
If the ntp is installed via yum,we can update chkconfig by executing the chkconfig - - level 235 on command so that the ntp will start automatically on the system startup.
Start NTP manually
If the ntp is installed via tarball, we can start this daemon by using the /etc/init.d/ntpd start command
If the ntp is installed via yum,we can start it by using the /etc/init.d/ntpd start or service ntpd start command
Verify NTP mechanism
To realize whether the ntp daemon is running now by using the service ntpd status command.
Until now, we have already finish NTP daemon setup and installation.
Reference :
(# 1) If execute configure command without the - - enable-clockctl parameter, we will get the error when start ntpd daemon.
(# 2) If we want to configure NTP time server in /etc/ntp.conf, maybe we can refer to the NTP Pool Project Web Site and choose the neighboring time server as Asia for us.
(# 3) If it have no a NTP drift file after time correction, we have to create a drift file manually by using the echo 0 > /var/lib/ntp/drift command