Article Directory
2.Hive installation
2.1 Hive installation
2.2 HiveJDBC access
2.2.1 Start hiveserver2 service
hiveserver2
2.2.2 Connect to hiveserver2 service
新建命令窗口
, Enter the following command
beeline -u "jdbc:hive2://localhost:10000"
The picture appears to indicate a successful connection
2.2.3 Attention
The error reported here is usually due to insufficient permissions, you only need to empower the tmp and opt folders.
hadoop fs -chmod -R 777 /tmp
hadoop fs -chmod -R 777 /opt
2.3 Hive common interactive commands
1. "-E" Do not enter the interactive window of hive to execute SQL statements
hive -e "查询语句"
2. "-F" executes the sql statement in the script
hive -f sql文件路径/sql文件名称
Execute the sql statement in the file and write the result to the file
hive -f sql文件路径/sql文件名称 > 保存结果的路径
2.4 Hive other command operations
1. Exit the hive window
exit;
quit;
2. How to view in hive cli command windowhdfs文件系统
dfs -ls /;
3. How to view in the hive cli command window本地文件系统
!ls /opt;
2.5 Hive common attribute configuration
2.5.1 Data warehouse location configuration
Modify the value of the hive-site.xml file
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/opt/hive/warehouse</value>
</property>
2.5.2 Information display configuration after query
In hive-site.xml
add the following configuration file, you can display the header information to achieve the current database, and query the table configuration.
<property>
<name>hive.cli.print.header</name>
<value>true</value>
</property>
<property>
<name>hive.cli.print.current.db</name>
<value>true</value>
</property>
Restart hive and compare the differences before and after configuration.
2.5.3 Running log information configuration
- Hive log is stored in the
/tmp/root/hive.log
directory by default (root is the current user name)
- Modify hive log to store logs to
/opt/hive/logs
1. Modify the /opt/hive/conf/hive-log4j.properties.template
file name tohive-log4j.properties
mv hive-log4j.properties.template hive-log4j.properties
2. hive-log4j.properties
Modify the log
storage location in the file
hive.log.dir=/opt/hive/logs
Restart hive