问题
It has taken me weeks to solve this so I thought I would share:
I am hosting an Apex app on Oracle XE using Google compute CentOS image. I was trying to get a second server going using a snapshot but found that once created I got connect refused.
The database was running and I had not changed any firewall rules on centOS or Google Compute so could not understand how it would not work.
I spent weeks blaming the two firewalls.
回答1:
It turns out the Oracle stores host information in files used when the database starts and if this does not match the current server then the listener either will not be running or will be listening for the wrong things.
There are quite a few documents and help articles dealing with problems in these setup files "tnsnames.ors" and "listener.ora" but they are complex and at times contradictory. but there is one simple trick to get Oracle to fix it for you.
One off Fix:
All you have to do is rename the Listener.ora file to somthing else i.e. listener.ora.old and restart the DB and it will use the current servers host details and start working again.
If you need your VM to always work regardless of its hostname and IP
Simply rename the file as above before you create the snapshot then any new server will fix itself the first time it starts up.
Versions Tested
Oracle XE 11g Release 2
CentOS v7
Google Compute Engine Sep-2017
Hope it helps
来源:https://stackoverflow.com/questions/46107343/oracle-xe-stops-working-when-host-name-chages