Hive (two) Hive installation

2.Hive installation

2.1 Hive installation

"Hive Installation Tutorial"

2.2 HiveJDBC access

2.2.1 Start hiveserver2 service

hiveserver2

image-20200916143756819

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

image-20200916144644772

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 /;

image-20200916150426537

3. How to view in the hive cli command window本地文件系统

!ls /opt;

image-20200916151233406

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.xmladd 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.

image-20200916153135946

image-20200916154010571

2.5.3 Running log information configuration

  • Hive log is stored in the /tmp/root/hive.logdirectory by default (root is the current user name)

image-20200916155105713

  • Modify hive log to store logs to/opt/hive/logs

1. Modify the /opt/hive/conf/hive-log4j.properties.templatefile name tohive-log4j.properties

mv hive-log4j.properties.template hive-log4j.properties

2. hive-log4j.propertiesModify the logstorage location in the file

hive.log.dir=/opt/hive/logs

image-20200916155615882

Restart hive

image-20200916160113010

Guess you like

Origin blog.csdn.net/zmzdmx/article/details/108628446