105-BigData-33NTP时间同步服务器和MySql安装

上一篇:104-BigData-32cdh

一、部署NTP时间同步服务器

1、查看集群服务器的Linux版本,确保相同

[root@cdh1 ~]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)

2、查看服务器是否安装ntp服务(集群的每个节点)

[root@cdh1 ~]# rpm -qa | grep ntp
fontpackages-filesystem-1.44-8.el7.noarch
ntpdate-4.2.6p5-29.el7.centos.x86_64
ntp-4.2.6p5-29.el7.centos.x86_64

3、如果没有安装使用以下命令安装(集群每个节点)

[root@cdh1 ~]# yum install ntp ntpdate -y

4、查看NTP服务的状态(集群每个节点)

[root@cdh1 ~]# systemctl status ntpd.service
● ntpd.service - Network Time Service
   Loaded: loaded (/usr/lib/systemd/system/ntpd.service; disabled; vendor preset: disabled)
   Active: inactive (dead)

5、修改NTP服务器的机器的配置文件,我的是cdh1机器是服务器

[root@cdh1 ~]# vi /etc/ntp.conf
#找到如下内容注释掉
# 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
#添加以下内容,同步本地时间
server 127.127.1.0 iburst

6、启动cdh1节点的NTP服务

[root@cdh1 ~]# systemctl start ntpd.service

7、设置cdh1节点NTP开机启动

[root@cdh1 ~]# systemctl enable ntpd.service

8、在cdh1查看NTP状态

[root@cdh1 ~]# systemctl status ntpd.service
● ntpd.service - Network Time Service
   Loaded: loaded (/usr/lib/systemd/system/ntpd.service; enabled; vendor preset: disabled)
   Active: active (running) since Sat 2019-09-28 21:17:35 CST; 2min 10s ago
 Main PID: 72322 (ntpd)
   CGroup: /system.slice/ntpd.service
           └─72322 /usr/sbin/ntpd -u ntp:ntp -g

Sep 28 21:17:35 cdh1 ntpd[72322]: Listen normally on 2 lo 127.0.0.1 UDP 123
Sep 28 21:17:35 cdh1 ntpd[72322]: Listen normally on 3 eno16777736 192.168.20.134 UDP 123
Sep 28 21:17:35 cdh1 ntpd[72322]: Listen normally on 4 lo ::1 UDP 123
Sep 28 21:17:35 cdh1 ntpd[72322]: Listen normally on 5 eno16777736 fe80::20c:29ff:fe45:70d1 UDP 123
Sep 28 21:17:35 cdh1 ntpd[72322]: Listening on routing socket on fd #22 for interface updates
Sep 28 21:17:35 cdh1 ntpd[72322]: 0.0.0.0 c016 06 restart
Sep 28 21:17:35 cdh1 ntpd[72322]: 0.0.0.0 c012 02 freq_set kernel 0.000 PPM
Sep 28 21:17:35 cdh1 ntpd[72322]: 0.0.0.0 c011 01 freq_not_set
Sep 28 21:17:35 cdh1 systemd[1]: Started Network Time Service.
Sep 28 21:17:36 cdh1 ntpd[72322]: 0.0.0.0 c514 04 freq_mode

9、cdh1节点查看是否同步:关闭防火墙或者开放123端口

[root@cdh1 ~]# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*LOCAL(0)        .LOCL.           5 l   47   64    7    0.000    0.000   0.000

10、配置客户机的NTP服务,修改配置文件

#注释其他上游服务器
#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

#配置上游时间服务器为本地的ntpd Server服务器
server 192.168.20.134
#配置允许上游时间服务器主动修改本机的时间
restrict 192.168.20.134 nomodify notrap noquery

11、将客户机的时间与服务器的同步下

[root@cdh2 ~]# ntpdate -u 192.168.20.134
28 Sep 21:29:49 ntpdate[99848]: step time server 192.168.20.134 offset 18.103932 sec

12、启动客户端的NTP服务&配置开机启动NTP

[root@cdh2 ~]# systemctl start ntpd.service
[root@cdh2 ~]# systemctl enable ntpd.service

13、查看客户机的NTP状态

[root@cdh2 ~]# systemctl status ntpd.service
● ntpd.service - Network Time Service
   Loaded: loaded (/usr/lib/systemd/system/ntpd.service; enabled; vendor preset: disabled)
   Active: active (running) since Sat 2019-09-28 21:31:26 CST; 38s ago
 Main PID: 100613 (ntpd)
   CGroup: /system.slice/ntpd.service
           └─100613 /usr/sbin/ntpd -u ntp:ntp -g

