【已解决】SSH 登陆数据库

[复制链接]
查看11 | 回复9 | 2008-2-26 15:11:15 | 显示全部楼层 |阅读模式
A,B,C三个机器. A做数据库服务器, 运行linux+oracle10g; B做应用服务器, 运行linux+一个C++程序(暂时称为app)+Oracle Client; C作Web Portal.
希望达到如下效果: 客户端通过浏览器登陆C, 给C一个参数(比如, 一个整数:177)并由C通过SSH的方式传给B的app, app再拿这个参数使用oci的方式去访问数据库, 完成之后把结果给C, 最后结果再由C给用户.
出现如下问题: app可以接受到C传递过来的参数, 并且可以执行部分语句, 但是登陆数据库的语句总是不正常, 在C上, 可以看到如下错误:
Error while trying to retrieve text for error ORA-12154
__________________
在B上, 打开终端:执行./app 177. 结果正确返回.
在另外一个linux主机上, 打开终端:执行ssh oracle@[B] /$APP_HOME/bin/app 177. 也会返回上面的错误。
请问各位如何解决这个问题。
[ 本帖最后由 ruluo 于 2008-9-19 19:23 编辑 ]
回复

使用道具 举报

千问 | 2008-2-26 15:11:15 | 显示全部楼层
只能猜了
象是oracle 用户环境变量的事
在B上能返回数据的时候,用的是oracle 用户?
回复

使用道具 举报

千问 | 2008-2-26 15:11:15 | 显示全部楼层
环境变量我检查了, 没有问题。
在B上执行的时时候, 用的是Oracle用户。
回复

使用道具 举报

千问 | 2008-2-26 15:11:15 | 显示全部楼层
有没有人这么做:
在另外一个linux主机上, 打开终端:执行ssh oracle@[B] "sqlplus / as sysdba" 来登陆数据库.
我在一个两节点RAC(两个节点上的各个环境变量、目录结构都是一样的)上做了测试:
[oracle@rac1 ~]$ ssh 10.0.38.123 hostname
rac2
[oracle@rac1 ~]$ ssh 10.0.38.123 date
Fri Sep 19 22:14:02 CST 2008
[oracle@rac1 ~]$ ssh 10.0.38.123 "sqlplus / as sysdba"
bash: sqlplus: command not found
[oracle@rac1 ~]$ ssh 10.0.38.123 "lsnrctl stat"
bash: lsnrctl: command not found
[oracle@rac1 ~]$ ssh 10.0.38.123 "/u01/app/oracle/product/10.2.0/db_1/bin/lsnrctl stat"
LSNRCTL for Linux: Version 10.2.0.2.0 - Production on 19-SEP-2008 22:14:51
Copyright (c) 1991, 2005, Oracle.All rights reserved.
Message 1053 not found; No message file for product=network, facility=TNSMessage 1020 not found; No message file for product=network, facility=TNSMessage 1021 not found; No message file for product=network, facility=TNSMessage 1022 not found; No message file for product=network, facility=TNSMessage 1023 not found; No message file for product=network, facility=TNSMessage 1026 not found; No message file for product=network, facility=TNSMessage 1034 not found; No message file for product=network, facility=TNSMessage 1024 not found; No message file for product=network, facility=TNSMessage 1025 not found; No message file for product=network, facility=TNSMessage 1040 not found; No message file for product=network, facility=TNSMessage 1033 not found; No message file for product=network, facility=TNSMessage 1028 not found; No message file for product=network, facility=TNSMessage 1415 not found; No message file for product=network, facility=TNSMessage 1050 not found; No message file for product=network, facility=TNS
Message 1050 not found; No message file for product=network, facility=TNS
Message 1029 not found; No message file for product=network, facility=TNSMessage 1411 not found; No message file for product=network, facility=TNS
Message 1408 not found; No message file for product=network, facility=TNS
Message 1411 not found; No message file for product=network, facility=TNS
Message 1408 not found; No message file for product=network, facility=TNS
Message 1411 not found; No message file for product=network, facility=TNS
Message 1408 not found; No message file for product=network, facility=TNS
Message 1411 not found; No message file for product=network, facility=TNS
Message 1408 not found; No message file for product=network, facility=TNS
Message 1408 not found; No message file for product=network, facility=TNS
Message 1411 not found; No message file for product=network, facility=TNS
Message 1408 not found; No message file for product=network, facility=TNS
Message 1408 not found; No message file for product=network, facility=TNS
Message 1411 not found; No message file for product=network, facility=TNS
Message 1408 not found; No message file for product=network, facility=TNS
Message 1408 not found; No message file for product=network, facility=TNS
Message 1411 not found; No message file for product=network, facility=TNS
Message 1408 not found; No message file for product=network, facility=TNS
Message 1408 not found; No message file for product=network, facility=TNS
Message 1411 not found; No message file for product=network, facility=TNS
Message 1408 not found; No message file for product=network, facility=TNS
Message 1408 not found; No message file for product=network, facility=TNS
Message 1411 not found; No message file for product=network, facility=TNS
Message 1408 not found; No message file for product=network, facility=TNS
Message 1408 not found; No message file for product=network, facility=TNS
Message 1411 not found; No message file for product=network, facility=TNS
Message 1408 not found; No message file for product=network, facility=TNS
Message 1408 not found; No message file for product=network, facility=TNS
Message 1411 not found; No message file for product=network, facility=TNS
Message 1408 not found; No message file for product=network, facility=TNS
Message 1408 not found; No message file for product=network, facility=TNS
Message 1052 not found; No message file for product=network, facility=TNS[oracle@rac1 ~]$
[oracle@rac1 ~]$ ssh 10.0.38.123 "/u01/app/oracle/product/10.2.0/db_1/bin/sqlplus / as sysdba"
Error 6 initializing SQL*Plus
Message file sp1.msb not found
SP2-0750: You may need to set ORACLE_HOME to your Oracle software directory
[oracle@rac1 ~]$
这些又表明什么呢?
[ 本帖最后由 ruluo 于 2008-9-18 22:40 编辑 ]
回复

