检测是否安装了 Oracle 数据库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/304960/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Detecting if an Oracle Database is Installed
提问by Christopher McAtackney
I was wondering if there was a way to tell if an instance of Oracle on a system has a database installed or not?
我想知道是否有办法判断系统上的 Oracle 实例是否安装了数据库?
This is for an installation script, and I need to verify that there is an actual database in place before proceeding with the loading of my own tablespace onto that database. Has anyone tackled this problem before?
这是一个安装脚本,在继续将我自己的表空间加载到该数据库之前,我需要验证是否存在实际的数据库。以前有人解决过这个问题吗?
Cheers
干杯
采纳答案by ConcernedOfTunbridgeWells
Check for the existence of an ORACLE_HOME. It's also reasonable to expect that this environment should be configured for the installation, so testing the environment variables and exiting with a sensible diagnostic (possibly suggesting they run oraenv) is a good first start. If you have an ORACLE_HOME, ORACLE_SID or other appropriate environment variable set up, you can then check for the existence of an oracle home and test for database connectivity and permissions.
检查 ORACLE_HOME 是否存在。期望应该为安装配置此环境也是合理的,因此测试环境变量并以合理的诊断退出(可能暗示它们运行 oraenv)是一个好的开始。如果您设置了 ORACLE_HOME、ORACLE_SID 或其他适当的环境变量,则可以检查 oracle home 是否存在并测试数据库连接和权限。
回答by Mac
For Oracle 10g, on Windows :
对于 Oracle 10g,在 Windows 上:
- Check the registry :
- The key
HKLM\SOFTWARE\ORACLE
must exist. - A subkey must exist that :
- Has a name starting with
KEY_
(likeKEY_OraDb10g_home1
, the end string being an Oracle home name). - Has a value whose name starts with
ORA_
and ends with_AUTOSTART
. (likeORA_XE_AUTOSTART
, the middle string being an instance name).
- Has a name starting with
- The key
- 检查注册表:
- 密钥
HKLM\SOFTWARE\ORACLE
必须存在。 - 必须存在一个子项:
- 具有以开头的名称
KEY_
(例如KEY_OraDb10g_home1
,结束字符串是 Oracle 主名称)。 - 具有名称以 开头
ORA_
和结尾的值_AUTOSTART
。(例如ORA_XE_AUTOSTART
,中间字符串是实例名称)。
- 具有以开头的名称
- 密钥
Beware, installing an Oracle client (without a database instance then), creates entries in the registry and can set environment variables (like ORACLE_HOME
). This is why the above pattern is a bit complicated.
请注意,安装 Oracle 客户端(那时没有数据库实例)会在注册表中创建条目并可以设置环境变量(如ORACLE_HOME
)。这就是为什么上述模式有点复杂的原因。
This pattern is very likely to work for Oracle 9i also, and possibly Oracle 8i.
这种模式很可能也适用于 Oracle 9i,也可能适用于 Oracle 8i。
回答by ninesided
You could use tnsping
to check whether the database listener is active, that would be a good indication. Other than that, why not just simply do a test connection? If it's part of an installer process, you could prompt the user to enter the appropriate connection credentials if you don't know what they'll be in advance.
您可以tnsping
用来检查数据库侦听器是否处于活动状态,这将是一个很好的指示。除此之外,为什么不简单地进行测试连接呢?如果它是安装程序过程的一部分,如果您事先不知道它们将是什么,您可以提示用户输入适当的连接凭据。
回答by ninesided
Look up the /etc/oratab file for oracle homes.These homes have the database software installed as well as the database name from that home.Then you can check whether the database is sound or not by starting it.
查找oracle home 的/etc/oratab 文件。这些home 安装了数据库软件以及该home 的数据库名称。然后您可以通过启动它来检查数据库是否健全。
回答by Maha
I'm not sure about Oracle, but for MySQL and PostgreSql I do the following:
我不确定 Oracle,但对于 MySQL 和 PostgreSql,我执行以下操作:
$yum grouplist | grep SQL
This returns:
这将返回:
MySQL Database client
MySQL Database server
PostgreSQL Database client
PostgreSQL Database server
So I assume you should try:
所以我认为你应该尝试:
$yum grouplist | grep Orac