This notebook contains instruction on how to use the Hadoop cluster from the command line
# Setup
## Authentication
The Hadoop cluster uses Kerberos for authentication. You need to initialize your credentials with Kerberos to be able to connect to the Hadoop platform.
### Initializing credentials
You have to run the `kinit` command in a regular terminal.
This can't be run in a notebook because it will ask for your password.
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/hadoop-3.2.3/share/hadoop/common/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/tez-0.10.1/lib/slf4j-log4j12-1.7.30.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/hive-3.1.2/lib/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
2024-11-25 10:45:19,596 WARN erasurecode.ErasureCodeNative: ISA-L support is not available in your platform... using builtin-java codec where applicable
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/hadoop-3.2.3/share/hadoop/common/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/tez-0.10.1/lib/slf4j-log4j12-1.7.30.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/hive-3.1.2/lib/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
2024-11-25 10:39:25,751 WARN erasurecode.ErasureCodeNative: ISA-L support is not available in your platform... using builtin-java codec where applicable
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/hadoop-3.2.3/share/hadoop/common/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/tez-0.10.1/lib/slf4j-log4j12-1.7.30.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/hive-3.1.2/lib/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
2024-11-25 10:46:33,439 INFO fs.TrashPolicyDefault: Moved: 'hdfs://hsrv04.pic.es:9000/user/torradeflot/test_1M' to trash at: hdfs://hsrv04.pic.es:9000/user/torradeflot/.Trash/Current/user/torradeflot/test_1M1732527993433
Beeline is an interactive CLI to explore Hive. Since it is interactive it is a bit tricky to run it within python cells and get the stderr and stdout printed out.
This is how it would look if you run it in a terminal
### Open beeline
[torradeflot@td835 hadoop-3.2.3]$ beeline
...
Connecting to jdbc:hive2://hsrv01.pic.es:10000/default;principal=hive/_HOST@PIC.ES
This has been done for demostrative purposes but it is not convenient. **Use beeline in a shell or a proper python client to submit queries to Hive**
Since the Hive CLI is interactive, it is not possible to run it from jupyter notebook. However, we can run it in a python subprocess and pipe the stdin, stdout, stderr.
The next cell is an equivalent to launching a Beeline CLI in the shell