查看postgresql 安装情况
[root@localhost hive]# rpm -qa | grep postgresql
postgresql-9.2.4-1.fc19.x86_64
postgresql-libs-9.2.4-1.fc19.x86_64
postgresql-server-9.2.4-1.fc19.x86_64
# yum install postgresql
为 hive 提供 postgresql 驱动
[root@localhost Downloads]# cp postgresql-9.2-1003.jdbc4.jar /usr/lib/hive/lib/
使用 超级用户 postgres 为 hive 创建用户和数据库
[yuming@localhost all-in-one]$ sudo -u postgres psql
[sudo] password for yuming:
could not change directory to "/home/yuming/Downloads/all-in-one"
psql (9.2.4)
Type "help" for help.
postgres=# CREATE USER hive WITH PASSWORD 'hvie';
CREATE ROLE
postgres=# create database metastore owner=hive;
CREATE DATABASE
postgres=# grant all on database metastore to hive;
GRANT
postgres=# \c metastore
You are now connected to database "metastore" as user "postgres".
metastore=# \i /usr/lib/hive/scripts/metastore/upgrade/postgres/hive-schema-0.10.0.postgres.sql
重起数据库,如果不是 root 用户需要先切换到 root 用户
[root@localhost data]# su postgres
bash-4.2$ /usr/bin/pg_ctl -D /var/lib/pgsql/data restart
waiting for server to shut down.... done
server stopped
server starting
怎么老错:
bash-4.2$ sudo -u hive pgsql
[sudo] password for postgres:
Sorry, try again.
改个密码
[root@localhost hive]# sudo -u postgres psql postgres
could not change directory to "/home/yuming/hive"
psql (9.2.4)
Type "help" for help.
postgres=# \password postgres
Enter new password:
Enter it again:
postgres=#
[root@localhost hive]# sudo -u hive psql metastore
could not change directory to "/home/yuming/hive"
psql (9.2.4)
Type "help" for help.
metastore=> \t
Showing only tuples.
metastore=> \db
pg_default | postgres |
pg_global | postgres |
metastore=> \dt
public | BUCKETING_COLS | table | hive
public | CDS | table | hive
HDFS 中没有表 salerecord 对应的目录,metastore中有就可以了
[root@localhost ~]# hive -e "load data local inpath '/root/sal.txt' OVERWRITE into table salerecord partition (reco='20');"
导数据时会自动创建:
drwxr-xr-x - root hadoop 0 2013-07-30 14:10 /user/hive/warehouse/salerecord
drwxr-xr-x - root hadoop 0 2013-07-30 14:10 /user/hive/warehouse/salerecord/reco=20130525
-rw-r--r-- 3 root hadoop 977161793 2013-07-30 14:10 /user/hive/warehouse/salerecord/reco=20130525/sal.txt
但还不知道在元数据哪个表中
eac:</