TimesTen_安裝-建立資料庫

redhouser發表於2012-04-09

TimesTen安裝及建立資料庫。

1,使用者、使用者組、目錄準備
#log in as root
#create user group,allow direct driver connection
groupadd timesten

#create registry directory
mkdir /etc/TimesTen

#create admin group,install and uninstall
groupadd ttadmin
chgrp -R ttadmin /etc/TimesTen
chmod 770 /etc/TimesTen/
chmod 660 /etc/TimesTen/*

#create user
useradd -g timesten -G ttadmin tt

mkdir /tt
chown tt:timesten /tt

2,軟體準備
下載timesten112220[1].linux86.tar.gz


3,安裝
#logon as tt
cd /tt
3.1 解壓
gunzip timesten112220[1].linux86.tar.gz
tar -xvf timesten112220[1].linux86.tar

3.2 安裝
cd /linux
[tt@rhel5 linux86]$ ./setup.sh

NOTE: Each TimesTen installation is identified by a unique instance name.
      The instance name must be a non-null alphanumeric string, not longer
      than 255 characters.

Please choose an instance name for this installation? [ tt1122 ]
Instance name will be 'tt1122'.
Is this correct? [ yes ]

Of the three components:

  [1] Client/Server and Data Manager
  [2] Data Manager Only
  [3] Client Only

Which would you like to install? [ 1 ]

Of the following options :

  [1] /home/tt
  [2] /tt
  [3] Specify a location
  [q] Quit the installation

Where would you like to install the tt1122 instance of TimesTen? [ 1 ] 2
Where would you like to create the daemon home directory? [ /tt/TimesTen/tt1122/info ]

The daemon logs will be located in /tt/TimesTen/tt1122/info
Would you like to specify a different location for the daemon logs? [ no ]
Installing into /tt/TimesTen/tt1122 ...
Uncompressing ...

NOTE: If you are configuring TimesTen for use with Oracle Clusterware, the
      daemon port number must be the same across all TimesTen installations
      managed within the same Oracle Clusterware cluster.

NOTE: All installations that replicate to each other must use the same daemon
      port number that is set at installation time. The daemon port number can
      be verified by running 'ttVersion'.

The default port number is 53392.

Do you want to use the default port number for the TimesTen daemon? [ yes ]
The daemon will run on the default port number (53392).

NOTE: For security, we recommend that you restrict access to the
      TimesTen installation to members of a single OS group. Only members of
      that OS group will be allowed to perform. direct mode connections to
      TimesTen, and only members of that OS group will be allowed to perform
      operations that access TimesTen data stores, TimesTen files and shared
      memory. The OS group defaults to the primary group of the instance
      administrator. You can default to this group, choose another OS group
      or you can make this instance world-accessible. If you choose to make
      this instance world-accessible, all database files and shared memory
      are readable and writable by all users.

Restrict access to the the TimesTen installation to the group 'timesten'? [ yes ]

NOTE: Enabling PL/SQL will increase the size of some TimesTen libraries.

Would you like to enable PL/SQL for this instance? [ yes ]

In order to use the 'In-Memory Database Cache' feature in any databases
created within this installation, you must set a value for the TNS_ADMIN
environment variable. It can be left blank, and a value can be supplied later
using /bin/ttModInstall.

Please enter a value for TNS_ADMIN (s=skip)? [  ] s


NOTE: It appears that you are running version 3.4 or higher of the g++
      compiler. TimesTen ships with multiple sets of client libraries and server
      binaries : one built for compatibility with g++ 3.4.6 and one with
      g++ 4.1.0. The installer has created links to the 3.4.6 library in the
      /lib directory and to the 3.4.6 server binary in the
      /bin directory. If you want to use a different compiler,
      please modify the links to point to the desired library and server binary.

Installing server components ...
What is the TCP/IP port number that you want the TimesTen Server to listen on? [ 53393 ]
Do you want to install QuickStart and the TimesTen Documentation? [ no ] yes
Where would you like to install the quickstart and doc directories (s=skip)? [ /tt/TimesTen/tt1122 ]

The TimesTen Quickstart applications can take up to 64 Mbytes of disk space.
Depending on how your system is configured, you may not want to create the
QuickStart DemoDataStore directory in the default location,
/tt/TimesTen/tt1122/info/DemoDataStore

Where would you like to create the DemoDataStore directory? [ /tt/TimesTen/tt1122/info ]
Creating /tt/TimesTen/tt1122/info/DemoDataStore ...

Installing client components ...

Would you like to use TimesTen Replication with Oracle Clusterware? [ no ]

NOTE: The TimesTen daemon startup/shutdown scripts have not been installed.

Run the 'setuproot' script.:
        cd /tt/TimesTen/tt1122/bin
        ./setuproot -install
This will move the TimesTen startup script. into its appropriate location.

The startup script. is currently located here :
  '/tt/TimesTen/tt1122/startup/tt_tt1122'.

The Quickstart home page can be accessed here :
  '/tt/TimesTen/tt1122/quickstart/index.html'

The 11.2.2.2 Release Notes are located here :
  '/tt/TimesTen/tt1122/README.html'

Starting the daemon ...
TimesTen Daemon startup OK.
End of TimesTen installation.

3.3 配置自動啟動
#logon as root
cd /tt/TimesTen/tt1122/bin
[root@rhel5 bin]# ./setuproot -install
Would you like to install the TimesTen daemon startup scripts into /etc/init.d? [ yes ]
Copying /tt/TimesTen/tt1122/startup/tt_tt1122 to /etc/init.d

Successfully installed the following scripts :
/etc/init.d/tt_tt1122
/etc/rc.d/rc0.d/K45tt_tt1122
/etc/rc.d/rc1.d/K45tt_tt1122
/etc/rc.d/rc2.d/S90tt_tt1122
/etc/rc.d/rc3.d/S90tt_tt1122
/etc/rc.d/rc5.d/S90tt_tt1122
/etc/rc.d/rc6.d/K45tt_tt1122

3.4 檢視後臺程式
#logon as tt
[tt@rhel5 linux86]$ cat /tt/TimesTen/tt1122/info/timestend.pid
15595

[tt@rhel5 linux86]$ ps -ef|grep TimesTen
tt       15595     1  0 07:51 ?        00:00:00 /tt/TimesTen/tt1122/bin/timestend -initfd 13
tt       15599 15595  0 07:51 ?        00:00:00 /tt/TimesTen/tt1122/bin/timestensubd -verbose -userlog tterrors.log -supportlog ttmesg.log -id 1000000 -facility user
tt       15600 15595  0 07:51 ?        00:00:00 /tt/TimesTen/tt1122/bin/timestensubd -verbose -userlog tterrors.log -supportlog ttmesg.log -id 1000001 -facility user
tt       15601 15595  0 07:51 ?        00:00:00 /tt/TimesTen/tt1122/bin/timestensubd -verbose -userlog tterrors.log -supportlog ttmesg.log -id 1000002 -facility user
tt       15602 15595  0 07:51 ?        00:00:00 /tt/TimesTen/tt1122/bin/timestensubd -verbose -userlog tterrors.log -supportlog ttmesg.log -id 1000003 -facility user
tt       15604 15595  0 07:51 ?        00:00:00 /tt/TimesTen/tt1122/bin/ttcserver -verbose -userlog tterrors.log -supportlog ttmesg.log -id 1000004 -p 53393 -facility user -group timesten

3.5 例項資訊、執行日誌、錯誤日誌
[tt@rhel5 linux86]$ cat /tt/TimesTen/tt1122/info/ttendaemon.options
# Commented values are default values
#-supportlog /tt/TimesTen/tt1122/info/ttmesg.log
#-maxsupportlogfiles 10
#-maxsupportlogsize 10485760
#-userlog /tt/TimesTen/tt1122/info/tterrors.log
#-maxuserlogfiles 10
#-maxuserlogsize 0x100000
#
-verbose
#-tns_admin
-server 53393
[tt@rhel5 linux86]$ cat /tt/TimesTen/tt1122/info/ttmesg.log
07:51:19.62 Info:    : 15595: FD limits are 65536 / 65536
07:51:19.63 Info:    : 15595: Process running as user tt
07:51:19.63 Info:    : 15595: listening on port 53392
07:51:19.63 Warn:    : 15595: TimesTen Daemon Release 11.2.2.2.0.tt1122 started.
07:51:19.63 Info:    : 15595: Running in /tt/TimesTen/tt1122/info as group timesten
07:51:19.63 Info:    : 15595: Spawning '/tt/TimesTen/tt1122/bin/timestensubd'
07:51:19.63 Info:    : 15595: Spawned new process (timestensubd), idx 1000000, handle 0x3cef=15599
07:51:19.63 Info:    : 15595: Subdaemon id 1000000 started
07:51:19.63 Info:    : 15595: Spawning '/tt/TimesTen/tt1122/bin/timestensubd'
07:51:19.63 Info:    : 15595: Spawned new process (timestensubd), idx 1000001, handle 0x3cf0=15600
07:51:19.63 Info:    : 15595: Subdaemon id 1000001 started
07:51:19.63 Info:    : 15595: Spawning '/tt/TimesTen/tt1122/bin/timestensubd'
07:51:19.63 Info:    : 15595: Spawned new process (timestensubd), idx 1000002, handle 0x3cf1=15601
07:51:19.63 Info:    : 15595: Subdaemon id 1000002 started
07:51:19.63 Info:    : 15595: Spawning '/tt/TimesTen/tt1122/bin/timestensubd'
07:51:19.64 Info:    : 15595: Spawned new process (timestensubd), idx 1000003, handle 0x3cf2=15602
07:51:19.64 Info:    : 15595: Subdaemon id 1000003 started
07:51:19.64 Info:    : 15595: Spawning '/tt/TimesTen/tt1122/bin/ttcserver'
07:51:19.64 Info:    : 15595: Spawned new process (ttcserver), idx 1000004, handle 0x3cf4=15604
07:51:19.67 Info:    : 15600: FD limits are 65536 / 65536
07:51:19.67 Info:    : 15601: FD limits are 65536 / 65536
07:51:19.67 Info:    : 15600: Process running as user tt
07:51:19.67 Info:    : 15601: Process running as user tt
07:51:19.68 Info:    : 15602: FD limits are 65536 / 65536
07:51:19.68 Info:    : 15602: Process running as user tt

[tt@rhel5 linux86]$ cat /tt/TimesTen/tt1122/info/tterrors.log
07:51:19.63 Warn:    : 15595: TimesTen Daemon Release 11.2.2.2.0.tt1122 started.

[tt@rhel5 linux86]$ cat /etc/TimesTen/instance_info
#SUM 53845     1
[ tt1122 ]
Product=TimesTen11.2.2.2.0
InstallDir=/tt/TimesTen/tt1122
InstanceAdministrator=tt
DaemonHome=/tt/TimesTen/tt1122/info
BitLevel=32
Component=Client/Server and DataManager
TT_PORT=53392

3.6 啟動、關閉例項
#stop
cd /tt/TimesTen/tt1122/bin
[tt@rhel5 bin]$ ./ttDaemonAdmin -stop
TimesTen Daemon stopped.

#start
[tt@rhel5 bin]$ ./ttDaemonAdmin -start
TimesTen Daemon startup OK.

3.7設定環境變數
#enviroment variables setting
#log on as tt
. ./bin/ttenv.sh

#永久設定
#log on as tt
cd
vi .bash_profile

# User specific environment and startup programs
TT_HOME=/tt/TimesTen/tt1122
PATH=$TT_HOME/bin/:$PATH:$HOME/bin
LD_LIBRARY_PATH=$TT_HOME/lib:$TT_HOME/ttoracle_home/instantclient_11_2:$LD_LIBRARY_PATH
CLASSPATH=$TT_HOME/lib/ttjdbc5.jar:$TT_HOME/lib/orai18n.jar:$TT_HOME/lib/timestenjmsxla.jar:$TT_HOME/3rdparty/jms1.1/lib/jms.jar:$CLASSPATH
ANT_HOME=$TT_HOME/3rdparty/ant:$ANT_HOME

export TT_HOME PATH LD_LIBRARY_PATH CLASSPATH ANT_HOME

32位UNIX上的預設例項名稱為tt1122_32,預設埠為53384(Main Daemon)\53385(Server Daemon),cache agent 監聽埠取決於作業系統,不能單獨設定.

預設情況下,LINUX安裝位置為:$HOME/TimesTen,TimesTen使用臨時檔案目錄為:/tmp

注:為了提高效能,需要對系統訊號量、記憶體、網路進行合理設定,參考《Installtion Guide》Installation prerequisites.

[tt@rhel5 ~]$ ttVersion
TimesTen Release 11.2.2.2.0 (32 bit Linux/x86) (tt1122:53392) 2011-12-23T09:21:34Z
  Instance admin: tt
  Instance home directory: /tt/TimesTen/tt1122
  Group owner: timesten
  Daemon home directory: /tt/TimesTen/tt1122/info
  PL/SQL enabled.

4,建立資料庫
4.1 設定DSN(Data Source Names)
#建立者必須為安裝者
#log on as tt
mkdir /tt/ttdata
mkdir /tt/ttdata/database
mkdir /tt/ttdata/logs

vi /tt/TimesTen/tt1122/info/sys.odbc.ini
#在[ODBC Data Sources]段內追加:
test_db=TimesTen 11.2.2 Driver

#在[ODBC Data Sources]段後面追加:
[test_db]
Driver=/tt/TimesTen/tt1122/lib/libtten.so
DataStore=/tt/ttdata/database/test_db
LogDir=/tt/ttdata/logs
PermSize=40
TempSize=32
DatabaseCharacterSet=AL32UTF8

4.2建立資料庫
TimesTen資料庫在建立第一個連線時自動建立,連線一個已經存在但未裝載到記憶體的資料庫將導致裝載資料到記憶體.
在確認TimesTen後臺程式啟動的情況下,以tt使用者登入系統:
[tt@rhel5 info]$ ttisql

Copyright (c) 1996-2011, Oracle.  All rights reserved.
Type ? or "help" for help, type "exit" to quit ttIsql.


Command> connect "dsn=test_db"
       > ;
Connection successful: DSN=test_db;UID=tt;DataStore=/tt/ttdata/database/test_db;DatabaseCharacterSet=AL32UTF8;ConnectionCharacterSet=US7ASCII;DRIVER=/tt/TimesTen/tt1122/lib/libtten.so;LogDir=/tt/ttdata/logs;PermSize=40;TempSize=32;TypeMode=0;
(Default setting AutoCommit=1)

#支援格式:connect test_db [as conn1];connect "dsn=test_db;udi=tt";

5,簡單測試
5.1 建立使用者
con1: Command> create user mh identified by mh;

User created.
con1: Command> grant create session to mh;
con1: Command> disconnect;
Command> connect "dsn=test_db;uid=mh";
Enter password for 'mh':
Connection successful: DSN=test_db;UID=mh;DataStore=/tt/ttdata/database/test_db;DatabaseCharacterSet=AL32UTF8;ConnectionCharacterSet=US7ASCII;DRIVER=/tt/TimesTen/tt1122/lib/libtten.so;LogDir=/tt/ttdata/logs;PermSize=40;TempSize=32;TypeMode=0;
(Default setting AutoCommit=1)

Command> select * from v$version;
 2206: Table MH.V$VERSION not found
The command failed.

5.2建立表
con1: Command> connect test_db;
con1: Command> create table t(x int,y int);
con1: Command> insert into t(x,y) values(1,1);
1 row inserted.
#--&gt預設自動提交,在另外一個會話中可以看到該記錄
con1: Command> rollback;
con1: Command> desc t;

Table TT.T:
  Columns:
    X                               NUMBER (38)
    Y                               NUMBER (38)

1 table found.
(primary key columns are indicated with *)
con1: Command> autocommit 0;
con1: Command> insert into t(x,y) values(2,2);
1 row inserted.
#--&gt關閉自動提交,在另外一個會話中不能看到該記錄
con1: Command> commit;

5.3關閉例項,驗證表和資料
con1: Command> disconnect
Disconnecting from con1...
none: Command> exit
Disconnecting from test_db...
Done.
[tt@rhel5 ~]$ ttDaemonAdmin -stop
TimesTen Daemon stopped.
[tt@rhel5 ~]$ ps -ef|grep Times
tt       17531 17509  0 19:32 pts/1    00:00:00 /tt/TimesTen/tt1122/bin/ttIsqlCmd
tt       17574 17443  0 19:48 pts/2    00:00:00 grep Times
[tt@rhel5 ~]$ ttDaemonAdmin -start
TimesTen Daemon startup OK.
[tt@rhel5 ~]$ ttisql
Command> connect test_db;
Connection successful: DSN=test_db;UID=tt;DataStore=/tt/ttdata/database/test_db;DatabaseCharacterSet=AL32UTF8;ConnectionCharacterSet=US7ASCII;DRIVER=/tt/TimesTen/tt1122/lib/libtten.so;LogDir=/tt/ttdata/logs;PermSize=40;TempSize=32;TypeMode=0;
(Default setting AutoCommit=1)
Command> select * from t;
< 1, 1 >
< 2, 2 >
2 rows found.

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/18922393/viewspace-720714/,如需轉載,請註明出處,否則將追究法律責任。

相關文章