본문 바로가기
IT

오라클 타임스텐 데이터베이스 시작 및 종료와 사용자 생성하기

by eddy's warehouse 2024. 4. 1.

지난 시간에 오라클 타임스텐 데이터베이스를 생성하는 법을 알아보았습니다. 데이터베이스는 최초 접속 시 자동으로 생성되는데, 이후부터는 특정 user와 password로 접속하게 하려고 합니다. 오늘은 타임스텐 데이터베이스를 종료하고 재시작한 후 사용자 생성에 대한 방법을 알려드리겠습니다.

오라클 타임스텐 데이터베이스 시작 및 종료와 사용자 생성하기 썸네일

오라클 타임스텐 데이터베이스 시작 및 종료

오라클 타임스텐을 시작하고 종료하는 것은 ttDaemonAdmin이라는 툴로 간단하게 수행할 수 있습니다.

다음은 종료 후 시작하는 예를 보여줍니다.

timesten:~/tt_instances/ttinstance/conf$ ttDaemonAdmin --stop
TimesTen Daemon (PID: 743086, port: 6624) stopped.
timesten:~/tt_instances/ttinstance/conf$ ps -ef |grep timesten
timesten  738352       1  0  3월27 ?      00:00:00 /lib/systemd/systemd --user
timesten  738353  738352  0  3월27 ?      00:00:00 (sd-pam)
timesten  738360  738352  0  3월27 ?      00:00:00 /usr/bin/pipewire
timesten  738361  738352  0  3월27 ?      00:00:00 /usr/bin/pipewire-media-session
timesten  738363  738352  0  3월27 ?      00:00:00 /snap/snapd-desktop-integration/83/usr/bin/snapd-desktop-integration
timesten  738375  738352  0  3월27 ?      00:00:00 /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
timesten  738382  738352  0  3월27 ?      00:00:00 /usr/libexec/gvfsd
timesten  738396  738352  0  3월27 ?      00:00:00 /usr/libexec/gvfsd-fuse /run/user/1007/gvfs -f
timesten  738399  738352  0  3월27 ?      00:00:00 /usr/libexec/xdg-document-portal
timesten  738407  738352  0  3월27 ?      00:00:00 /usr/libexec/xdg-permission-store
timesten  738538  738352  0  3월27 ?      00:00:04 /usr/libexec/tracker-miner-fs-3
timesten  738546  738363  0  3월27 ?      00:00:00 /snap/snapd-desktop-integration/83/usr/bin/snapd-desktop-integration
timesten  738560  738352  0  3월27 ?      00:00:00 /usr/libexec/gvfs-udisks2-volume-monitor
timesten  738565  738352  0  3월27 ?      00:00:18 /usr/libexec/gvfs-afc-volume-monitor
timesten  738570  738352  0  3월27 ?      00:00:00 /usr/libexec/gvfs-gphoto2-volume-monitor
timesten  738574  738352  0  3월27 ?      00:00:00 /usr/libexec/gvfs-mtp-volume-monitor
timesten  738578  738352  0  3월27 ?      00:00:00 /usr/libexec/gvfs-goa-volume-monitor
timesten  738582  738352  0  3월27 ?      00:00:00 /usr/libexec/goa-daemon
timesten  738589  738352  0  3월27 ?      00:00:00 /usr/libexec/goa-identity-service
root      759150  758901  0  3월28 pts/2  00:00:00 su - timesten
timesten  759153  759150  0  3월28 pts/2  00:00:00 -bash
root      845522  845472  0 16:17 pts/3    00:00:00 su - timesten
timesten  845531  845522  0 16:17 pts/3    00:00:00 -bash
timesten  846743  759153  0 17:43 pts/2    00:00:00 ps -ef
timesten  846744  759153  0 17:43 pts/2    00:00:00 grep timesten

timesten@altibase-KVM:~/tt_instances/ttinstance$ ttDaemonAdmin --start
TimesTen Daemon (PID: 846811, port: 6624) startup OK.

 

 

오라클 타임스텐 Database 사용자(User)와 소유자(Owner)

타임스텐은 비밀번호로 사용자 이름을 인증합니다. 기본적으로 애플리케이션을 실행하는 데 사용되는 로그인 이름이 데이터베이스의 객체 소유자가 되므로 애플리케이션은 애플리케이션 자체에 대해 하나의 UID를 선택해야 합니다.

