HIVE 安装系列(3)配置HIVE 使用Mysql作为元数据的数据库
2016-03-02 19:59
816 查看
HIVE使用mysql作为元数据
安装成功!结果如下
[root@master lib]#pwd
/usr/local/apache-hive-1.2.1/lib
[root@master lib]#cd /dev/shm/setup_tool/
[root@master setup_tool]#ls
MySQL-client-5.5.31-2.el6.i686.rpm mysql-connector-java-5.1.10.jar MySQL-server-5.5.31-2.el6.i686.rpm
[root@master setup_tool]#cp
cp: missing file operand
Try `cp --help' for more information.
[root@master setup_tool]#cp MySQL-client-5.5.31-2.el6.i686.rpm /usr/local/apache-hive-1.2.1/lib
[root@master apache-hive-1.2.1]#cd conf
[root@master conf]#ls
beeline-log4j.properties.template hive-env.sh.template hive-log4j.properties.template
hive-default.xml.template hive-exec-log4j.properties.template ivysettings.xml
[root@master conf]#cp hive-env.sh.template hive-env.sh
[root@master conf]#cp hive-default.xml.template hive-site.xml
[root@master conf]#
[root@master hadoop]# service mysql start
Starting MySQL..... SUCCESS!
[root@master hadoop]#ps -ef|grep mysqld
root 3662 1 0 06:16 pts/1 00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql
--pid-file=/var/lib/mysql/master.pid
mysql 3753 3662 32 06:17 pts/1 00:00:03 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql
--plugin-dir=/usr/lib/mysql/plugin --user=mysql --log-error=/var/lib/mysql/master.err --pid-
file=/var/lib/mysql/master.pid
root 3781 2869 0 06:17 pts/1 00:00:00 grep mysqld
[root@master hadoop]#mysql -uroot -proot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.31 MySQL Community Server (GPL)
Copyright (c) 2000, 2013, 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> GRANT ALL PRIVILEGES ON *.* TO
'hadoop'@'localhost' IDENTIFIED BY 'hadoop' WITH GRANT OPTION;
Query OK, 0 rows affected (0.03 sec)
mysql> GRANT ALL PRIVILEGES ON *.* TO
'hadoop'@'%' IDENTIFIED BY 'hadoop' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql>
[root@master hadoop]#mysql -uhadoop -phadoop
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.31 MySQL Community Server (GPL)
Copyright (c) 2000, 2013, 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> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.05 sec)
mysql>
[root@master lib]#ls | grep mysql
[root@master lib]#pwd
/usr/local/apache-hive-1.2.1/lib
[root@master lib]#cd /dev/shm
[root@master shm]#ls
pulse-shm-2554940598 pulse-shm-3486649521 setup_tool
[root@master shm]#ce setup_tool
bash: ce: command not found
[root@master shm]#ls
pulse-shm-2554940598 pulse-shm-3486649521 setup_tool
[root@master shm]#cd setup_tool
[root@master setup_tool]#ls
mysql-connector-java-5.1.10.jar
[root@master setup_tool]#cp mysql-connector-java-5.1.10.jar /usr/local/apache-hive-1.2.1/lib
[root@master setup_tool]#cd /usr/local/apache-hive-1.2.1/lib
[root@master lib]#ls | grep mysql
mysql-connector-java-5.1.10.jar
[root@master lib]#
[root@master conf]#cat hive-site.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true</value>
<description>JDBC connect string for a JDBC metastore</description>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
<description>Driver class name for a JDBC metastore</description>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>hadoop</value>
<description>username to use against metastore database</description>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>hadoop</value>
<description>password to use against metastore database</description>
</property>
</configuration>
[root@master conf]#
[root@master sbin]#start-dfs.sh
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
16/03/02 06:44:01 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform...
using builtin-java classes where applicable
Starting namenodes on [Master]
Master: starting namenode, logging to /usr/local/hadoop-2.6.0/logs/hadoop-root-namenode-master.out
localhost: starting datanode, logging to /usr/local/hadoop-2.6.0/logs/hadoop-root-datanode-master.out
Starting secondary namenodes [0.0.0.0]
0.0.0.0: starting secondarynamenode, logging to /usr/local/hadoop-2.6.0/logs/hadoop-root-
secondarynamenode-master.out
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
16/03/02 06:44:43 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform...
using builtin-java classes where applicable
[root@master sbin]#jps
4210 SecondaryNameNode
3973 NameNode
4343 Jps
4061 DataNode
[root@master sbin]#hive
Logging initialized using configuration in jar:file:/usr/local/apache-hive-1.2.1/lib/hive-common-
1.2.1.jar!/hive-log4j.properties
Java HotSpot(TM) Client VM warning: You have loaded library /tmp/libnetty-transport-native-
epoll2358578991288615799.so which might have disabled stack guard. The VM will try to fix the stack
guard now.
It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z
noexecstack'.
[ERROR] Terminal initialization failed; falling back to unsupported
java.lang.IncompatibleClassChangeError: Found class jline.Terminal, but interface was expected
at jline.TerminalFactory.create(TerminalFactory.java:101)
at jline.TerminalFactory.get(TerminalFactory.java:158)
at jline.console.ConsoleReader.<init>(ConsoleReader.java:229)
at jline.console.ConsoleReader.<init>(ConsoleReader.java:221)
at jline.console.ConsoleReader.<init>(ConsoleReader.java:209)
at org.apache.hadoop.hive.cli.CliDriver.setupConsoleReader(CliDriver.java:787)
at org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:721)
at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:681)
at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:621)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.hadoop.util.RunJar.run(RunJar.java:221)
at org.apache.hadoop.util.RunJar.main(RunJar.java:136)
Exception in thread "main" java.lang.IncompatibleClassChangeError: Found class jline.Terminal, but
interface was expected
at jline.console.ConsoleReader.<init>(ConsoleReader.java:230)
at jline.console.ConsoleReader.<init>(ConsoleReader.java:221)
at jline.console.ConsoleReader.<init>(ConsoleReader.java:209)
at org.apache.hadoop.hive.cli.CliDriver.setupConsoleReader(CliDriver.java:787)
at org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:721)
at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:681)
at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:621)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.hadoop.util.RunJar.run(RunJar.java:221)
at org.apache.hadoop.util.RunJar.main(RunJar.java:136)
增加hadoop-env.sh 配置
export HADOOP_USER_CLASSPATH_FIRST=true
export JAVA_HOME=/usr/local/jdk1.8.0_65
export HADOOP_USER_CLASSPATH_FIRST=true
"hadoop-env.sh" 105L, 4309C written
[root@master hadoop]#ls
capacity-scheduler.xml hadoop-env.sh httpfs-env.sh kms-env.sh
mapred-env.sh slaves yarn-site.xml
configuration.xsl hadoop-metrics2.properties httpfs-log4j.properties kms-log4j.properties
mapred-queues.xml.template ssl-client.xml.example
container-executor.cfg hadoop-metrics.properties httpfs-signature.secret kms-site.xml
mapred-site.xml ssl-server.xml.example
core-site.xml hadoop-policy.xml httpfs-site.xml log4j.properties
mapred-site.xml.bak yarn-env.cmd
hadoop-env.cmd hdfs-site.xml kms-acls.xml mapred-env.cmd
mapred-site.xml.template yarn-env.sh
[root@master hadoop]# source ./hadoop-env.sh
[root@master hadoop]#hive
Logging initialized using configuration in jar:file:/usr/local/apache-hive-1.2.1/lib/hive-common-
1.2.1.jar!/hive-log4j.properties
Java HotSpot(TM) Client VM warning: You have loaded library /tmp/libnetty-transport-native-
epoll2494088548290783314.so which might have disabled stack guard. The VM will try to fix the stack
guard now.
It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z
noexecstack'.
hive>
hive> show tables;
OK
Time taken: 5.823 seconds
hive>
hive> show tables;
OK
Time taken: 5.823 seconds
hive> create table a1(a string,b int);
OK
Time taken: 2.19 seconds
hive> create table a2(a string,b int);
OK
Time taken: 0.077 seconds
hive> show tables;
OK
a1
a2
Time taken: 0.07 seconds, Fetched: 2 row(s)
hive>
安装成功!结果如下
[root@master lib]#pwd
/usr/local/apache-hive-1.2.1/lib
[root@master lib]#cd /dev/shm/setup_tool/
[root@master setup_tool]#ls
MySQL-client-5.5.31-2.el6.i686.rpm mysql-connector-java-5.1.10.jar MySQL-server-5.5.31-2.el6.i686.rpm
[root@master setup_tool]#cp
cp: missing file operand
Try `cp --help' for more information.
[root@master setup_tool]#cp MySQL-client-5.5.31-2.el6.i686.rpm /usr/local/apache-hive-1.2.1/lib
[root@master apache-hive-1.2.1]#cd conf
[root@master conf]#ls
beeline-log4j.properties.template hive-env.sh.template hive-log4j.properties.template
hive-default.xml.template hive-exec-log4j.properties.template ivysettings.xml
[root@master conf]#cp hive-env.sh.template hive-env.sh
[root@master conf]#cp hive-default.xml.template hive-site.xml
[root@master conf]#
[root@master hadoop]# service mysql start
Starting MySQL..... SUCCESS!
[root@master hadoop]#ps -ef|grep mysqld
root 3662 1 0 06:16 pts/1 00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql
--pid-file=/var/lib/mysql/master.pid
mysql 3753 3662 32 06:17 pts/1 00:00:03 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql
--plugin-dir=/usr/lib/mysql/plugin --user=mysql --log-error=/var/lib/mysql/master.err --pid-
file=/var/lib/mysql/master.pid
root 3781 2869 0 06:17 pts/1 00:00:00 grep mysqld
[root@master hadoop]#mysql -uroot -proot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.31 MySQL Community Server (GPL)
Copyright (c) 2000, 2013, 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> GRANT ALL PRIVILEGES ON *.* TO
'hadoop'@'localhost' IDENTIFIED BY 'hadoop' WITH GRANT OPTION;
Query OK, 0 rows affected (0.03 sec)
mysql> GRANT ALL PRIVILEGES ON *.* TO
'hadoop'@'%' IDENTIFIED BY 'hadoop' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql>
[root@master hadoop]#mysql -uhadoop -phadoop
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.31 MySQL Community Server (GPL)
Copyright (c) 2000, 2013, 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> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.05 sec)
mysql>
[root@master lib]#ls | grep mysql
[root@master lib]#pwd
/usr/local/apache-hive-1.2.1/lib
[root@master lib]#cd /dev/shm
[root@master shm]#ls
pulse-shm-2554940598 pulse-shm-3486649521 setup_tool
[root@master shm]#ce setup_tool
bash: ce: command not found
[root@master shm]#ls
pulse-shm-2554940598 pulse-shm-3486649521 setup_tool
[root@master shm]#cd setup_tool
[root@master setup_tool]#ls
mysql-connector-java-5.1.10.jar
[root@master setup_tool]#cp mysql-connector-java-5.1.10.jar /usr/local/apache-hive-1.2.1/lib
[root@master setup_tool]#cd /usr/local/apache-hive-1.2.1/lib
[root@master lib]#ls | grep mysql
mysql-connector-java-5.1.10.jar
[root@master lib]#
[root@master conf]#cat hive-site.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true</value>
<description>JDBC connect string for a JDBC metastore</description>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
<description>Driver class name for a JDBC metastore</description>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>hadoop</value>
<description>username to use against metastore database</description>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>hadoop</value>
<description>password to use against metastore database</description>
</property>
</configuration>
[root@master conf]#
[root@master sbin]#start-dfs.sh
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
16/03/02 06:44:01 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform...
using builtin-java classes where applicable
Starting namenodes on [Master]
Master: starting namenode, logging to /usr/local/hadoop-2.6.0/logs/hadoop-root-namenode-master.out
localhost: starting datanode, logging to /usr/local/hadoop-2.6.0/logs/hadoop-root-datanode-master.out
Starting secondary namenodes [0.0.0.0]
0.0.0.0: starting secondarynamenode, logging to /usr/local/hadoop-2.6.0/logs/hadoop-root-
secondarynamenode-master.out
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
16/03/02 06:44:43 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform...
using builtin-java classes where applicable
[root@master sbin]#jps
4210 SecondaryNameNode
3973 NameNode
4343 Jps
4061 DataNode
[root@master sbin]#hive
Logging initialized using configuration in jar:file:/usr/local/apache-hive-1.2.1/lib/hive-common-
1.2.1.jar!/hive-log4j.properties
Java HotSpot(TM) Client VM warning: You have loaded library /tmp/libnetty-transport-native-
epoll2358578991288615799.so which might have disabled stack guard. The VM will try to fix the stack
guard now.
It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z
noexecstack'.
[ERROR] Terminal initialization failed; falling back to unsupported
java.lang.IncompatibleClassChangeError: Found class jline.Terminal, but interface was expected
at jline.TerminalFactory.create(TerminalFactory.java:101)
at jline.TerminalFactory.get(TerminalFactory.java:158)
at jline.console.ConsoleReader.<init>(ConsoleReader.java:229)
at jline.console.ConsoleReader.<init>(ConsoleReader.java:221)
at jline.console.ConsoleReader.<init>(ConsoleReader.java:209)
at org.apache.hadoop.hive.cli.CliDriver.setupConsoleReader(CliDriver.java:787)
at org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:721)
at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:681)
at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:621)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.hadoop.util.RunJar.run(RunJar.java:221)
at org.apache.hadoop.util.RunJar.main(RunJar.java:136)
Exception in thread "main" java.lang.IncompatibleClassChangeError: Found class jline.Terminal, but
interface was expected
at jline.console.ConsoleReader.<init>(ConsoleReader.java:230)
at jline.console.ConsoleReader.<init>(ConsoleReader.java:221)
at jline.console.ConsoleReader.<init>(ConsoleReader.java:209)
at org.apache.hadoop.hive.cli.CliDriver.setupConsoleReader(CliDriver.java:787)
at org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:721)
at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:681)
at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:621)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.hadoop.util.RunJar.run(RunJar.java:221)
at org.apache.hadoop.util.RunJar.main(RunJar.java:136)
增加hadoop-env.sh 配置
export HADOOP_USER_CLASSPATH_FIRST=true
export JAVA_HOME=/usr/local/jdk1.8.0_65
export HADOOP_USER_CLASSPATH_FIRST=true
"hadoop-env.sh" 105L, 4309C written
[root@master hadoop]#ls
capacity-scheduler.xml hadoop-env.sh httpfs-env.sh kms-env.sh
mapred-env.sh slaves yarn-site.xml
configuration.xsl hadoop-metrics2.properties httpfs-log4j.properties kms-log4j.properties
mapred-queues.xml.template ssl-client.xml.example
container-executor.cfg hadoop-metrics.properties httpfs-signature.secret kms-site.xml
mapred-site.xml ssl-server.xml.example
core-site.xml hadoop-policy.xml httpfs-site.xml log4j.properties
mapred-site.xml.bak yarn-env.cmd
hadoop-env.cmd hdfs-site.xml kms-acls.xml mapred-env.cmd
mapred-site.xml.template yarn-env.sh
[root@master hadoop]# source ./hadoop-env.sh
[root@master hadoop]#hive
Logging initialized using configuration in jar:file:/usr/local/apache-hive-1.2.1/lib/hive-common-
1.2.1.jar!/hive-log4j.properties
Java HotSpot(TM) Client VM warning: You have loaded library /tmp/libnetty-transport-native-
epoll2494088548290783314.so which might have disabled stack guard. The VM will try to fix the stack
guard now.
It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z
noexecstack'.
hive>
hive> show tables;
OK
Time taken: 5.823 seconds
hive>
hive> show tables;
OK
Time taken: 5.823 seconds
hive> create table a1(a string,b int);
OK
Time taken: 2.19 seconds
hive> create table a2(a string,b int);
OK
Time taken: 0.077 seconds
hive> show tables;
OK
a1
a2
Time taken: 0.07 seconds, Fetched: 2 row(s)
hive>
相关文章推荐
- mysql阅读笔记六
- Hibernate连接MySQL
- MySQL体系结构
- mysql 参数调优
- MySQL添加字段和修改字段的方法
- MySQL核心知识要点
- MySQL核心知识要点
- mysql常用操作
- MySQL优化
- MySQL安装(图文详解)
- mysql 主从同步原理
- MySQL常用指令
- JDBC连接MySQL数据库
- 老李分享:loadrunner操作mysql数据库
- 老李分享:MySql的insert语句的性能优化方案
- mysql二进制安装
- mysql client常见error总结
- mysql设置远程连接用户
- 01.MySQL的安装,配置,卸载(虽然不是做搞数据库,希望可以帮到人)
- mysql分库分表方案浅析