Sep 28 21:31:26 cdh2 ntpd[100613]: Listen and drop on 1 v6wildcard :: UDP 123
Sep 28 21:31:26 cdh2 ntpd[100613]: Listen normally on 2 lo 127.0.0.1 UDP 123
Sep 28 21:31:26 cdh2 ntpd[100613]: Listen normally on 3 eno16777736 192.168.20.132 UDP 123
Sep 28 21:31:26 cdh2 ntpd[100613]: Listen normally on 4 lo ::1 UDP 123
Sep 28 21:31:26 cdh2 ntpd[100613]: Listen normally on 5 eno16777736 fe80::20c:29ff:feb3:f5ad UDP 123
Sep 28 21:31:26 cdh2 ntpd[100613]: Listening on routing socket on fd #22 for interface updates
Sep 28 21:31:26 cdh2 ntpd[100613]: 0.0.0.0 c016 06 restart
Sep 28 21:31:26 cdh2 ntpd[100613]: 0.0.0.0 c012 02 freq_set kernel 0.000 PPM
Sep 28 21:31:26 cdh2 ntpd[100613]: 0.0.0.0 c011 01 freq_not_set
Sep 28 21:31:26 cdh2 systemd[1]: Started Network Time Service.

14、查看时间是否同步

[root@cdh2 ~]# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 cdh1            LOCAL(0)         6 u   14   64    3    1.092    9.130   3.475

通过以上操作即可以解决配置hbase或者cdh等集群是的时间不同步问题。

二、MySql安装

2.4.1 安装包准备
1)查看mysql是否安装,如果安装了,卸载mysql
(1)查看
[root@hadoop102 桌面]# rpm -qa|grep -i mysql
mysql-libs-5.1.73-7.el6.x86_64
(2)卸载
[root@hadoop102 桌面]# rpm -e --nodeps mysql-libs-5.1.73-7.el6.x86_64
2)解压mysql-libs.zip文件到当前目录
[root@hadoop102 software]# unzip mysql-libs.zip
[root@hadoop102 software]# ls
mysql-libs.zip
mysql-libs
3)进入到mysql-libs文件夹下,并设置当前用户执行权限
[root@hadoop102 mysql-libs]# ll
总用量 76048
-rw-r--r--. 1 root root 18509960 3月 26 2015 MySQL-client-5.6.24-1.el6.x86_64.rpm
-rw-r--r--. 1 root root 3575135 12月 1 2013 mysql-connector-java-5.1.27.tar.gz
-rw-r--r--. 1 root root 55782196 3月 26 2015 MySQL-server-5.6.24-1.el6.x86_64.rpm

[root@hadoop102 mysql-libs]# chmod u+x ./*
[root@hadoop102 mysql-libs]# ll
总用量 76048
-rwxr--r--. 1 root root 18509960 3月 26 2015 MySQL-client-5.6.24-1.el6.x86_64.rpm
-rwxr--r--. 1 root root 3575135 12月 1 2013 mysql-connector-java-5.1.27.tar.gz
-rwxr--r--. 1 root root 55782196 3月 26 2015 MySQL-server-5.6.24-1.el6.x86_64.rpm
2.4.2 安装MySql服务器
1)安装mysql服务端
[root@hadoop102 mysql-libs]# rpm -ivh MySQL-server-5.6.24-1.el6.x86_64.rpm
系统已经安装了其他版本的mysql-libs包导致不兼容。
删除mysql-libs yum remove mysql-libs
FATAL ERROR: please install the following Perl modules before executing /usr/bin/mysql_install_db:
解决方法 :安装autoconf库 命令:yum-y install autoconf

2)查看产生的随机密码
[root@hadoop102 mysql-libs]# cat /root/.mysql_secret
OEXaQuS8IWkG19Xs
3)查看mysql状态
[root@hadoop102 mysql-libs]# service mysql status
4)启动mysql
[root@hadoop102 mysql-libs]# service mysql start
2.4.3 安装MySql客户端
1)安装mysql客户端
[root@hadoop102 mysql-libs]# rpm -ivh MySQL-client-5.6.24-1.el6.x86_64.rpm
2)连接mysql
[root@hadoop102 mysql-libs]# mysql -uroot -pOEXaQuS8IWkG19Xs
3)修改密码
mysql>SET PASSWORD=PASSWORD('000000');
4)退出mysql
mysql>exit
2.4.4 MySql中user表中主机配置
配置只要是root用户+密码,在任何主机上都能登录MySQL数据库。
1)进入mysql
[root@hadoop102 mysql-libs]# mysql -uroot -p000000
2)显示数据库
mysql>show databases;
3)使用mysql数据库
mysql>use mysql;
4)展示mysql数据库中的所有表
mysql>show tables;
5)展示user表的结构
mysql>desc user;
6)查询user表
mysql>select User, Host, Password from user;
7)修改user表,把Host表内容修改为%
mysql>update user set host='%' where host='localhost';
8)删除root用户的其他host
mysql>delete from user where Host='hadoop102 ';
mysql>delete from user where Host='127.0.0.1';
mysql>delete from user where Host='::1';
9)刷新
mysql>flush privileges;
10)退出
mysql> quit;

下一篇:106-BigData-34CDH配置HA模式

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 218,122评论 6 505
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 93,070评论 3 395
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 164,491评论 0 354
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,636评论 1 293
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,676评论 6 392
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,541评论 1 305
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,292评论 3 418
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 39,211评论 0 276
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,655评论 1 314
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,846评论 3 336
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,965评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,684评论 5 347
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,295评论 3 329
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,894评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 33,012评论 1 269
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 48,126评论 3 370
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,914评论 2 355

推荐阅读更多精彩内容