非Hadoop用户运行Hive报错,如何修改inode目录为/user/fratboy?
Hey there! Let's work through your Hive problems one by one—first that SLF4J warning, then configuring the correct HDFS directory for your fratboy user.
1. Resolve the SLF4J Multiple Bindings Warning
That warning pops up because both Hadoop and Hive include SLF4J logging implementations, and they're conflicting. It's mostly a nuisance, but fixing it will clean up your logs. Here's how:
- Head to your Hive lib directory:
/usr/local/hadoop/hive/lib - Move the conflicting log4j-slf4j-impl jar to a backup so it's no longer on the classpath:
mv /usr/local/hadoop/hive/lib/log4j-slf4j-impl-2.6.2.jar /usr/local/hadoop/hive/lib/log4j-slf4j-impl-2.6.2.jar.bak
This removes Hive's SLF4J binding, letting Hadoop's take over (since they should be compatible).
2. Configure Hive to Use /user/fratboy as Its Base Directory
To stop Hive from trying to access root directories, you need to update its core configuration file (hive-site.xml). Here's the step-by-step:
Step 1: Edit hive-site.xml
Find the config file in your Hive conf directory (usually /usr/local/hadoop/hive/conf). Open it in a text editor and add or modify these properties:
<property> <name>hive.metastore.warehouse.dir</name> <value>hdfs://localhost:9000/user/fratboy/warehouse</value> <description>Location of default database for the warehouse</description> </property> <property> <name>hive.exec.scratchdir</name> <value>hdfs://localhost:9000/user/fratboy/hive/scratch</value> <description>Scratch space for Hive jobs</description> </property>
(Note: Adjust the HDFS URL hdfs://localhost:9000 to match your cluster's actual address if needed.)
Step 2: Create and Set Permissions for HDFS Directories
Even though you've created /user/fratboy, Hive needs specific subdirectories. Run these commands as fratboy (or use sudo -u fratboy):
# Create required subdirectories hdfs dfs -mkdir -p /user/fratboy/warehouse hdfs dfs -mkdir -p /user/fratboy/hive/scratch # Set ownership (already done for the parent, but double-check) hdfs dfs -chown -R fratboy:fratboy /user/fratboy # Set proper permissions hdfs dfs -chmod -R 755 /user/fratboy/warehouse # Read/write for owner, read for others hdfs dfs -chmod -R 777 /user/fratboy/hive/scratch # Temp dir needs universal write access
Step 3: Restart Hive (if running as a service)
If you have Hive services (like metastore) running, restart them to apply the new config. If you're just running the Hive CLI, close and reopen it.
Once you've done these steps, running Hive as fratboy should no longer try to access root directories, and that SLF4J warning should be gone!
内容的提问来源于stack exchange,提问作者Under Memphis

