一、安装前准备 1. 安装配置Hadoop,见http://blog.csdn.net/wzy0623/article/details/50681554 2. 下载安装包 mysql-5.7.10-linux-glibc2.5-x86_64 apache-hive-1.2.1-bin.tar.gz mysql-connector-java-5.1.38.tar.gz 二、安装MySQL 1. 解压 tar -zxvf mysql-5.7.10-linux-glibc2.5-x86_64.tar.gz 2. 建立软连接 ln -s /home/grid/mysql-5.7.10-linux-glibc2.5-x86_64 mysql 3. 建立数据目录 mkdir /home/grid/mysql/data 4. 编辑配置文件~/.my.cnf内容如下 [mysqld] basedir=/home/grid/mysql datadir=/home/grid/mysql/data log_error=/home/grid/mysql/data/master.err log_error_verbosity=2 5. 初始化安装,并记下初始密码 mysqld --defaults-file=/home/grid/.my.cnf --initialize 6. 启动MySQL mysqld --defaults-file=/home/grid/.my.cnf --user=grid & 7. 登录MySQL,修改初始密码 mysql -u root -p mysql> ALTER USER USER() IDENTIFIED BY 'new_password'; mysql> exit; 8. 在/etc/profile中添加环境变量 export PATH=$PATH:/home/grid/mysql/bin 三、安装配置hive 1. 解压 tar -zxvf apache-hive-1.2.1-bin.tar.gz 2. 建立软连接 ln -s /home/grid/apache-hive-1.2.1-bin hive 3. 建立临时目录 mkdir /home/grid/hive/iotmp 4. 建立配置文件hive-site.xml cp ~/hive/conf/hive-default.xml.template ~/hive/conf/hive-site.xml 5. 新建配置文件hive-site.xml,内容如下:
代码语言:javascript复制<?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://127.0.0.1:3306/hive?createDatabaseIfNotExist=true&useSSL=false</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> new_password</value>
</property>
<property>
<name>hive.cli.print.current.db</name>
<value>true</value>
</property>
</configuration>
6. 拷贝JDBC驱动 tar -zxvf mysql-connector-java-5.1.38.tar.gz ln -s mysql-connector-java-5.1.38 connector cp /home/grid/connector/mysql-connector-java-5.1.38-bin.jar /home/grid/hive/lib/ 7. 在/etc/profile中添加环境变量 export HIVE_HOME=/home/grid/hive export PATH=$PATH:$HIVE_HOME/bin 8. 重新登录Liunx,运行hive,结果如图1所示 hive hive> show databases;
图1