NTP时间同步设置
2016-01-08 12:20
639 查看
服务器端:
apt-get install ntp
vi ./etc/ntp.conf
127.127.1.0 表示ntp本机ip
打开防火墙123端口
iptables -t filter -A INPUT -p udp --destination-port 123 -j ACCEPT
重启服务
service ntp restart
客户端
apt-get install ntp
vi /etc/ntp.conf
其中10.0.0.20 是服务器的内网IP
ntpdate 10.0.0.20 可时间同步
或者启动服务service ntp restart
ntpq -p
date查看时间是否同步。
遇到的问题。客户机上时间一直不同步,后来发现是时区的问题。
使用tzselect修改时区报错。
$tzselect
选择时区,这里选择5,13,1 然后查看date没变。
如果报错
/usr/bin/tzselect: line 171: /home/test/iso3166.tab: No such file or directory
/usr/bin/tzselect: time zone files are not set up correctly
参考http://www.ithao123.cn/content-7792857.html修改成功。
vim / usr/bin/select
把${TZDIR=`pwd`} 修改为: ${TZDIR=/usr/share/zoneinfo}
vi .profile
添加 TZ='Asia/Hong_Kong'; export TZ
然后soucre .profile
再date 查看修改成功。
修改系统时间 date -s 12:34:56
apt-get install ntp
vi ./etc/ntp.conf
# Use Ubuntu's ntp server as a fallback. <span style="color:#3333ff;">server 127.127.1.0 ibusrt</span> # Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for # details. The web page <http://support.ntp.org/bin/view/Support/AccessRestrictions> # might also be helpful. # # Note that "restrict" applies to both servers and clients, so a configuration # that might be intended to block requests from certain clients could also end # up blocking replies from your own upstream servers. # By default, exchange time with everybody, but don't allow configuration. restrict -4 default kod notrap nomodify restrict -6 default kod notrap nomodify # Local users may interrogate the ntp server more closely. restrict 127.0.0.1 restrict ::1
127.127.1.0 表示ntp本机ip
打开防火墙123端口
iptables -t filter -A INPUT -p udp --destination-port 123 -j ACCEPT
重启服务
service ntp restart
客户端
apt-get install ntp
vi /etc/ntp.conf
# Use Ubuntu's ntp server as a fallback. <span style="color:#3333ff;">server 10.0.0.20 iburst</span> # Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for # details. The web page <http://support.ntp.org/bin/view/Support/AccessRestrictions> # might also be helpful. # # Note that "restrict" applies to both servers and clients, so a configuration # that might be intended to block requests from certain clients could also end # up blocking replies from your own upstream servers. # By default, exchange time with everybody, but don't allow configuration. restrict -4 default kod notrap nomodify restrict -6 default kod notrap nomodify # Local users may interrogate the ntp server more closely. restrict 127.0.0.1 restrict ::1
其中10.0.0.20 是服务器的内网IP
ntpdate 10.0.0.20 可时间同步
或者启动服务service ntp restart
ntpq -p
date查看时间是否同步。
遇到的问题。客户机上时间一直不同步,后来发现是时区的问题。
使用tzselect修改时区报错。
$tzselect
选择时区,这里选择5,13,1 然后查看date没变。
如果报错
/usr/bin/tzselect: line 171: /home/test/iso3166.tab: No such file or directory
/usr/bin/tzselect: time zone files are not set up correctly
参考http://www.ithao123.cn/content-7792857.html修改成功。
vim / usr/bin/select
把${TZDIR=`pwd`} 修改为: ${TZDIR=/usr/share/zoneinfo}
vi .profile
添加 TZ='Asia/Hong_Kong'; export TZ
然后soucre .profile
再date 查看修改成功。
修改系统时间 date -s 12:34:56
相关文章推荐
- (转)深入理解PHP之数组(遍历顺序)
- PHPExcel 常用方法
- php实现MVC框架的简单实例
- ThinkPHP 静态缓存 实现商品详情页PC版、手机版静态+SEO优化(未完待续。。。)
- PHP数据类型转换(字符转数字,数字转字符)
- PHP PDO load data 错误
- PHP使用数组依次替换字符串中匹配项
- composer生成一个项目,然后再yii2中下载并安装
- php+croppic 图片裁剪,可缩放、旋转
- php常用命令大全
- php+MYSQL判断表是否存在,不存在创建最简单的方法
- php date 输出指定时间
- php 实现图片批量下载的方法
- #学习笔记#(21)php+mysql分页
- php获取当月天数及当月第一天及最后一天、上月第一天及最后一天实现方法
- PHP 之 compact extract list
- php 解析xml 的四种方法
- 史上最佳 Mac+PhpStorm+XAMPP+Xdebug 集成开发和断点调试环境的配置
- php判断搜索引擎是否蜘蛛
- php获取客户端真实IP