hive集群安装,连接mysql

1.linux安装mysql,并且生成hive用户,密码为Abc!123D,权限为所有权限,请看(这点很重要)http://blog.csdn.net/qq_21383435/article/details/76573955

2。我的hadoop是2。7,hive下载的是2.2,下载解压hive到/opt/moudles/apache-hive-2.2.0-bin这个目录
3。配置hive环境变量

export HIVE_HOME=/opt/moudles/apache-hive-2.2.0-bin
export PATH=$PATH:$HIVE_HOME/bin
"/etc/profile" 109L, 2732C                              

4。配置hive的环境

vim hive-env.sh
HADOOP_HOME=/opt/moudles/hadoop-2.7.3
export HIVE_CONF_DIR=/opt/moudles/apache-hive-2.2.0-bin/conf

5.配置vim conf/hive-site.xml


<configuration>
  
  
  
  

    <property>
        <name>hive.metastore.localname>
        <value>falsevalue>
    property>
    

    <property>
         <name>hive.metastore.warehouse.dirname>
         <value>hdfs://mycluster/hive/warehousevalue>
     property>
        

    <property>
      <name>javax.jdo.option.ConnectionURLname>
      <value>jdbc:mysql://biluos.com:3306/hive_db?createDatabaseIfNotExist=truevalue>
      <description>JDBC connect string for a JDBC metastoredescription>
    property>
    

    <property>
      <name>javax.jdo.option.ConnectionDriverNamename>
      <value>com.mysql.jdbc.Drivervalue>
      <description>Driver class name for a JDBC metastoredescription>
    property>
    

    <property>
      <name>javax.jdo.option.ConnectionUserNamename>
      <value>hivevalue>
      <description>username to use against metastore databasedescription>
    property>
    

    <property>
      <name>javax.jdo.option.ConnectionPasswordname>
      <value>Abc!123Dvalue>
      <description>password to use against metastore databasedescription>
    property>
    

    <property>
      <name>hive.metastore.urisname>
      <value>thrift://biluos.com:9083value>
      <description>Thrift URI for the remote metastore. ...description>
    property>
    

    <property>
      <name>hive.metastore.schema.verificationname>
      <value>falsevalue>
    property>
    


    <property>
      <name>hive.cli.print.current.dbname>
      <value>truevalue>
    property>
    

    <property>
      <name>hive.cli.print.headername>
      <value>truevalue>
    property>
    

configuration>

6。把MySql驱动放到Hive的lib目录下
hive集群安装,连接mysql_第1张图片
上面这个带bin的不知道是不是windows使用的,反正没测试,因为报错太多,用空测试吧
7。初始化hive

[root@biluos apache-hive-2.2.0-bin]# schematool -initSchema -dbType mysql --verbose

–verbose可要可不要,要的话会显示详细信息,我在这里卡了很久。但是不知怎么就解决了。主要是出问题
hive集群安装,连接mysql_第2张图片
这里重点检查配置文件和hive用户的权限,主要是连接的URL配置。
成功后mysql中可以看到
hive集群安装,连接mysql_第3张图片
8。启动Hive
实际使用时,一般通过后台启动metastore和hiveserver实现服务,命令如下:
hive –service metastore &
hive –service hiveserver &
我现在是测试
这里写图片描述
然后启动hive命令行
hive集群安装,连接mysql_第4张图片
这一点如果先执行这个命令会报错如下,需要先执行hive –service metastore

Exception in thread "main" java.lang.RuntimeException: org.apache.hadoop.hive.ql.metadata.HiveException: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient

Caused by: org.apache.hadoop.hive.ql.metadata.HiveException: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient

Caused by: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient

Caused by: java.lang.reflect.InvocationTargetException

Caused by: MetaException(message:Could not connect to meta store using any of the URIs provided. Most recent failure: org.apache.thrift.transport.TTransportException: java.net.ConnectException: Connection refused (Connection refused)

Caused by: java.net.ConnectException: Connection refused (Connection refused)

9。hive中建立一个数据库,然后建立一个表create table test(id int,name string); 可以看到网页上可以看到
hive集群安装,连接mysql_第5张图片
10。好了,安装完成


11,下面是集群的另外一种配置,其他不变只需要修改hive-site.xml就好了


        <property>
         <name>hive.metastore.warehouse.dirname>
         <value>hdfs://mycluster/hive/warehousevalue>
        property>


        
        <property>
          <name>javax.jdo.option.ConnectionURLname>
          <value>jdbc:mysql://biluos.com:3306/hive_db?createDatabaseIfNotExist=truevalue>
          <description>JDBC connect string for a JDBC metastoredescription>
        property>


        
        <property>
          <name>javax.jdo.option.ConnectionDriverNamename>
          <value>com.mysql.jdbc.Drivervalue>
          <description>Driver class name for a JDBC metastoredescription>
        property>


        
        <property>
          <name>javax.jdo.option.ConnectionUserNamename>
          <value>hivevalue>
          <description>username to use against metastore databasedescription>
        property>

        
        <property>                                                                                                                                                         
          <name>javax.jdo.option.ConnectionPasswordname>                                                                                                                 
          <value>Abc!123Dvalue>                                                                                                                                          
          <description>password to use against metastore databasedescription>                                                                                            
        property>                                                                                                                                                        


                                                                                                                        
        <property>                                                                                                                                                         
          <name>hive.metastore.urisname>                                                                                                                                 
          <value>thrift://biluos.com:9083value>                                                                                                                          
          <description>Thrift URI for the remote metastore. ...description>                                                                                              
        property>  

                                                                                                                                                       
        <property>                                                                                                                                                         
                <name>hbase.zookeeper.quorumname>                                                                                                                        
                <value>biluos.com,biluos1.com,biluos2.comvalue>                                                                                                          
        property>                                            

你可能感兴趣的:(大数据-hive)