• 【Hive安装】Hive架构及远程元数据服务模式安装


    Hive架构及远程元数据服务模式安装

    node01主node02备node03数据结点node04数据结点
    mysql
    hive√ (服务端)√ (客户端)

    mysql安装

    yum install mysql-server
    
    • 1

    如果提示没有可用包,那就要先下载 rpm 包安装一下,yum安装报错拉至最后修改镜像为清华源

    yum -y install wget
    wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
    rpm -ivh mysql-community-release-el7-5.noarch.rpm
    yum install mysql-server
    
    • 1
    • 2
    • 3
    • 4

    安装完后,启动 mysql 服务

    service mysqld start
    
    • 1

    然后就可以输入 mysql 进入命令行

    mysql	// 进入命令行
    use mysql	// 修改针对hive的权限相关。首先进入mysql这个库
    
    // 有一个表叫user。此时这个表里的主机显示的都是本机,而我们需要让其他机器可以联网访问它
    grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option
    flush privileges
    quit		// 然后可以退出了
    
    //不要这样设置密码负责后面hive使用不了,若已经设置,可以到mysql将*外所有用户删除
    [root@host]# mysqladmin -u root password "123456";	//不要执行此命令
    
    chkconfig mysqld on		// 将mysql服务注册为开机启动
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12

    安装 hive

    接下来安装 hive。首先准备 hive 的压缩文件以及 mysql 的驱动 jar 包

    tar -zxvf apache-hive-2.3.4-bin.tar.gz -C /opt/bigdata/
    cd /opt/bigdata
    mv apache-hive-2.3.4-bin hive-2.3.4
    vi /etc/profile // 加一下环境变量
    
    export JAVA_HOME=/usr/java/default
    export HADOOP_HOME=/opt/bigdata/hadoop-2.6.5
    export ZOOKEEPER_HOME=/opt/bigdata/zookeeper-3.4.6
    export HIVE_HOME=/opt/bigdata/hive-2.3.4
    export PATH=$PATH:$JAVA_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$ZOOKEEPER_HOME/bin:$HIVE_HOME/bin
    
    source /etc/profile
    cp mysql-connector-java-5.1.47 $HIVE_HOME/lib/ 	// 驱动包拷贝到lib目录下,注:6以上为com.mysql.cj.jdbc.Driver,6以下为com.mysql.jdbc.Driver
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    cd hive-2.3.4/conf
    cp hive-default.xml.template hive-site.xml
    vi hive-site.xml // 配置文档,这里node01和node04是不一样的
    
    // node01服务端的hive-site.xml
    <configuration>
    	<property>
    		<name>hive.metastore.warehouse.dirname>
    		<value>/user/hive_remote/warehousevalue>
    	property>
    	<property>
    		<name>javax.jdo.option.ConnectionURLname>
    		<value>jdbc:mysql://node01:3306/hive_remote?createDatabaseIfNotExist=truevalue>
    	property>
    	<property>
    		<name>javax.jdo.option.ConnectionDriverNamename>
    		<value>com.mysql.jdbc.Drivervalue>
    	property>
    	<property>
    		<name>javax.jdo.option.ConnectionUserNamename>
    		<value>rootvalue>
    	property>
    	<property>
    		<name>javax.jdo.option.ConnectionPasswordname>
    		<value>123456value>
    	property>
    configuration>
    
    scp -r ./hive-2.3.4/ root@node04:/opt/bigdata/			//复制hive-2.3.4从node01到node04
    
    // node04客户端的hive-site.xml
    <configuration>
    	<property>
    		<name>hive.metastore.warehouse.dirname>
    		<value>/user/hive_remote/warehousevalue>
    	property>
    	<property>
    		<name>hive.metastore.urisname>
    		<value>thrift://node04:9083value>
    	property>
    configuration>
    
    // 从hive-2.1开始,这个初始化命令需要执行。只需要在node01 $HIVE_HOME/bin下执行
    ./schematool -dbType mysql -initSchema
    hive --service metastore // node01上开启元数据服务,是个阻塞式窗口
    // 在node04上输入hive就可以使用了
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46

    yum安装报错

    使用yum安装报错:[Errno 256] No more mirrors to try
    一、更新yum:
      yum clean all
      yum makecache
      yum update -y
    二、若不行,可能是因为DNS不稳定吧,因为yum安装时会从三个”repo源“(base,extras,updates)随机获取地址
    先备份老源:mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
    CentOS7系统:wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
    具体方法参考阿里云官方:https://developer.aliyun.com/mirror/centos?spm=a2c6h.13651102.0.0.3e221b11iDH0bA
    刷新并生成缓存
      yum clean all
      yum makecache

    例如:CentOS-Base.repo换为清华源

    # CentOS-Base.repo
    #
    # The mirror system uses the connecting IP address of the client and the
    # update status of each mirror to pick mirrors that are updated to and
    # geographically close to the client.  You should use this for CentOS updates
    # unless you are manually picking other mirrors.
    #
    # If the mirrorlist= does not work for you, as a fall back you can try the 
    # remarked out baseurl= line instead.
    #
    #
    
    [base]
    name=CentOS-$releasever - Base
    #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
    #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.9/os/x86_64/
    gpgcheck=1
    gpgkey=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.9/os/x86_64/RPM-GPG-KEY-CentOS-6
    
    #released updates 
    [updates]
    name=CentOS-$releasever - Updates
    #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
    #baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.9/os/x86_64/
    gpgcheck=1
    gpgkey=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.9/os/x86_64/RPM-GPG-KEY-CentOS-6
    
    #additional packages that may be useful
    [extras]
    name=CentOS-$releasever - Extras
    #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
    #baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.9/os/x86_64/
    gpgcheck=1
    gpgkey=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.9/os/x86_64/RPM-GPG-KEY-CentOS-6
    
    #additional packages that extend functionality of existing packages
    [centosplus]
    name=CentOS-$releasever - Plus
    #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
    #baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.9/os/x86_64/
    gpgcheck=1
    enabled=0
    gpgkey=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.9/os/x86_64/RPM-GPG-KEY-CentOS-6
    
    #contrib - packages by Centos Users
    [contrib]
    name=CentOS-$releasever - Contrib
    #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib&infra=$infra
    #baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.9/os/x86_64/
    gpgcheck=1
    enabled=0
    gpgkey=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.9/os/x86_64/RPM-GPG-KEY-CentOS-6
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
  • 相关阅读:
    第2-3-6章 打包批量下载附件的接口开发-文件存储服务系统-nginx/fastDFS/minio/阿里云oss/七牛云oss
    原生JS实现无缝轮播图
    MySQL基本知识
    JAVA宠物管理系统计算机毕业设计Mybatis+系统+数据库+调试部署
    微信核酸检测预约小程序系统毕业设计毕设(4)开题报告
    VGG16网络结构学习笔记
    python开发过程中注意编码规范~
    Day9 ---- 用户注册与登录
    AJAX——HTTP协议
    代码随想录算法训练营第五十六天 | LeetCode 647. 回文子串、516. 最长回文子序列、动态规划总结
  • 原文地址:https://blog.csdn.net/qq_44033208/article/details/126260905