大数据Hive在简书

阿里云搭建CDH(Step 3: 搭建Hive)

2018-08-03  本文已影响0人  阿武z

安装

官方文档

yum install hive hive-metastore hive-server2 -y

PS. 找一台压力小的机器 安装hive

修改Hive配置文件

vim /etc/hive/conf/hive-site.xml

<!-- HiveMetastore --!>
<property>
   <name>javax.jdo.option.ConnectionURL</name>
   <value>jdbc:mysql://worker3:3306/hive_metastore?useUnicode=true&;characterEncoding=UTF-8</value>
</property>
<property>
   <name>javax.jdo.option.ConnectionDriverName</name>
   <value>com.mysql.jdbc.Driver</value>
</property>
<property>
  <name>javax.jdo.option.ConnectionUserName</name>
  <value>hive</value>
</property>
<property>
  <name>javax.jdo.option.ConnectionPassword</name>
  <value>hive</value>
</property>
<property>
  <name>datanucleus.autoCreateSchema</name>
  <value>false</value>
</property>
<property>
  <name>datanucleus.fixedDatastore</name>
  <value>true</value>
</property>
<property>
  <name>datanucleus.autoStartMechanism</name> 
  <value>SchemaTable</value>
</property> 
<property>
  <name>hive.metastore.uris</name>
  <value>thrift://worker3:9083</value>
  <description>IP address (or fully-qualified domain name) and port of the metastore host</description>
</property>
<property>
  <name>hive.metastore.warehouse.dir</name>
  <value>/user/hive/warehouse</value>
</property>

<!-- HiveServer2 --!>
<property>
  <name>hive.support.concurrency</name>
  <value>true</value>
</property>

<property>
  <name>hive.zookeeper.quorum</name>
  <description>Zookeeper quorum used by Hive's Table Lock Manager</description>
  <value>worker1,worker2,worker3</value>
</property>
<property>
  <name>org.apache.hive.jdbc.HiveDriver</name>
  <value>jdbc:worker3:10000</value>
</property>
<property>
  <name>hive.server2.thrift.port</name>
  <value>10001</value>
  <description>TCP port number to listen on, default 10000</description>
</property>

安装mysql社区版

wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql-community-server
# 启动mysql服务
systemctl start mysqld.service
# 查看状态
systemctl status mysqld.service
# 查找密码
grep "password" /var/log/mysqld.log
2018-04-02T03:09:19.238697Z 1 [Note] A temporary password is generated for root@localhost: E*?Lklu0Maup
# 卸载 mysql的yum源
yum -y remove mysql57-community-release-el7-10.noarch


# 登陆mysql
mysql -uroot -pE*?Lklu0Maup

# MySQL有密码设置的规范
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

mysql> set global validate_password_policy=0;
mysql> set global validate_password_length=1;

mysql> SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+-------+
| Variable_name                        | Value |
+--------------------------------------+-------+
| validate_password_check_user_name    | OFF  |
| validate_password_dictionary_file    |      |
| validate_password_length            | 1    |
| validate_password_mixed_case_count  | 1    |
| validate_password_number_count      | 1    |
| validate_password_policy            | LOW  |
| validate_password_special_char_count | 1    |
+--------------------------------------+———+

配置hive登陆账号和 对应数据库

mysql> CREATE DATABASE hive_metastore;
mysql> CREATE USER 'hive'@'worker3' IDENTIFIED BY 'hive';
mysql> REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'hive'@'worker3';
mysql> GRANT ALL PRIVILEGES ON hive_metastore.* TO 'hive'@'worker3';
mysql> FLUSH PRIVILEGES;

初始化hive元数据

sudo yum install mysql-connector-java
ln -s /usr/share/java/mysql-connector-java.jar /usr/lib/hive/lib/mysql-connector-java.jar
/usr/lib/hive/bin/schematool -dbType mysql -initSchema -passWord hive -userName hive

启动服务

sudo service hive-metastore start

sudo -u hdfs hadoop fs -mkdir -p /user/hive
sudo -u hdfs hadoop fs -chmod -R 1775 /user/hive
sudo -u hdfs hadoop fs -mkdir -p /user/hive/warehouse
sudo -u hdfs hadoop fs -chmod -R 1777 /user/hive/warehouse
sudo service hive-server2 start

验证服务

$ /usr/lib/hive/bin/beeline
beeline> !connect jdbc:hive2://worker3:10000 hive hive org.apache.hive.jdbc.HiveDriver
0: jdbc:hive2://worker3:10000> SHOW TABLES;
show tables;
+-----------+
| tab_name  |
+-----------+
+-----------+
No rows selected (0.238 seconds)
0: jdbc:hive2://worker3:10000>
上一篇下一篇

猜你喜欢

热点阅读