TimesTen的逻辑服务器名概念

概念

TimesTen中逻辑服务器名(logical server name)的概念用的很少,但是了解一下还是必要的。
首先,logical server是在客户端定义,指向服务器端。
其次,当用非TCP/IP的通讯协议或者TimesTen Server不在缺省的端口监听时,必须使用logical server name。

TimesTen的逻辑服务器名概念_第1张图片

A logical server name is a definition for a server system on the TimesTen Client. In some cases, such as when using a communication protocol other than TCP/IP for local client/server or the TimesTen Server process is not listening on the default TCP/IP port, you must define a logical server name on the client system. In these cases, the Client DSN must refer to the logical server name. However, in most cases when the communication protocol used is TCP/IP, the Client DSN can refer directly to the server host name without having to define a logical server name.

logical server的配置在sys.ttconnect.ini文件中定义。例如:

$ cat sys.ttconnect.ini
# Copyright (c) 1999, 2009, Oracle and/or its affiliates.All rights reserved. 

############################################################### # This is a sample sys.ttconnect.ini file that is used for the # TimesTen Client. It contains entries for each server. ###############################################################

[ttLocalHost_tt1122]
Description=TimesTen Server
Network_Address=ttLocalHost
TCP_PORT=53393

在本例中, 由于是32位版本,因此TCP_PORT中的53393是缺省端口。
值得一说的是Network_Address:
ttLocalHost表示使用Unix Domain socket通讯
ttShmHost表示使用shared memory进行IPC通讯
Network_Address也可以定义为主机名或IP地址

示例

在本例中我们在一台VM中安装了两个TimesTen示例tt1122和ttnew,第一个使用缺省的端口53392。由于缺省端口已占用,第二个使用的是另外的端口号55555。

$ cat /etc/TimesTen/instance_info 
#SUM 55602 1
[ tt1122 ]
Product=TimesTen11.2.2.6.2
InstallDir=/home/oracle/TimesTen/tt1122
InstanceAdministrator=oracle
DaemonHome=/home/oracle/TimesTen/tt1122/info
BitLevel=64
Component=Client/Server and DataManager
TT_PORT=53392

[ ttnew ]
Product=TimesTen11.2.2.8.11
InstallDir=/u01/TimesTen/ttnew
InstanceAdministrator=oracle
DaemonHome=/u01/TimesTen/ttnew/info
BitLevel=64
Component=Client/Server and DataManager
TT_PORT=55555

$ ttversion
TimesTen Release 11.2.2.6.2 (64 bit Linux/x86_64) (tt1122:53392) 2014-01-03T07:01:05Z
  Instance admin: oracle
  Instance home directory: /home/oracle/TimesTen/tt1122
  Group owner: oracle
  Daemon home directory: /home/oracle/TimesTen/tt1122/info
  PL/SQL enabled.


$ . /u01/TimesTen/ttnew/bin/ttenv.sh
$ ttversion
TimesTen Release 11.2.2.8.11 (64 bit Linux/x86_64) (ttnew:55555) 2016-02-09T19:36:50Z
  Instance admin: oracle
  Instance home directory: /u01/TimesTen/ttnew
  Group owner: oracle
  Daemon home directory: /u01/TimesTen/ttnew/info
  PL/SQL enabled.

再看一下tt1122的ttstatus:

[oracle@timesten-hol info]$ ttstatus
TimesTen status report as of Wed Jun 29 04:20:17 2016

Daemon pid 2644 port 53392 instance tt1122
TimesTen server pid 2653 started on port 53393 ------------------------------------------------------------------------
Data store /home/oracle/TimesTen/tt1122/info/DemoDataStore/cachedb1
There are no connections to the data store
Replication policy  : Manual
Cache Agent policy  : Manual
PL/SQL enabled. ------------------------------------------------------------------------
Accessible by group oracle
End of report

另起一个终端,看一下ttnew的ttstatus

$ . /u01/TimesTen/ttnew/bin/ttenv.sh
$ export TT_HOME=/u01/TimesTen/ttnew [oracle@timesten-hol info]$ ttstatus
TimesTen status report as of Wed Jun 29 04:21:38 2016

Daemon pid 4494 port 55555 instance ttnew
TimesTen server pid 4503 started on port 55556 ------------------------------------------------------------------------
Data store /home/oracle/TimesTen/tt1122/info/DemoDataStore/cachedb2
There are no connections to the data store
Replication policy  : Manual
Cache Agent policy  : Manual
PL/SQL enabled. ------------------------------------------------------------------------
Accessible by group oracle
End of report

注意Daemon pid和TimesTen server pid两行,Daemon 指的是 TimesTen Data Manager daemon, 负责Data Manager service 。Daemon的端口不能重。
TimesTen server是Daemon的子进程,或称为subdaemon。

安装TimesTen后,系统自动产生了sys.ttconnect.ini文件,先看tt1122的, 由于是主机第一个安装,因此使用的都是缺省值:

