这时候须要独立数据库,这里使用mysqljava
上传mysql和mysql驱动mysql
[hadoop@master conf]$ pwdlinux
/home/hadoop/hive/confsql
修改配置文件,若是没有修改都是从hivedefault配置文件中读取相应的信息。数据库
[hadoop@master ~]$ su - rootvim
口令:ide
aaoop
[root@master ~]# cd installer/spa
[root@master installer]# ls.net
jdk-6u27-linux-i586.rpm sun-javadb-common-10.6.2-1.1.i386.rpm
jdk-6u27-linux-i586-rpm.bin sun-javadb-core-10.6.2-1.1.i386.rpm
MySQL-5.5.40-1.rhel5.i386.rpm-bundle.tar sun-javadb-demo-10.6.2-1.1.i386.rpm
mysql-connector-java-5.1.29.tar.gz sun-javadb-docs-10.6.2-1.1.i386.rpm
sun-javadb-client-10.6.2-1.1.i386.rpm sun-javadb-javadoc-10.6.2-1.1.i386.rpm
[root@master installer]# mv mysql-connector-java-5.1.29.tar.gz /home/hadoop/installer/
[root@master installer]# mv MySQL-5.5.40-1.rhel5.i386.rpm-bundle.tar /home/hadoop/installer/
[root@master installer]# chown hadoop mysql-connector-java-5.1.29.tar.gz
[root@master installer]# chown hadoop MySQL-5.5.40-1.rhel5.i386.rpm-bundle.tar
[root@master installer]#
解压
[root@master installer]# tar xf MySQL-5.5.40-1.rhel5.i386.rpm-bundle.tar
[hadoop@master installer]$ tar xzf mysql-connector-java-5.1.29.tar.gz
Mysql解压出来的包比较多,咱们单独创建一个文件夹
[root@master installer]# mkdir mysql
[root@master installer]# mv MySQL-* mysql
[root@master installer]# cd mysql
[root@master mysql]# pwd
/home/hadoop/installer/mysql
[root@master mysql]#
安装注意使用root用户
[root@master installer]# cd mysql
[root@master mysql]# pwd
/home/hadoop/installer/mysql
[root@master mysql]# rpm -ivh MySQL-server-5.5.40-1.rhel5.i386.rpm
Preparing... ########################################### [100%]
1:MySQL-server ########################################### [100%]
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h master password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
Please report any problems at http://bugs.mysql.com/
[root@master mysql]#
[root@master mysql]# rpm -ivh MySQL-devel-5.5.40-1.rhel5.i386.rpm
Preparing... ########################################### [100%]
1:MySQL-devel ########################################### [100%]
[root@master mysql]# rpm -ivh MySQL-client-5.5.40-1.rhel5.i386.rpm
Preparing... ########################################### [100%]
1:MySQL-client ########################################### [100%]
[root@master mysql]#
[root@master mysql]# service mysql status
MySQL is not running [失败
[root@master mysql]# service mysql start
Starting MySQL... [肯定]
[root@master mysql]#
更改密码
[root@master mysql]# /usr/bin/mysqladmin -u root password '123456'
登录mysql
[root@master mysql]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.5.40 MySQL Community Server (GPL)
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
mysql> set password=password('123456');
Query OK, 0 rows affected (0.01 sec)
这样也能
为hive建立数据库和用户
mysql> grant all on *.* to mysql@'%' identified by 'mysql' with grant option;
Query OK, 0 rows affected (0.00 sec)
mysql>grant all on *.* to hadoop@'localhost' identified by '123456' with grant option;
Query OK, 0 rows affected (0.00 sec)
mysql> \q
Bye
[root@master mysql]#
[root@master mysql]# mysql -uhadoop -p123456
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 30
Server version: 5.5.40 MySQL Community Server (GPL)
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
mysql> create database hive;
Query OK, 1 row affected (0.05 sec)
配置
[root@master ~]# su - hadoop
[hadoop@master ~]$ cd hive
[hadoop@master hive]$ cd conf
[hadoop@master conf]$ cd ..
[hadoop@master hive]$ cd bin
[hadoop@master bin]$ ls
beeline ext hive hive-config.sh hiveserver2 metatool
[hadoop@master bin]$ vim hive-config.sh
[hadoop@master bin]$ pwd
/home/hadoop/hive/bin
拉到最后添加下面三条信息
export JAVA_HOME=/usr/java/jdk1.6.0_27
export HADOOP_HOME=/home/hadoop/hadoop
export HIVE_HOME=/home/hadoop/hive
[hadoop@master conf]$ cp hive-default.xml.template hive-site.xml
[hadoop@master conf]$ vim hive-site.xml
130 <property>
131 <name>javax.jdo.option.ConnectionURL</name>
132 <value>jdbc:mysql://localhost:3306/hive?=createDatabaseIfNotExsit=true</value>
133 <description>JDBC connect string for a JDBC metastore</description>
134 </property>
135
136 <property>
137 <name>javax.jdo.option.ConnectionDriverName</name>
138 <value>com.mysql.jdbc.Driver</value>
139 <description>Driver class name for a JDBC metastore</description>
140 </property>
141
160 <property>
161 <name>javax.jdo.option.ConnectionUserName</name>
162 <value>hadoop</value>
163 <description>username to use against metastore database</description>
164 </property>
165
166 <property>
167 <name>javax.jdo.option.ConnectionPassword</name>
168 <value>123456</value>
169 <description>password to use against metastore database</description>
170 </property>
171
拷贝驱动
[hadoop@master mysql-connector-java-5.1.29]$ pwd
/home/hadoop/installer/mysql-connector-java-5.1.29
[hadoop@master mysql-connector-java-5.1.29]$ cp mysql-connector-java-5.1.29-bin.jar /home/hadoop/hive/lib/
[hadoop@master mysql-connector-java-5.1.29]$
[hadoop@master conf]$ hive
Logging initialized using configuration in jar:file:/home/hadoop/hive-0.11.0/lib/hive-common-0.11.0.jar!/hive-log4j.properties
Hive history file=/tmp/hadoop/hive_job_log_hadoop_32276@master_201411130616_948032439.txt
hive> show tables;
OK
Time taken: 3.847 seconds