標籤:
一、yum源配置
1,進入yum源配置目錄
cd /etc/yum.repos.d
2,備份系統內建的yum源
mv CentOS-Base.repo CentOS-Base.repo.bk
下載163網易的yum源:
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
3,更新玩yum源後,執行下邊命令更新yum配置,使操作立即生效
yum makecache
yum list測試加緩衝更新
4,除了網易之外,國內還有其他不錯的yum源,比如中科大和搜狐的,大家可以根據自己需求下載
中科大的yum源:
wget http://centos.ustc.edu.cn/CentOS-Base.repo
sohu的yum源
wget http://mirrors.sohu.com/help/CentOS-Base-sohu.repo
阿里yum源
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
二、更新系統時間 net
一,用ntpdate從時間伺服器更新時間
如果你的linux系統根本沒有ntpdate這個命令
yum install ntp -y
安裝完了之後,你不要做什麼配置,也不需要,直接測試一下
[[email protected] ~]# ntpdate time.nist.gov 22 Oct 21:11:43 ntpdate[5014]: adjust time server 207.200.81.113 offset -0.018788 sec
如果出去上面的內容說明,同步成功了。然後在crontab裡面加上以下內容。
*/10 * * * * ntpdate time.nist.gov #網域名稱或IP
每隔十分鐘同步一次。推薦幾個時間伺服器。
time.nist.gov
time.nuri.net
asia.pool.ntp.org
asia.pool.ntp.org
asia.pool.ntp.org
asia.pool.ntp.org
二,用ntp搭建自己的時間伺服器
上面我們是利用別人的時間伺服器來同步時間,這些時間伺服器都是比較權威的。當我們自己搭建時間伺服器就不用crontab來定時去跑。
1,安裝時間伺服器ntp
yum install ntp
2,配置ntp
查看複製列印?
[[email protected] ~]# cat /etc/ntp.conf |awk ‘{if($0 !~ /^$/ && $0 !~ /^#/) {print $0}}‘restrict default ignore //預設不允許修改或者查詢ntp,並且不接收特殊封包restrict 127.0.0.1 //給於本機所有許可權restrict 192.168.1.0 mask 255.255.255.0 notrap nomodify //給於區域網路機的機器有同步時間的許可權server time.nist.gov prefer //設定時間伺服器,加prefer表示優先server 0.asia.pool.ntp.org server 1.asia.pool.ntp.org server 2.asia.pool.ntp.org server 127.127.1.0 # local clock fudge 127.127.1.0 stratum 10 driftfile /var/lib/ntp/drift keys /etc/ntp/keys
3,啟動 ntp
[[email protected] ~]# /etc/init.d/ntpd start
4,查看並測試
[[email protected] ~]# netstat -upnl |grep ntpd //查看時程[[email protected] ~]# ntpq -pn //查看同步的伺服器IP remote refid st t when poll reach delay offset jitter ============================================================================== 50.77.217.185 .INIT. 16 u - 64 0 0.000 0.000 0.000 202.90.158.4 .INIT. 16 u - 64 0 0.000 0.000 0.000 202.71.100.89 .INIT. 16 u - 64 0 0.000 0.000 0.000 202.134.1.10 .INIT. 16 u - 64 0 0.000 0.000 0.000 *127.127.1.0 .LOCL. 10 l 18 64 377 0.000 0.000 0.001 [[email protected] ~]# ntpstat //同步的結果synchronised to local net at stratum 11 time correct to within 12 ms polling server every 512 s
remote:即NTP主機的IP或主機名稱。注意最左邊的符號,如果由“+”則代表目前正在作用鐘的上層NTP,如果是“*”則表示也有連上線,不過是作為次要聯機的NTP主機。
refid:參考的上一層NTP主機的地址
st:即stratum階層
when:幾秒前曾做過時間同步更新的操作
poll:下次更新在幾秒之後
reach:已經向上層NTP伺服器要求更新的次數
delay:網路傳輸過程鐘延遲的時間
offset:時間補償的結果
jitter:Linux系統時間與BIOS硬體時間的差異時間
推薦第一種方法,雖然搭建個時間伺服器,還是比較簡單的,但是我覺得沒有這個必要。如果用別人的時間伺服器,每隔10分鐘同步一次,可以精確到毫秒。
作者:海底蒼鷹
地址:http://blog.51yip.com/server/1474.html
CentOS和RedHat等系列系統 yum源配置、時間同步