[oracle@timesten-hol info]$ cat sys.ttconnect.ini 
# Copyright (c) 1999, 2009, Oracle and/or its affiliates.All rights reserved. 

############################################################### # This is a sample sys.ttconnect.ini file that is used for the # TimesTen Client. It contains entries for each server. ###############################################################

[ttLocalHost_tt1122]
Description=TimesTen Server
Network_Address=ttLocalHost
TCP_PORT=53393

再看一下第二个非缺省安装ttnew的:

[tt1122]$ cat sys.ttconnect.ini 
# Copyright (c) 1999, 2009, Oracle and/or its affiliates.All rights reserved. 

############################################################### # This is a sample sys.ttconnect.ini file that is used for the # TimesTen Client. It contains entries for each server. ###############################################################

[ttLocalHost_ttnew]
Description=TimesTen Server
Network_Address=ttLocalHost
TCP_PORT=55556
[tt1122]$ ttisql -v1 -e 'set prompt "tt1122>"' repdb1_1122
tt1122>create user tthr identified by timesten;
tt1122>grant create session to tthr;

tt1122>call ttconfiguration('ConnectionName');
< ConnectionName, repdb1_1122 >

[ttnew]$ ttisql -v1 -e 'set prompt "ttnew>"' repdb2_1122
ttnew>create user tthr identified by timesten;
ttnew>grant create session to tthr;


ttnew>call ttconfiguration('ConnectionName');
< ConnectionName, repdb2_1122 >

接下来测试从ttnew上的repdb2_1122访问tt1122上的repdb1_1122
sys.odbc.ini中已经有了一个repdb1CS_1122的定义:

repdb1CS_1122=TimesTen 11.2.2 Client Driver

[repdb1CS_1122]
TTC_SERVER=ttLocalHost_ttnew
TTC_SERVER_DSN=repdb1_1122

但由于ttLocalHost_ttnew实际上指向本实例,因此无法连接到对方。
因此我们必须修改TTC_SERVER指向的logical server,涉及到sys.odbc.ini和sys.ttconnect.ini, 这里不妨把对方实例的sys.ttconnect.ini拷贝过来

[ttnew]$ cat sys.odbc.ini
...
[repdb1CS_1122]
TTC_SERVER=ttLocalHost_tt1122
TTC_SERVER_DSN=repdb1_1122
...

[ttnew]$ hostname
timesten-hol

[ttnew]$ cat sys.ttconnect.ini
# Copyright (c) 1999, 2009, Oracle and/or its affiliates.All rights reserved. 

###############################################################
# This is a sample sys.ttconnect.ini file that is used for the
# TimesTen Client. It contains entries for each server.
###############################################################

[ttLocalHost_ttnew]
Description=TimesTen Server
Network_Address=ttLocalHost
TCP_PORT=55556

####### ADDED BY STEVEN,COPIED FROM INSTANCE TT1122 ########
[ttLocalHost_tt1122]
Description=TimesTen Server
Network_Address=timesten-hol
TCP_PORT=53393

然后测试连通性,成功了:
[ttnew]$ ttisqlcs “dsn=repdb1CS_1122;uid=tthr;pwd=timesten”
Command> call ttconfiguration(‘ConnectionName’);
< ConnectionName, repdb1cs_1122 >
1 row found.
Command> call ttconfiguration(‘datastore’);
< DataStore, /home/oracle/TimesTen/tt1122/info/DemoDataStore/repdb1_1122 >

更简洁的方法

除了在sys.ttconnect.ini中定义外,还可以在连接属性中直接定义。
使用的属性有ttc_server, ttc_server_dsn和tcp_port
关键是tcp_port,指的是timesten server port,即daemon port + 1。

从任意客户端连接到tt1122的cachedb1可以用:

$ ttIsqlCS -connstr "ttc_server=timesten-hol;tcp_port=53393;ttc_server_dsn=cachedb1;uid=tthr;pwd=timesten" 

从任意客户端连接到ttnew的cachedb2可以用:

ttIsqlCS -connstr "ttc_server=timesten-hol;tcp_port=55556;ttc_server_dsn=cachedb2;uid=tthr;pwd=timesten"

总结

逻辑服务器名用于使用非TCP/IP的通讯协议或者TimesTen Server不在缺省的端口监听时。
逻辑服务器名在sys.ttconnect.ini中定义,指向的是目标服务器的网络地址和Daemon使用的端口。而实际的DSN则在对方的DSN文件中定义。
逻辑服务器名在客户端的DSN文件中使用,用TTC_SERVER指定逻辑服务器名,用TTC_SERVER_DSN指定对方的DSN。
逻辑服务器的属性还可以直接在连接属性中定义。

参考

  • TimesTen Operation Guide | Working with the TimesTen Client and Server | Configuring TimesTen Client and Server | Defining a logical server name
  • TimesTen Client Connection Failed With Error: (Doc ID 1571037.1)

你可能感兴趣的:(timesten,逻辑服务器)