연결 문자열에서 UID 연결 속성을 생략하면 TimesTen은 현재 사용자의 로그인 이름을 사용합니다. TimesTen은 모든 사용자 이름을 대문자로 변환합니다. SQL 문을 실행할 때마다 데이터베이스 개체의 정규화된 이름(예: owner.table_name)을 사용해야 합니다.

사용자는 SYS 사용자로 TimesTen 데이터베이스에 액세스할 수 없습니다. 타임스텐은 UID 연결 속성의 값으로 사용자 이름을 결정하거나, 없는 경우 연결된 사용자의 로그인 이름으로 사용자 이름을 결정합니다. 사용자의 로그인이 SYS인 경우 로그인 이름을 재정의하도록 UID 연결을 설정합니다.

 

먼저 DSN을 이용해서 ttIsql을 실행하여 데이터베이스에 접속합니다.

$ ttIsql tpcc

Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved.
Type ? or "help" for help, type "exit" to quit ttIsql.

connect "DSN=tpcc";
Connection successful: DSN=tpcc;UID=timesten;DataStore=/home/timesten/tt_instances/ttinstance/db/tpcc;DatabaseCharacterSet=KO16MSWIN949;ConnectionCharacterSet=US7ASCII;DRIVER=/home/timesten/tt_instances/ttinstance/install/lib/libtten.so;
(Default setting AutoCommit=1)
Command>

 

이제 사용자를 생성할 수 있습니다. 다음과 같은 SQL 명령어를 사용하여 사용자를 생성합니다

Command> create user tpcc identified by tpcc;

User created.

Command> GRANT CREATE SESSION, CREATE TABLE TO tpcc ;

 

위와 같이 계정 생성 후 create session과 create table 권한을 부여합니다.

 

ttIsql에서 Connect adding 구문을 통해서 uid와 pwd를 입력해서 다음과 같이 접속해 볼 수 있습니다.

Command> Connect adding "uid=tpcc;pwd=tpcc" as tpcc1;
Connection successful: DSN=tpcc;UID=tpcc;DataStore=/home/timesten/tt_instances/ttinstance/db/tpcc;DatabaseCharacterSet=KO16MSWIN949;ConnectionCharacterSet=US7ASCII;DRIVER=/home/timesten/tt_instances/ttinstance/install/lib/libtten.so;
(Default setting AutoCommit=1)

 

연결 후에는 아래와 같이 tpcc 사용자의 스키마로 테이블이 생성되고 처리됩니다.

tpcc1: Command> select * from t1;
 2206: Table TPCC.T1 not found
The command failed.
tpcc1: Command> show tables;
The argument to the command is invalid or missing.
The correct usage is: show all | <attribute>
The command failed.
tpcc1: Command> show table;
The argument to the command is invalid or missing.
The correct usage is: show all | <attribute>
The command failed.
tpcc1: Command> create table t1(i1 integer);
tpcc1: Command> insert into t1 values(10);
1 row inserted.
tpcc1: Command> select * from t1;
< 10 >
1 row found.
tpcc1: Command> select * from tpcc.t1;
< 10 >
1 row found.
tpcc1: Command>

 

 

이제 $TIMESTEN_HOME 디렉터리의 conf/sys.odbc.ini 파일을 수정하여, 앞서 생성한 tpcc 사용자의 UID와 PWD를 DSN에 입력합니다. 이렇게 해 놓으면, 향후에는 tpcc DSN을 이용하여 tpcc 사용자로 timesten database에 접속할 수 있습니다.

timesten:~/tt_instances/ttinstance$ vi conf/sys.odbc.ini

[ODBC Data Sources]
tpcc=TimesTen 22.1 Driver


[tpcc]
Driver=/home/timesten/tt_instances/ttinstance/install/lib/libtten.so
DataStore=/home/timesten/tt_instances/ttinstance/db/tpcc
DatabaseCharacterSet=KO16MSWIN949
UID=tpcc
PWD=tpcc

 

이번 글에서는 오라클 타임스텐에 ttIsql을 이용해서 접속하고, 신규 사용자를 생성하여 권한을 부여하는 법에 대해서 알아보았습니다. 이제는 DSN으로 특정 사용자에 대한 접속을 쉽게 하여 DML을 할 수 있는 준비가 완료되었습니다.

다음 시간에는 파이썬으로 timesten db에 접속하는 법을 알아보도록 하겠습니다.

facebook twitter kakaoTalk kakaostory naver band shareLink