您可以嘗試覆蓋連接字符串中的主機。
我在指定的機器定義的「irk1210」「激怒」
[email protected]:/usr3/products/12.10$ grep irk1210 $INFORMIXSQLHOSTS
irk1210shm onipcshm irk irk1210shm
irk1210 onsoctcp 9.20.143.225 3046
dr_irk1210 drsoctcp irk 3047
通過Python(我猜這就是你使用的是什麼),我可以只用「irk1210」作爲服務器名稱連接(信息將從sqlhosts文件領取)
[email protected]:/usr3/products/12.10$ python
Python 2.7.3 (default, Oct 26 2016, 21:04:23)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import informixdb
>>> conn = informixdb.connect('[email protected]',user='informix',password='ximrofni')
>>> print conn
<_informixdb.Connection object at 0x9d287a0>
>>>
或指定服務器的全部信息(服務器/協議/主機/服務)
[email protected]:/usr3/products/12.10$ python
Python 2.7.3 (default, Oct 26 2016, 21:04:23)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import informixdb
>>> conn = informixdb.connect('[email protected]|onsoctcp|9.20.143.225|3046',user='informix',password='ximrofni')
>>> print conn
<_informixdb.Connection object at 0x93c37a0>
>>>
做好後給你指定的服務器不同的主機(IP)的選項:
[email protected]:/usr3/products/12.10$ python
Python 2.7.3 (default, Oct 26 2016, 21:04:23)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import informixdb
>>> conn = informixdb.connect('[email protected]|onsoctcp|10.1.1.10|3046',user='informix',password='ximrofni')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
_informixdb.OperationalError: SQLCODE -908 in CONNECT:
08004: Client unable to establish connection
IX000: ISAM error: record is locked.
>>>
我得到了一個錯誤-908,因爲我有沒有10.1.1.10服務器,但它種證明驅動程序試圖連接到比SQLHOSTS爲irk1210服務器
它可以指定一個不同的IP!謝謝!!你救了我的命! – Urkidy
我認爲這比sqlhosts env hack更好8) –
是的!哈哈thx! – Urkidy