Install Hive and bind MySQL

1. Transfer the hive file to the hadoop user directory in Linux


   Then extract it to the opt directory

          

2. After decompression, go to its directory, find the file hive-default.xml.template in a conf directory, and rename it to hive-site.xml



3. Next, set the data address, driver, user name and password for connecting to the MySQL database, database storage location, etc.

     vi Enter the file we renamed

              

          a) Check hive.exec.scratchdir, no need to change here, we use the path created by default

                    

  

          b) Change the driver: check: javax.jdo.option.ConnectionDriverName is changed to com.mysql.jdbc.Driver

                 

   c) Change the data address: check javax.jdo.option.ConnectionURL and change it to: jdbc:mysql://python2:3306/hive?autoReconnect=true&useUnicode=true&createDatabaseIfNotExist=true&characterEncoding=utf8&useSSL=false&serverTimezone =UTC

                 

    Here python2 is our hostname

      

            d) Change the username of MySQL to connect to:

                 查:javax.jdo.option.ConnectionUserName

                 Changed to: root (this is the username for my MySQL database)

               

        

            e) Change the password of the MySQL to be connected:

                查:javax.jdo.option.ConnectionPassword

                Changed to: root (this is the password for my MySQL database)

              

           f) Check hive.metastore.warehouse.dir here without changing it, use the path created by default

             

4. Configure hive environment variables

       1. Set the variable hivepath=`pwd`, save the current path in the variable, and then configure the HIVE_HOME and PATH paths

       2. Update the environment source~/.bashrc

          

          

5. Start MySQL, execute schematool -dbType mysql –initSchema, an error will be reported here, we need a jar file now, we need to use the wget command, but our system is not installed, so we have to switch to the root user to install

           

   After downloading, we enter the lib directory where we need the jar file to download


    Then you will be prompted that the installation is complete


6. Start hive

       After entering hive, the system will give an error, saying that there is a path required for this place


      Then we create a new directory under the hadoop user named hivetmp, then pwd, copy the absolute path of the path, and then we need to enter the file to modify, the file is the file we renamed hive-site.xml

       Enter vi hive-site.xml, then enter /, paste the content we need to view at the back, press Enter to query, if there are more than one, press n to jump to the need to enter /java.io.tmpdir in total There are four places that need to be modified. Replace the places that need to be modified with the absolute path we just copied, but there are two folders that have been created by default. We need to keep this.

             

             

             

             

7. Next, we enter hive and it can be used, but I don’t need this method here. We start hiveserver2. After entering, the cursor will always be stuck here. We only need to copy a pipeline and enter the bin directory of hive in this pipeline. , enter: ./beeline-u jdbc:hive2://

                      

  Let's use the command to see the current database

             

Doing this, we have completed the installation of hive and the binding of the database.


If hive can connect to the MySQL database, there will be an additional hive database in the MySQL database




 

  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324421081&siteId=291194637