Ubuntu 15.10环境下安装Hive
1. 安装MySQL
sudo tar -xzvf mysql-5.7.13-linux-glibc2.5-x86_64.tar.gz
sudo mv mysql-5.7.13-linux-glibc2.5-x86_64 /usr/local/
cd /usr/local/
mv mysql-5.7.13-linux-glibc2.5-x86_64/ mysql
sudo groupadd mysql
sudo useradd -r -g mysql mysql
sudo chown -R mysql:mysql mysql/
#sudo ./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data
sudo apt-get install libaio1 libaio-dev
#缺少依赖包
sudo ./bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data
2. 配置MySQL
cp support-files/my-default.cnf my.cnf
vim my.cnf
在my.cnf中配置basedir datadir port三项,设置如下
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
port = 3306
cp my.cnf /etc/my.cnf
cp support-files/mysql.service /etc/init.d/mysql
/etc/init.d/mysql由于路径不是默认路径,需要更改配置
vim /etc/init.d/mysql
做如下更改:
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
3. 添加服务自启动
update-rc.d mysql defaults
update-rc.d mysql enable
#添加环境变量
vim /etc/profile
export MYSQL_HOME=/usr/local/mysql
export PATH=$MYSQL_HOME/bin:$PATH
source /etc/profile
#启动服务
service mysql start
service mysql status
4. apt-get 安装Mysql
安装路径:/usr/share/mysql目录下
mysqldump文件位置:/usr/bin/mysqldump
mysql配置文件:
/etc/mysql/my.cnf或/usr/share/mysql/my.cnf
mysql数据目录在/var/lib/mysql目录下
5. Hive安装及配置
5.1 安装及配置
解压更改配置文件,
cd /hive/conf
vim hive-site.xml
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://localhost:3306/hive_metadata?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>hive</value>
<description>Username to use against metastore database</description>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>hive</value>
<description>Password to use against metastore database</description>
</property>
<property>
<name>hive.metastore.uris</name>
<value>thrift://localhost:9083</value>
<description>Thrift URI for the remote metastore. Used by metastore client to connect to remote metastore.</description>
</property>
<!--
<property>
<name>hive.metastore.uris</name>
<value>thrift://master(localhost):9083</value>
</property>
-->
5.2 创建Hive用户
1)删除匿名用户(否则有可能对后面的hive用户造成影响)
use mysql
delete from user where USER='';
flush privileges;
2)加用户并授权
create user hive identified by "hive";
grant all on *.* to hive;
--GRANT ALL PRIVILEGES ON *.* TO 'hive'@'master' WITH GRANT OPTION;
3)创建数据库
create database hive;
4)测试登录
用安装hadoop的用户登录,执行
mysql -uhive -phive
--mysql -h master -uhive -p
show databases;
use hive;
如果出现:
ERROR 1044 (42000): Access denied foruser ''@'localhost' to database 'hive'
说明使用匿名账号登陆的。
5.3启动
#后台启动
hive --service metastore &
#错误处理:
bin/schematool -dbType mysql -initSchema