Oracle Linux 7.4虚拟机上Oracle 12c主机名配置问题咨询
Hey there, I’ve been down this exact rabbit hole while setting up Oracle databases on Oracle Linux, so let’s get this hostname mismatch sorted out for you.
Why the Mismatch Happens
Oracle Linux 7 uses systemd to manage hostnames, and there are three types it tracks:
- Static hostname: Stored in
/etc/hostname(this is what Oracle’s docs are referring to) - Transient hostname: A temporary hostname set at runtime (e.g., via the
hostnamecommand without persisting it) - Pretty hostname: A human-readable name (rarely relevant for Oracle installs)
Chances are you changed the transient hostname when configuring the network, but didn’t update the static one stored in /etc/hostname—that’s why the command output and file content don’t align.
Step-by-Step Fix
Check current hostname status
Run this command to see all hostname types and spot the mismatch clearly:hostnamectl statusLook for the
Static hostnameandTransient hostnamefields—one will be the name you set, the other will be the original/old value.Set the static hostname (and sync everything)
Usehostnamectlto set your desired hostname permanently. This command automatically updates/etc/hostnameand aligns all hostname types:hostnamectl set-hostname your-oracle-hostname --staticReplace
your-oracle-hostnamewith the exact hostname you want to use for the Oracle 12c installation.Verify the fix
- Check the
/etc/hostnamefile now should show your desired name:cat /etc/hostname - Run the
hostnamecommand again—it should return the same name as the file:hostname - Re-run
hostnamectl statusto confirm all hostname fields match.
- Check the
Critical Oracle Installation Note
Don’t stop here! Oracle’s installer also relies on the /etc/hosts file to resolve the hostname correctly. Make sure you add a line like this to /etc/hosts:
# Replace with your VM's actual IP address and hostname 192.168.x.x your-oracle-hostname your-oracle-hostname.localdomain
This prevents network-related errors during the Oracle 12c setup process.
内容的提问来源于stack exchange,提问作者need_java

