当前位置: 代码迷 >> MySQL >> Hive And MySQL安装及设立
  详细解决方案

Hive And MySQL安装及设立

热度:274   发布时间:2016-05-05 16:47:09.0
Hive And MySQL安装及设置

?

?Hive安装

?

解压

[[email protected] local]# tar -zxvf hive-0.9.0

?配置/etc/profile环境变量

export HIVE_HOME=/usr/local/hive-0.9.0export PATH=.:$HADOOP_HOME/bin:$HBASE_HOME/bin:$JAVA_HOME/bin:$HIVE_HOME/bin:$PATH[[email protected] local]# source /etc/profile

修改hadoop中hadoop-env.sh文件

 export HADOOP_CLASSPATH==.:$CLASSPATH:$HADOOP_CLASSPATH:$HADOOP_HOME/bin

修改配置文件名称

[[email protected] conf]# pwd/usr/local/hive-0.9.0/conf[[email protected] conf]# mv hive-default.xml.template hive-site.xml[[email protected] conf]# mv hive-env.sh.template hive-env.sh

?修改hive-config.xml配置文件,暴露java、hive、hadoop

[[email protected] bin]# vim hive-config.sh[[email protected] bin]# more hive-config.shexport JAVA_HOME=/usr/local/jdk1.6.0_24export HIVE_HOME=/usr/local/hive-0.9.0export HADOOP_HOME=/usr/local/hadoop-1.1.2

如果需要修改HDFS默认的存储位置hive-site.xml文件中

<property>  <name>hive.metastore.warehouse.dir</name>  <value>/hive</value>  <description>location of default database for the warehouse</description></property>

执行hvie命令进入CLI

[[email protected] bin]# hiveWARNING: org.apache.hadoop.metrics.jvm.EventCounter is deprecated. Please use org.apache.hadoop.log.metrics.EventCounter in all the log4j.properties files.Logging initialized using configuration in jar:file:/usr/local/hive-0.9.0/lib/hive-common-0.9.0.jar!/hive-log4j.propertiesHive history file=/tmp/root/hive_job_log_root_201508170333_222296555.txthive>

?

安装MySQL

?

删除Linux上已经安装的MySQL

?

#查看是否有mysql[[email protected] conf]# rpm -qa | grep mysqlmysql-libs-5.1.66-2.el6_3.i686#删除时有依赖[[email protected] conf]# rpm -e mysql-libs-5.1.66-2.el6_3.i686error: Failed dependencies:        libmysqlclient.so.16 is needed by (installed) postfix-2:2.6.6-2.2.el6_1.i686        libmysqlclient.so.16(libmysqlclient_16) is needed by (installed) postfix-2:2.6.6-2.2.el6_1.i686        mysql-libs is needed by (installed) postfix-2:2.6.6-2.2.el6_1.i686#前置删除[[email protected] conf]# rpm -e mysql-libs-5.1.66-2.el6_3.i686 --nodeps
?安装MySQL服务端
[[email protected] local]# rpm -i MySQL-server-5.5.31-2.el6.i686.rpmPLEASE 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 centos password 'new-password'Alternatively you can run:/usr/bin/mysql_secure_installationwhich will also give you the option of removing the testdatabases and anonymous user created by default.  This isstrongly recommended for production servers.See the manual for more instructions.Please report any problems with the /usr/bin/mysqlbug script!

?启动MySQL

[[email protected] local]# mysqld_safe &

设置MySQL密码

[[email protected] local]# mysql_secure_installationSet root password? [Y/n] YRemove anonymous users? [Y/n] nDisallow root login remotely? [Y/n] nRemove test database and access to it? [Y/n] nReload privilege tables now? [Y/n] Y

?安装MySQL客户端

[[email protected] local]# rpm -i MySQL-client-5.5.31-2.el6.i686.rpm

? 登录

[[email protected] local]# mysqlERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)[[email protected] local]# mysql -uroot -proot

?

使用MySQL作为Hive的metastroe

把mysql的jdbc驱动放置到hive的lib目录下

[[email protected] local]# cp mysql-connector-java-5.1.10.jar /usr/local/hive-0.9.0/lib/

?修改hive-site.xml文件

        <property>		<name>javax.jdo.option.ConnectionURL</name>		<value>jdbc:mysql://centos:3306/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>root</value>	</property>

?让MySQL的root用户允许远程连接访问

mysql> grant all on hive.* to 'root'@'%' identified by 'root';Query OK, 0 rows affected (0.15 sec)mysql> flush privileges;Query OK, 0 rows affected (0.00 sec)

?在MySQL查看hive所创建的表

mysql> show databases;+--------------------+| Database           |+--------------------+| information_schema || hive               || mysql              || performance_schema || test               |+--------------------+5 rows in set (0.02 sec)mysql> use hiveReading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changedmysql> show tables;+-----------------+| Tables_in_hive  |+-----------------+| BUCKETING_COLS  || CDS             || COLUMNS_V2      || DATABASE_PARAMS || DBS             || PARTITION_KEYS  || SDS             || SD_PARAMS       || SEQUENCE_TABLE  || SERDES          || SERDE_PARAMS    || SORT_COLS       || TABLE_PARAMS    || TBLS            |+-----------------+14 rows in set (0.00 sec)

?

?

?

?

?

?

?

?

?

?

?

?

  相关解决方案