大数据项目之_15_帮助文档_NTP 配置时间服务器+Linux 集群服务群起脚本+CentOS6.8 升级到 python 到 2.7
一、NTP 配置时间服务器1.1、检查当前系统时区1.2、同步时间1.3、检查软件包1.4、修改 ntp 配置文件1.5、重启 ntp 服务1.6、设置定时同步任务二、Linux 集群服务群起脚本2.1、介绍2.2、编写脚本三、CentOS6.8 升级到 python 到 2.73.1、环境准备3.2、安装 Python2.7
一、NTP 配置时间服务器
当集群中各个节点的时间不同步,误差超过某个范围时,会导致一些集群的服务无法正常进行,这时我们应该想办法做一个定时同步集群所有节点时间的任务。
1.1、检查当前系统时区
选择某台机器,作为集群中时间服务器的主节点,然后其他机器同步该机器的时间即可。但是在开始这步操作之前,我们需要确保所有节点的时区是统一的:
# date -R
显示类似如下格式:
Sat, 07 Oct 2017 12:44:58 +0800
尖叫提示:如果显示的时区不是+0800,你可以删除localtime文件夹后,再关联一个正确时区的软链接过去:
# rm -rf /etc/localtime
# ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
1.2、同步时间
如果怀疑自己本地机器的时间与标准时间相差很多,建议使用时间服务器的主节点同步一下网络时间:
# ntpdate pool.ntp.org
1.3、检查软件包
1) 后边我们要使用 ntp 服务,所以在使用该服务之前,建议检查一下 ntp 服务是否正确安装
# rpm -qa | grep ntp
显示如下:
ntp-4.2.6p5-10.el6.centos.x86_64
fontpackages-filesystem-1.41-1.1.el6.noarch
ntpdate-4.2.6p5-10.el6.centos.x86_64
2) 如果没有 ntp 服务,可使用 yum 命令进行安装
# yum -y install ntp
1.4、修改 ntp 配置文件
我们需要修改 ntp 服务的配置文件,关闭网络时间的同步:
# vim /etc/ntp.conf
对如下内容做出修改:
# Hosts on local network are less restricted.
# 授权192.168.25.0网段上的所有机器可以从这台机器上查询和同步时间
restrict 192.168.25.0 mask 255.255.255.0 nomodify notrap
# 当该节点丢失网络连接,依然可以作为时间服务器为集群中的其他节点提供时间同步
server 127.127.1.0
fudge 127.127.1.0 stratum 10
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#集群在局域网中,不使用其他的网络时间
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
尖叫提示:
nomodify:客户端不能使用 ntpc 与 ntpq 修改服务器的时间参数
notrap:不提供 trap 远程时间登录的功能
1.5、重启 ntp 服务
CentOS6:
# service ntpd restart
# chkconfig ntpd on
CentOS7:
# systemctl restart ntpd.service
# systemctl enable ntpd.service
1.6、设置定时同步任务
1) 首先在其他节点上关闭 ntp 服务
CentOS6:
# service ntpd stop
# chkconfig ntpd off
CentOS7:
# systemctl stop ntpd.service
# systemctl disable ntpd.service
查看 ntp 进程 id:
# pgrep ntpd
2) 其他节点手动同步第一台时间服务器的时间进行测试
# ntpdate hadoop102
3) 其他节点制定计划任务,周期性同步时间
# crontab -e
# .------------------------------------------minute(0~59)
# | .----------------------------------------hours(0~23)
# | | .--------------------------------------day of month(1~31)
# | | | .------------------------------------month(1~12)
# | | | | .----------------------------------day of week(0~6)
# | | | | | .--------------------------------command
# | | | | | |
# | | | | | |
*/10 * * * * /usr/sbin/ntpdate hadoop102
4) 重启定时任务
CentOS6:
# service crond restart
CentOS7:
# systemctl restart crond.service
5) 查看任务
# crontab -l
二、Linux 集群服务群起脚本
2.1、介绍
写这个脚本,纯粹是为了偷懒,方便,不然用 linux 干嘛?
目的:在一台服务器上执行一个脚本,启动所有集群节点上的相关进程。
描述:Resourcemanager、HMaster 和 Zookeeper 等节点可能需要登录到节点所在机器启动。
在开始之前呢,我们先了解一些概念:
登录 Shell:粗放来讲,就是你手动使用 CRT 登录 Linux 的时候。此种情形,系统环境信息的读取顺序:/etc/profile、~/.bash_profile、~/.bash_login、~/.profile
非登录Shell:粗放来讲,就是你使用 ssh 登录某台机器的时候。此种情形,系统环境信息的读取顺序:/etc/bash.bashrc、~/.bashrc
解决方案:了解完 Shell 这个小知识之后,你应该明白 ssh 到远程节点启动的对应服务的时候,其实是没有 JDK 配置的环境的,所以,在每台机器中先执行:
$ cat /etc/profile >> ~/.bashrc
将我们配置的 profile 变量追加到 .bashrc 中即可。
2.2、编写脚本
1) 启动脚本:start-cluster.sh
#!/bin/bash
echo "================ 开始启动所有节点服务 ==========="
echo "================ 正在启动 Zookeeper ==========="
for i in atguigu@hadoop102 atguigu@hadoop103 atguigu@hadoop104
do
ssh $i 'source /etc/profile;/opt/module/zookeeper-3.4.10/bin/zkServer.sh start'
done
echo "================ 正在启动 HDFS ==========="
ssh atguigu@hadoop102 '/opt/module/hadoop-2.7.2/sbin/start-dfs.sh'
echo "================ 正在启动 YARN ==========="
ssh atguigu@hadoop103 '/opt/module/hadoop-2.7.2/sbin/start-yarn.sh'
echo "================ hadoop102 节点正在启动 JobHistoryServer ==========="
ssh atguigu@hadoop102 '/opt/module/hadoop-2.7.2/sbin/mr-jobhistory-daemon.sh start historyserver'
2) 停止脚本:stop-cluster.sh
#!/bin/bash
echo "================ 开始停止所有节点服务 ==========="
echo "================ hadoop102 节点正在停止 JobHistoryServer ==========="
ssh atguigu@hadoop102 '/opt/module/hadoop-2.7.2/sbin/mr-jobhistory-daemon.sh stop historyserver'
echo "================ 正在停止 YARN ==========="
ssh atguigu@hadoop103 '/opt/module/hadoop-2.7.2/sbin/stop-yarn.sh'
echo "================ 正在停止 HDFS ==========="
ssh atguigu@hadoop102 '/opt/module/hadoop-2.7.2/sbin/stop-dfs.sh'
echo "================ 正在停止 Zookeeper ==========="
for i in atguigu@hadoop102 atguigu@hadoop103 atguigu@hadoop104
do
ssh $i 'source /etc/profile;/opt/module/zookeeper-3.4.10/bin/zkServer.sh stop'
done
3) 查看进程脚本:util.sh
#!/bin/bash
for i in atguigu@hadoop102 atguigu@hadoop103 atguigu@hadoop104
do
echo "================ $i 的所有进程 ==========="
ssh $i '/opt/module/jdk1.8.0_144/bin/jps'
done
尖叫提示:脚本学会之后,如果后续再有新的节点需要添加到群起任务中,可以自行解决之。尖叫提示:启动与停止注意脚本的执行顺序,而且停止脚本的停止过程应该是启动过程的倒序。
三、CentOS6.8 升级到 python 到 2.7
由于 HUE 框架依赖 python2.7,而 CentOS7 以下的系统使用的都是 python2.6,并且 CentOS6.8 的 yum 也是依赖 2.6,所以升级过程会稍微繁琐,特此予以讲解。
3.1、环境准备
1) 查看 python 版本
# python –v
2) 安装 GCC 与 wget,用于编译源码包与资源下载
# yum install gcc gcc-c++
# yum install wget
3) 安装 xz 工具,用于解压 tar.xz 格式文件
# wget http://down1.chinaunix.net/distfiles/xz-5.0.3.tar.bz2
# cd xz-5.0.3
# ./configure
# make
# make install
3.2、安装 Python2.7
1) 下载解压 Python 安装包
# wget https://www.python.org/ftp/python/2.7.11/Python-2.7.11.tar.xz
# xz -d Python-2.7.11.tar.xz
# tar -xf Python-2.7.11.tar
2) 编译安装 python
# cd Python-2.7.11
# ./configure
# make
# make install
3) 将系统指向的 python 从 2.6 修改到 2.7 版本
# /usr/local/bin/python2.7 -V
# mv /usr/bin/python /usr/bin/python.bak
# ln -s /usr/local/bin/python2.7 /usr/bin/python
4) 将 yum 对 python 的引用重新指向 python2.6 (即:yum 使用 2.6,系统用 2.7)
# vi /usr/bin/yum
修改:
!/usr/bin/python
改为:
!/usr/bin/python2.6
5) 检查 python 版本,检查 yum 是否可用
# python -V
大数据项目之_15_帮助文档_NTP 配置时间服务器+Linux 集群服务群起脚本+CentOS6.8 升级到 python 到 2.7的更多相关文章
- Apache DolphinScheduler 使用文档(2-3/8):集群规划及环境准备
本文章经授权转载,原文链接: https://blog.csdn.net/MiaoSO/article/details/104770720 目录 2. 集群规划 2.1 集群配置 2.2 软件版本 2 ...
- 大数据项目之_15_电信客服分析平台_01&02_项目背景+项目架构+项目实现+数据生产+数据采集/消费(存储)
一.项目背景二.项目架构三.项目实现3.1.数据生产3.1.1.数据结构3.1.2.编写代码3.1.3.打包测试3.2.数据采集/消费(存储)3.2.1.数据采集:采集实时产生的数据到 kafka 集 ...
- 大数据项目之_15_电信客服分析平台_03&04_数据分析
3.3.数据分析3.3.1.Mysql 表结构设计3.3.2.需求:按照不同的维度统计通话3.3.3.环境准备3.3.4.编写代码:数据分析3.3.5.运行测试3.3.6.bug 解决 3.3.数据分 ...
- python3如何随机生成大数据存储到指定excel文档里
本次主要采用的是python3的第三方库xlwt,来创建一个excel文件.具体步骤如下: 1.确认存储位置,文件命名跟随时间格式 2.封装写入格式 3.实现随机数列生成 4.定位行和列把随机数写入 ...
- Cobar使用文档(可用作MySQL大型集群解决方案)
原文:http://my.oschina.net/ydsakyclguozi/blog/374564 最近好不容易抽空研究了下Cobar,感觉这个产品确实很不错(在文档方面比Amoeba强多了),特此 ...
- 转 Cobar使用文档(可用作MySQL大型集群解决方案)
转自:http://blog.csdn.net/shagoo/article/details/8191346 最近好不容易抽空研究了下Cobar,感觉这个产品确实很不错(在文档方面比Amoeba强多了 ...
- 分布式文档存储数据库之MongoDB分片集群
前文我们聊到了mongodb的副本集以及配置副本集,回顾请参考https://www.cnblogs.com/qiuhom-1874/p/13953598.html:今天我们来聊下mongodb的分片 ...
- Cassandra1.2文档学习(7)—— 规划集群部署
数据参考:http://www.datastax.com/documentation/cassandra/1.2/webhelp/index.html#cassandra/architecture/a ...
- ServiceFabric极简文档-1.0 Service Fabric 自定义集群部署
Service Fabric 部署集群:https://docs.microsoft.com/zh-cn/azure/service-fabric/service-fabric-get-started ...
随机推荐
- MT【314】正切比值
(05复旦)已知三角形$\Delta ABC$满足$\tan A:\tan B:\tan C=1:2:3$,求$\dfrac{AC}{AB}$____ 解答:设$x=tan A$,利用恒等式$\tan ...
- poj 2955 Brackets (区间dp 括号匹配)
Description We give the following inductive definition of a “regular brackets” sequence: the empty s ...
- 洛谷P1233 木棍加工题解 LIS
突然发现自己把原来学的LIS都忘完了,正好碰见这一道题.|-_-| \(LIS\),也就是最长上升子序列,也就是序列中元素严格单调递增,这个东西有\(n^{2}\)和\(nlog_{2}n\)两种算法 ...
- PMP备考资料和备考经验分享(基于PMP第六版)
之前有不少小伙伴私信我说,你PMP考过了,有没有报班呢,有没有自己看的资料,有没有一些经验分享,今天在这里,就统一给大家分享一下,以便大家备考和学习PMP. 先说我自己的情况,我本身是从事项目管理的, ...
- 动态SQL之、条件判断(转)
错误方式一: 在mybatis的动态sql语句中使用<if>标签可以判断sql中的条件是否成立. <select id="getPerson" resultTyp ...
- Redis的Cluster配置
Redis的Cluster配置 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.安装Redis并启动 1>.修改Redis的配置文件(本实验只有三个节点) [root@no ...
- C++回顾day03---<多态>
一:错误理解下的多态 #include <iostream> using namespace std; class Parent { public: Parent() { cout < ...
- [再寄小读者之数学篇](2014-06-27 向量公式: The Hall term)
$$\bex \n\cdot{\bf b}=0\ra \n\times [(\n\times {\bf b})\times {\bf b}]=\n\times [\n\cdot ({\bf b}\ot ...
- LINUX涉及网络相关知识
才接触到网络的老铁,是否比较晕呢? 简单记录一下网络相关知识吧(IPV4)! A0. 网络号.主机号 A1.网络地址分类: A2. 保留地址: A3. 子网掩码作用:(子网掩码.IPV4地址做“与”运 ...
- js将时间戳转换为日期类型
function getLocalTime(nS) { var date = new Date(nS); Y = date.getFullYear() + '年'; M = ( ...