網頁

2013年9月21日 星期六

NTP --- Install & Configure NTP daemon on Minimal CentOS 6.x

The time correction is very important on any systems as tracking log between servers, business data flow, Kerberos authentication and so on. For this reason, I will build a internal time server as bridgehead to synchronize the time between servers and clients.
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 commandScreenShot006To create a new ntp user with specific userid by using the useradd –d /etc/ntp –u 38 –g ntp –s /sbin/nologin ntp commandScreenShot007To install the Development tools for compiling any application by using the yum groupinstall “Development tools” commandScreenShot003
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 commandScreenHunter_01So does that the ntp source tree will be created. To switch to the distribution base directory for making this software.ScreenHunter_03To configure sources for performing an automatic configuration procedure that inspect the hardware & software environment and configure the build process by using ./configure - -prefix=/usr - -sysconfdir=/etc - -with-binsubdir=sbin - -with-lineeditlibs=readline - - enable-clockctl command (# 1)ScreenShot016ScreenHunter_14To compile and link the distribution sources by using make commandScreenShot005ScreenHunter_10To install ntp by using make install command so that the executable file by default is in the /usr/local/bin directoryScreenHunter_15ScreenHunter_11
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 commandScreenShot011To change the /var/run/ntpd.pid UIG:GID to ntp:ntp by using the chown ntp:ntp /var/run/ntpd.pid command
To create a /etc/sysconfig/ntpd directory and add some parameters for passing argument to the ntpd daemon at boot time.ScreenShot012
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 commandScreenShot003ScreenShot004
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-ISScreenShot005TO-BEScreenShot015

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.ScreenShot017ScreenShot018Due to the above command just temporarily store in memory, we have to execute the service iptables save command that avoid the new rule miss after the system reboot. For applying the new rule, we will restart iptables daemon by using the service iptables restart command.ScreenShot019
The following expression is different result before- and after- do the iptables command.
AS-ISScreenShot005TO-BEScreenShot020

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 755ScreenShot014/etc/init.d/ntpdScreenShot018ScreenShot019To set ntp daemon to auto start on boot by using the chkconfig ntpd on commandScreenShot001
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.ScreenShot011
Start NTP manually
If the ntp is installed via tarball, we can start this daemon by using the /etc/init.d/ntpd start commandScreenShot017
If the ntp is installed via yum,we can start it by using the /etc/init.d/ntpd start or service ntpd start commandScreenShot005

Verify NTP mechanism
To realize whether the ntp daemon is running now by using the service ntpd status command.ScreenShot020To confirm whether the system clock can synchronize the outside time server by using the ntpstat command.ScreenShot017To realize the relationship between the ntp and up time server by using the ntpd –p command. (# 3)
ScreenShot018To realize whether the UDP port 123 is listening now by using the netstat –unlnp | grep 123 commandScreenShot014
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.ScreenShot015
(# 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.ScreenHunter_07To choose the neighbor zone as TaiwanScreenHunter_03So does that we can add the pool zone to the /etc/ntp.conf fileScreenHunter_04
(# 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 commandScreenShot004and change the UIG:GID to ntp:ntp by using the chown ntp:ntp /var/lib/ntp/drift commandScreenShot005

2013年8月21日 星期三

VMware Workstation Pro 12.x --- Install VMware Tool on CentOS 6.3 x64 or 6.7 x64 minimal version

In the VMware product as Workstation or vSphere, it will be very important that install VMware Tools on any VM Guest for enhancing/improving some function as graphic display and performance, drag and drop operation, shared folder and so on.
How to install VMware Tools on CentOS?
It will be very simple operation if do the related steps as follows:

After power on the VM Guest, we have to click VM –> Install VMware Tools.. in this VM Guest menu.ScreenHunter_02So does that the VMware Tools will be mounted by CDROM device now.

In the next step, we need to create a mount point by executing the command mkdir /mnt/cdrom next to mount this CDROM by doing the command mount /dev/cdrom /mnt/cdromScreenHunter_03Now the system can read-only the CDROM data. In the moment, we will extract the VMware Tools from CDROM to the folder of local disk by using the command tar zxpf /mnt/cdrom/VMwareTools…ScreenHunter_04So does that the VMware Tool source will be accessed now.

To switch to VMware Tool directory as vmware-tools-distrib and execute the command ./vmware-install.pl for installing VMware Tools. (# 1) In the later procedure, we always press Return/Enter key to choose the default setting or configuration.ScreenHunter_05ScreenHunter_06ScreenHunter_07ScreenHunter_08ScreenHunter_10When the above process is successful and never show the warning/error message, we will reboot the system so that the VMware Tools will embed into the Kernel now. (# 2)

To verify the status of VMware Tools by using status vmware-tools command

Reference :
(# 1)   Before execute vmware-install.pl in the CentOS minimal version, please firstly confirm whether ever install gcc、perl、fuse-libs package in the procedure of OS installation.

(# 2)   If update the Kernel or there is new VMware tool version, we have to install VMware Tools again by the above procedure except for uninstalling old version firstly.

2013年8月18日 星期日

Squid 3.1 --- Install and start with basic configuration

As we know, Squid is a public proxy server in open source environment. If use it, we can easy to cache and filter web content for reusing it for the same request in the future. For realizing its function, I will build a lab for testing it. At first, we have to know how to install this package.

Squid InstallationBy doing yum install squid command, we can quickly and easily install the squid package and its dependencies from the yum repositories.ScreenHunter_17ScreenHunter_18So does that the Squid package will be installed nowScreenHunter_28
Squid ConfigurationAfter installing Squid package, there is recommended minimum configuration that exists in the /etc/squid/squid.conf file and it can work finely without changing anything. Of course,we can correct some parameter in this default setting for conforming with the actual environment.(# 1)
After changing the configuration, we can do the command /usr/sbin/squid –f /etc/squid/squid.conf –k parse to verify whether the configuration syntax is wrong or incorrect. (# 2)ScreenHunter_20When the prerequisite is ready, we will begin to start squid daemon. For starting it in the first time, we need to do the command /usr/sbin/squid –z to create the swap directories.ScreenHunter_21and uncomment the cache_dir directories in the /etc/squid/squid.conf file (# 3)ScreenHunter_23next to start squid daemon by executing the command service squid start. So do that the Cache directories will be created in the /var/spool/squid path.ScreenHunter_24For starting Squid daemon automatically when system boots, we need to type the command chkconfig –levels 235 squid on if we need it.ScreenHunter_22
Squid function verification
After start squid daemon, we can do something to verify whether its function is normal now.
<In Server>
To confirm whether the default listening port 3128 is opened by executing the command netstat –tnl | grep 3128 if we don’t change the http_port in squid configuration.ScreenHunter_30<In Client>
In the moment, we can try to ping & telnet this squid proxy to realize whether network channel is normal between Squid Server and Client machine. ScreenHunter_25If it is normal, we need to change proxy setting in any Browsers as IE or Firefox. That is proxy server sets the squid hostname or IP and port sets squid port number as 3128.ScreenHunter_24So do that we can normally explore Internet now.ScreenHunter_26
Reference
(# 1).  Squid configuration directives
(# 2). Although I ever set hostname in the file /etc/sysconfig/network, it still has warning message “hostname rDNS test failed; Could not determine this machine public hostname” by executing the command /usr/sbin/squid –f /etc/squid/squid.conf –k parse ScreenHunter_01This problem is resolved until I add a record IP mapping FQDN into /etc/hostsScreenHunter_02or add a record visible_hostname 10.10.101.254 into the file /etc/squid/squid.confScreenHunter_03(# 3) When we execute the command /usr/sbin/squid –NCd1, the warning message tell us that cache_mem is larger than total disk cache space now.ScreenHunter_26So we change cache space from 100MB to 1024MB because cache_mem define 256 MB manually.
ScreenHunter_28
Since 2010 Design by Davidwa
©Copyright Davidwa Inc. All rights reserved.