使用道具 举报

千问 | 2008-2-26 15:11:15 | 显示全部楼层
在10.0.38.123 的home目录做个脚本:mysqlplus.sh
#!/bin/bash
source ~/.bash_profile
sqlplus / as sysdba

然后 ssh 10.0.38.123 mysqlplus.sh
[ 本帖最后由 netbbs 于 2008-9-19 09:42 编辑 ]
回复

使用道具 举报

千问 | 2008-2-26 15:11:15 | 显示全部楼层
是的,环境变量没有获得。可以加到用户的.profile里,这样一登录就获得了。
回复

使用道具 举报

千问 | 2008-2-26 15:11:15 | 显示全部楼层
多谢楼上2位, 我已经做了如下测试:
在10.0.38.123上:
[oracle@rac2 ~]$ ifconfig eth0 | grep 'inet addr'

inet addr:10.0.38.123Bcast:10.0.38.255Mask:255.255.255.0
[oracle@rac2 ~]$ ls
1.shDesktoporaInventory
[oracle@rac2 ~]$ cat 1.sh
#!/bin/bash
source ~/.bash_profile
sqlplus -S / as sysdba <<EOF
select instance_name,status from v\$instance;
exit
EOF
[oracle@rac2 ~]$
在10.0.38.122上:
[oracle@rac1 ~]$ ifconfig eth0 | grep 'inet addr'

inet addr:10.0.38.122Bcast:10.0.38.255Mask:255.255.255.0
[oracle@rac1 ~]$ ssh 10.0.38.123 /home/oracle/1.sh
INSTANCE_NAMESTATUS
---------------- ------------
dbrac2 OPEN
[oracle@rac1 ~]$
我再去试试真正的环境去
[ 本帖最后由 ruluo 于 2008-9-19 10:12 编辑 ]
回复

使用道具 举报

千问 | 2008-2-26 15:11:15 | 显示全部楼层
那不就行了,就在你的B机上把app改一下好了,环境变量放进去。
回复

使用道具 举报

千问 | 2008-2-26 15:11:15 | 显示全部楼层
或者象6楼的说的,改.profile也可以。
回复

使用道具 举报

千问 | 2008-2-26 15:11:15 | 显示全部楼层
我是rhel4-u6, 你说的.profile在什么地方?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行