Cygwin下Hive元数据初始化失败:找不到主类FAMILY求助
This error almost certainly stems from spaces in your Windows username causing path parsing issues in Cygwin—just like you suspected from your earlier Hadoop troubles. Here's how to fix it step by step:
1. Confirm the root cause
First, check if your user directory has spaces by running this in Cygwin:
echo $HOME
If the output looks something like /cygdrive/c/Users/John Doe, the space in your username is breaking path references in Hive/Hadoop configuration.
2. Update Hive's log directory to a space-free path
Hive defaults to storing logs in a subdirectory of your user home, which includes spaces. Fix this by:
- Navigate to Hive's config directory:
cd $HIVE_HOME/conf - If you don’t have a
hive-env.shfile, copy the template:cp hive-env.sh.template hive-env.sh - Edit
hive-env.shand add this line (replace the path with any space-free directory you’ve created):export HIVE_LOG_DIR=/cygdrive/e/big-data/hive-logs - Make sure the directory exists:
mkdir -p /cygdrive/e/big-data/hive-logs
3. Fix Hadoop's log directory (if needed)
Hadoop might also be using your space-containing home directory for logs. Open $HADOOP_HOME/etc/hadoop/hadoop-env.sh and update HADOOP_LOG_DIR to a space-free path using the same method as above.
4. Secure environment variables with quotes
Update your ~/.bashrc to wrap classpath definitions in quotes, preventing space-related splitting:
export HADOOP_CLASSPATH="$HADOOP_CLASSPATH:$HIVE_HOME/lib/*.jar"
Then reload your bash profile to apply changes:
source ~/.bashrc
5. Re-run the schematool command
Switch to Hive's bin directory and execute the initialization command directly to avoid path parsing quirks:
cd $HIVE_HOME/bin ./schematool -dbType derby -initSchema
Why this works
When your username has spaces, default paths (like log directories) include those spaces. Java treats spaces in classpath/path arguments as separators, so it ends up trying to load a "main class" that’s actually just the second half of your username (hence the FAMILY in your error). By moving these paths to space-free locations and quoting environment variables, you eliminate this parsing issue.
内容的提问来源于stack exchange,提问作者Chyle Andrei Lee

