写论文的第五天 hive安装

时间:2022-12-03 06:31:44

Hive的安装和使用

         我们的版本约定:

         JAVA_HOME=/usr/local /jdk1.8.0_191

         HADOOP_HOME=/usr/local/hadoop

         HIVE_HOME=/usr/local/hive

        

                   离线安装Mysql

                            1°、查看mysql的依赖

                                     rpm -qa | grep mysql

                            2°、删除mysql的依赖

                                     rpm -e --nodeps `rpm -qa | grep mysql`或者

                                     rpm -e --nodeps `rpm -qa | grep MySQL`

                            3°、离线安装mysql

                                     rpm -ivh MySQL-server-5.1.73-1.glibc23.x86_64.rpm

                                     rpm -ivh MySQL-client-5.1.73-1.glibc23.x86_64.rpm

                            4°、启动mysql服务

                                     service mysql start

                            5°、加入到开机启动项

                                     chkconfig mysql on

                            6°、初始化配置mysql服务(第一次直接回车,后面跟着提示设置密码,自己设置密码

                                     whereis mysql_secure_installation

                                     执行脚本/usr/bin/mysql_secure_installation

                                                       

 

如果在mysql  /usr/bin/mysql_secure_installation 一直是下面报错后

 写论文的第五天 hive安装

 

 

解决办法:

ps aux | grep mysql
然后KILLmysql相关全部进程 Pid是进程号
kill -9 pid1 pid2 …

比如 kill -9 8301 8302 
然后再从第4步重新操作。

 

 

 

 

7°、访问mysql服务并修改权限

                            mysql -uroot -proot

7.1 切换数据库:use mysql;

7.2  查看用户权限表: select user,host from user

7.3 update user set host = '%' where user = 'root' (提示报错不用管,忽略)

7.4 刷新权限:flush privileges

 

 

         2、安装Hive

                   前提是:hadoop必须已经启动了***

                   1°、解压hive的安装包

                             tar -zxvf apache-hive-1.2.1-bin.tar.gz

修改下目录名称

mv apache-hive-1.2.1-bin hive

 

                   2°、备份配置文件

                    cp hive-env.sh.template hive-env.sh

                    cp hive-default.xml.template hive-site.xml

                   3°、配置hive的配置文件(hive的配置文件比较大,在linux中查找某项配置比较难,可以先将hive-site.xml文件复制到windows用文本编辑打开,然后ctrl+f查关键字修改,修改之后再放回到hive 的conf目录)

                            1)、修改hive-env.sh

                                     加入三行内容(大家根据自己的情况来添加)

Export HADOOP_HOME=/usr/local/ hadoop

Export JAVA_HOME=/usr/local/ jdk1.8.0_191

Export HIVE_HOME=/usr/local/ hive

 

2)、修改hive-site.xml 

 

                                     <property>

                                               <name>javax.jdo.option.ConnectionURL</name>

                                               <value>jdbc:mysql://112.74.50.240:3309/hive?createDatabaseIfNotExist=true</value>

                                     </property>

                                     <property>

                                               <name>javax.jdo.option.ConnectionDriverName</name>

                                               <value>com.mysql.jdbc.Driver</value>

                                     </property>

                                     <property>

                                               <name>javax.jdo.option.ConnectionUserName</name>

                                               <value>root</value>

                                     </property>

                                     <property>

                                               <name>javax.jdo.option.ConnectionPassword</name>

                                               <value>wang</value>

                                     </property>

                                     <property>

                                               <name>hive.querylog.location</name>

                                               <value>/usr/local/ hive/tmp</value>

                                     </property>

                                     <property>

                                               <name>hive.exec.local.scratchdir</name>

                                               <value>/usr/local/ hive/tmp</value>

                                     </property>

                                     <property>

                                               <name>hive.downloaded.resources.dir</name>

                                               <value>/usr/local/ hive/tmp</value>

                                     </property>

                   4°、拷贝mysql驱动到$HIVE_HOME/lib目录下

                             cp /usr/local/soft/mysql-connector-java-5.1.47.jar ../lib/

5、将hadoop的jline-0.9.94.jar的jar替换成hive的版本。

hive的 jline-2.12.jar 位置在 /usr/local /hive/lib/jline-2.12.jar

将Hadoop的删除

rm -rf   /usr/local/soft/hadoop-2.6.0/share/hadoop/yarn/lib/jline-0.9.94.jar

然后将hive的jar拷过去hadoop下:

命令:

cp

 /usr/local/ hive/lib/jline-2.12.jar    /usr/local/ hadoop/share/hadoop/yarn/lib/

 

                   6°、启动Hive

                             ./hive

 写论文的第五天 hive安装

 

=================================================================================================

7.配置环境变量

Vim /etc/profile

增加:export HIVE_HOME=/usr/local/hive

Export PATH=$HIVE_HOME/bin:$PATH