hadoop集群基本配置

软件说明

  1. hadoop集群使用cloudera hadoop-2.5.0-cdh5.3.6
  2. java-JDK使用jdk-8u171-linux-x64
  3. Hive使用hive-0.13.1-cdh5.3.6
  4. Mysql使用MySQL-server-5.6.24-1.el6.x86_64
  5. ZooKeeper使用zookeeper-3.4.5-cdh5.3.6
  6. kafka 使用kafka_2.9.2-0.8.1
  7. slf4j使用slf4j-nop-1.7.6.jar
  8. flume使用flume-ng-1.5.0-cdh5.3.6
  9. hbase使用hbase-1.3.1-bin.tar.gz
    相关下载地址
    CDH http://archive.cloudera.com/cdh5/cdh/5/
    JDK http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
    Mysql https://dev.mysql.com/downloads/mysql/
    1. 给通常用户添加sudo权限
    配置sudo权限
    [root@localhost ~]# visudo
    也就是修改/etc/sudoers 文件
    root ALL=(ALL) ALL
    用户名 被管理主机的地址 = (可使用的身份) 授权命令(绝对路径)
    #%wheel ALL=(ALL) ALL %
    用户名 ALL=(ALL) ALL
    组名 被管理主机的地址 = (可使用的身份) 授权命令(绝对路径)

r w x
4 2 1

chmod 777 1.txt
chmod 654 1.txt
6当前用户
chmod u+x 当前用户 执行权限
chmod g+r 当前组有读
chmod o+w 表示其他用户写
2. 关闭selinux
SELINUX
vi /etc/selinux/config
SELINUX=disabled

3. 安装JDK(集群中都需要)
将jdk-8u171-linux-x64.rpm上传到服务器上
安装JDK:rpm -ivh jdk-8u171-linux-x64.rpm
配置jdk相关的环境变量
vi ~/.bashrc_profile

执行 vi ~/.bashrc
vi ~/.bash_profile
vi /etc/profile
export JAVA_HOME=/usr/java/latest
export PATH= P A T H : PATH: JAVA_HOME/bin
source ~/.bashrc_profile
测试jdk安装是否成功:java -version
rm -f /etc/udev/rules.d/70-persistent-net.rules
重启服务器命令reboot
关闭服务器命令shutdown
5. NTP时间同步

NTP简介:
NTP是网络时间协议(Network Time Protocol),它是用来同步网络中各个计算机的时间的协议。
在计算机的世界里,时间非常地重要
例如:对于火箭发射这种科研活动,对时间的统一性和准确性要求就非常地高,是按照A这台计算机的时间,还是按照B这台计算机的时间?
NTP就是用来解决这个问题的,NTP(Network Time Protocol,网络时间协议)是用来使网络中的各个计算机时间同步的一种协议。
它的用途是把计算机的时钟同步到世界协调时UTC,其精度在局域网内可达0.1ms,在互联网上绝大多数的地方其精度可以达到1-50ms。
它可以使计算机对其服务器或时钟源(如石英钟,GPS等等)进行时间同步,它可以提供高精准度的时间校正,而且可以使用加密确认的方式来防止病毒的协议攻击。
 
环境:
系统:CentOS 7

NTP Server服务器IP:192.168.93.126

NTP Client客户端IP:192.168.93.127

 
1、搭建NTP服务器
1.1、查看服务器是否安装ntp,系统默认安装ntpdate;
[root@localhost ~]# rpm -qa |grep ntp
ntpdate-4.2.6p5-28.el7.centos.x86_64
ntp-4.2.6p5-28.el7.centos.x86_64
1.2、安装ntp,ntpdate已经系统默认安装过了
[root@localhost ~]# yum install -y ntp
1.3、修改ntp配置文件
复制代码
[root@localhost ~]# vim /etc/ntp.conf

把配置文件下面四行注释掉:
server 0.cn.pool.ntp.org iburst
server 1.cn.pool.ntp.org iburst
server 2.cn.pool.ntp.org iburst
server 3.cn.pool.ntp.org iburst
然后在下面添加这几行:
server 0.cn.pool.ntp.org iburst
server 1.cn.pool.ntp.org iburst
server 2.cn.pool.ntp.org iburst
server 3.cn.pool.ntp.org iburst
复制代码
1.4、启动ntp服务,并开机自启动
[root@localhost ~]# systemctl start ntpd
[root@localhost ~]# systemctl enable ntpd
1.5、查询ntp是否同步
[root@localhost ~]# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*119.28.206.193  100.122.36.196   2 u  128  128  377   19.711   -0.468   5.363
1.6、开启防火墙ntp默认端口udp123
[root@localhost ~]# firewall-cmd --permanent --zone=public --add-port=123/udp
success
[root@localhost ~]# firewall-cmd --reload
success
 

2、NTP客户端配置
安装的NTP跟上面的步骤一样

2.1、修改ntp配置文件,将上面的NTP服务器作为客户端同步NTP时间服务器
复制代码
[root@localhost ~]# vim /etc/ntp.conf
#配置允许NTP Server时间服务器主动修改本机的时间
restrict 192.168.0.15 nomodify notrap noquery
#注释掉其他时间服务器
#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
#配置时间服务器为本地搭建的NTP Server服务器
server 192.168.0.15
复制代码
2.2、与NTP server服务器同步一下时间:
[root@localhost ~]# ntpdate -u 192.168.0.15
2.3、查看ntp同步状态
能看到已经成功同步,要记得开启ntpd这个服务器

设置可以直接通过主机名访问

设置主机名相互访问
vi /etc/hosts
ip 主机名 域名
示例
192.168.93.126 master
192.168.93.127 slave2
192.168.93.128 slave3

使用主机名ping master 是否可以测试通过

windows 下使用主机名连接Linux系统
C:\Windows\System32\drivers\etc\hosts 使用以上相同的配置方式

配置集群ssh免密码登录
A. 生成本机的公钥,过程中不断敲回车即可,ssh-keygen命令默认会将公钥放在/root[当前操作用户的]/.ssh目录下
ssh-keygen -t rsa

B. 将公钥复制为authorized_keys文件,此时使用ssh连接本机就不需要输入密码了
cd /root[当前操作用户的]/.ssh
cp id_rsa.pub authorized_keys

C. 接着配置三台机器互相之间的ssh免密码登录
使用ssh-copy-id -i master命令将本机的公钥拷贝到指定机器的authorized_keys文件中(方便好用)
测试登陆其他主机
ssh 用户名@主机名

发布了60 篇原创文章 · 获赞 7 · 访问量 4354

猜你喜欢

转载自blog.csdn.net/weixin_43250197/article/details/104010068