Deploy a Grid and Database

The ttGridRollout utility uses the parameters you define in a configuration file to deploy a grid and database from start to finish without needing further input from you. This utility uses ttGridAdmin commands to perform the operations related to the initial configuration and deployment of a grid and database. You can find the ttGridRollout utility in the bin directory of a TimesTen Scaleout installation.

For more information on the ttGridRollout utility, see ttGridRollout in Oracle TimesTen In-Memory Database Reference.

Create a Database Definition File

The database definition file (suffix of .dbdef) contains the data store and first connection attributes of a database. You must name the file as database_name.dbdef. For example, for a database named database1, the database definition file would be database1.dbdef.

Create a database definition file in a directory on the system defined as the host of the active management instance, as shown next.

% vi /mydir/database1.dbdef

[database1]
DataStore=/disk1/databases/database1
LogDir=/disk2/logs
DatabaseCharacterSet=AL32UTF8
Durability=0
PermSize=32768
TempSize=4096
LogBufMB=1024
Connections=2048

See Creating a Database Definition File.

Create a Connectable File

The connectable file (suffix of .connect) contains the general connection attributes for a connection to a database. TimesTen Scaleout supports connectables that can be either for direct or client/server connections to the database.

Create a connectable file in a directory on the system defined as the host of the active management instance, as shown next.

% vi /mydir/database1CS.connect

ConnectionCharacterSet=AL32UTF8

See Creating a Connectable File.

Create a SQL Script File for Your Database

The SQL script file contains the SQL statements to create SQL objects for your database.

Create a SQL script file in a directory on the system defined as the host of the active management instance, as shown next.

Note:

See Defining Table Distribution Schemes for details on the CREATE TABLE statements and their distribution schemes included in the database1.sql file.

% vi /mydir/database1.sql

CREATE USER terry IDENTIFIED BY password;
 
GRANT CREATE SESSION TO terry;
 
CREATE TABLE terry.account_type
(
    type            CHAR(1) NOT NULL PRIMARY KEY,
    description     VARCHAR2(100) NOT NULL
)
DUPLICATE;
 
CREATE TABLE terry.account_status
(
    status          NUMBER(2,0) NOT NULL PRIMARY KEY,
    description     VARCHAR2(100) NOT NULL
)
DUPLICATE;
 
CREATE TABLE terry.customers
(
    cust_id            NUMBER(10,0) NOT NULL PRIMARY KEY,
    first_name         VARCHAR2(30) NOT NULL,
    last_name          VARCHAR2(30) NOT NULL,
    addr1              VARCHAR2(64),
    addr2              VARCHAR2(64),
    zipcode            VARCHAR2(5),
    member_since       DATE NOT NULL
)
DISTRIBUTE BY HASH;
 
CREATE TABLE terry.accounts
(
    account_id         NUMBER(10,0) NOT NULL PRIMARY KEY,
    phone              VARCHAR2(16) NOT NULL,
    account_type       CHAR(1) NOT NULL,
    status             NUMBER(2,0) NOT NULL,
    current_balance    NUMBER(10,2) NOT NULL,
    prev_balance       NUMBER(10,2) NOT NULL,
    date_created       DATE NOT NULL,
    cust_id            NUMBER(10,0) NOT NULL,
    CONSTRAINT fk_customer
        FOREIGN KEY (cust_id)
            REFERENCES terry.customers(cust_id),
    CONSTRAINT fk_acct_type
        FOREIGN KEY (account_type)
            REFERENCES terry.account_type(type),
    CONSTRAINT fk_acct_status
        FOREIGN KEY (status)
            REFERENCES terry.account_status(status)
)
DISTRIBUTE BY REFERENCE (fk_customer);
 
CREATE TABLE terry.transactions
(
    transaction_id      NUMBER(10,0) NOT NULL,
    account_id          NUMBER(10,0) NOT NULL ,
    transaction_ts      TIMESTAMP NOT NULL,
    description         VARCHAR2(60),
    optype              CHAR(1) NOT NULL,
    amount              NUMBER(6,2) NOT NULL,
    PRIMARY KEY (account_id, transaction_id, transaction_ts),
    CONSTRAINT fk_accounts
        FOREIGN KEY (account_id)
            REFERENCES terry.accounts(account_id)
)
DISTRIBUTE BY REFERENCE (fk_accounts);
 
CREATE SEQUENCE terry.txn_seq CACHE 100 BATCH 1000000;

Create a Configuration File for the ttGridRollout Utility

The configuration file for the ttGridRollout utility defines all the necessary parameters to successfully create and deploy a grid and database in TimesTen Scaleout.

Create a configuration file for the ttGridRollout utility, as shown next. The following configuration file:

  • Names the grid as grid1.

  • Defines the membership servers provided by the membership.conf file.

  • Defines the location for the installation files for every installation object as /grid/tt22.1.1.18.0 on their respective host.

  • Defines the location for the instance files of every instance object as /grid on their respective hosts.

  • Creates the database definition provided by the database1.dbdef file.

  • Creates the client/server connectable provided by the database1CS.connect file.

  • Adds the SQL schema provided by the database1.sql file to the database1 database.

  • Creates two management instances, including their respective hosts and installations.

  • Creates six data instances, including their respective hosts and installations, evenly assigned to two data space groups. The ttGridRollout utility sets K-safety to 3 at grid creation to satisfy the need of three data space groups.

    Note:

    See Define the Network Parameters of Each Host and Membership Server for details on the attributes used for every instance in this example.

% vi /mydir/grid1.conf

grid_name = grid1
zoo_conf = /mydir/membership.conf
instance_location = /grid
installation_location = /grid
dbdef_file = /mydir/database1.dbdef
cs_connect_files = /mydir/database1CS.connect
init_script = /mydir/database1.sql
mgmt_instances = [
        { "host":"host1", "address":"int-host1", "instance":"instance1", 
          "daemonport":6624, "csport":6625, "mgmtport":3574},
        { "host":"host2", "address":"int-host2", "instance":"instance1", 
          "daemonport":6624, "csport":6625, "mgmtport":3574}
]
data_instances = [
        { "host":"host3", "internalAddress":"int-host3",
          "externalAddress":"ext-host3.example.com", "dataspacegroup":1,
          "instance":"instance1", "daemonport":6624, "csport":6625},
        { "host":"host4", "internalAddress":"int-host4",
          "externalAddress":"ext-host4.example.com", "dataspacegroup":2,
          "instance":"instance1", "daemonport":6624, "csport":6625},
        { "host":"host5", "internalAddress":"int-host5",
          "externalAddress":"ext-host5.example.com", "dataspacegroup":3,
          "instance":"instance1", "daemonport":6624, "csport":6625},
        { "host":"host6", "internalAddress":"int-host6",
          "externalAddress":"ext-host6.example.com", "dataspacegroup":1,
          "instance":"instance1", "daemonport":6624, "csport":6625},
        { "host":"host7", "internalAddress":"int-host7",
          "externalAddress":"ext-host7.example.com", "dataspacegroup":2,
          "instance":"instance1", "daemonport":6624, "csport":6625},
        { "host":"host8", "internalAddress":"int-host8",
          "externalAddress":"ext-host8.example.com", "dataspacegroup":3,
          "instance":"instance1", "daemonport":6624, "csport":6625}
]

Create a Grid and Database

Use the ttGridRollout utility to create a grid and database based on the configuration file you provide.

% /grid/tt22.1.1.18.0/bin/ttGridRollout /mydir/grid1.conf
INFO: Checking Zookeeper on ms-host1!2181 -- OK
INFO: Checking Zookeeper on ms-host2!2181 -- OK
INFO: Checking Zookeeper on ms-host3!2181 -- OK
INFO: Checking the address for the management database -- OK
INFO: Checking connectivity to int-host1 -- OK
 
================================================================================
 
/grid/tt22.1.1.18.0/bin/ttInstanceCreate -grid -location /grid -name
 instance1 -daemonport 6624 -csport 6625
Creating instance in /grid/instance1 ...
 
NOTE: The TimesTen daemon startup/shutdown scripts have not been installed.
 
The startup script is located here :
	'/grid/instance1/startup/tt_instance1'
 
Run the 'setuproot' script :
	/grid/instance1/bin/setuproot -install
This will move the TimesTen startup script into its appropriate location.
 
The 22.1 Release Notes are located here :
  '/grid/tt22.1.1.18.0/README.html'
 
/grid/instance1/bin/ttenv ttGridAdmin gridCreate grid1 -k 3 -host host1 -address
 int-host1 -membership zookeeper -membershipConfig /mydir/membership.conf
 -mgmtport 3754
/grid/instance1/bin/ttenv ttGridAdmin hostCreate host2 -address int-host2
/grid/instance1/bin/ttenv ttGridAdmin installationCreate host2 -location /grid
/grid/instance1/bin/ttenv ttGridAdmin instanceCreate host2.instance1 -location
 /grid -type management -daemonport 6624 -csport 6625 -mgmtport 3754
/grid/instance1/bin/ttenv ttGridAdmin modelApply
/grid/instance1/bin/ttenv ttGridAdmin hostCreate host3 -externaladdress int-host3
 -internaladdress ext-host3.example.com -dataspacegroup 1
/grid/instance1/bin/ttenv ttGridAdmin installationCreate host3 -location /grid
/grid/instance1/bin/ttenv ttGridAdmin hostCreate host4 -externaladdress int-host4
 -internaladdress ext-host4.example.com -dataspacegroup 2
/grid/instance1/bin/ttenv ttGridAdmin installationCreate host4 -location /grid
/grid/instance1/bin/ttenv ttGridAdmin hostCreate host5 -externaladdress int-host5
 -internaladdress ext-host5.example.com -dataspacegroup 3
/grid/instance1/bin/ttenv ttGridAdmin installationCreate host5 -location /grid
/grid/instance1/bin/ttenv ttGridAdmin hostCreate host6 -externaladdress int-host6
 -internaladdress ext-host6.example.com -dataspacegroup 1
/grid/instance1/bin/ttenv ttGridAdmin installationCreate host6 -location /grid
/grid/instance1/bin/ttenv ttGridAdmin hostCreate host7 -externaladdress int-host7
 -internaladdress ext-host7.example.com -dataspacegroup 2
/grid/instance1/bin/ttenv ttGridAdmin installationCreate host7 -location /grid
/grid/instance1/bin/ttenv ttGridAdmin hostCreate host8 -externaladdress int-host8
 -internaladdress ext-host8.example.com -dataspacegroup 3
/grid/instance1/bin/ttenv ttGridAdmin installationCreate host8 -location
 /grid
/grid/instance1/bin/ttenv ttGridAdmin instanceCreate host3.instance1 -location
 /grid -daemonport 6624 -csport 6625
/grid/instance1/bin/ttenv ttGridAdmin instanceCreate host4.instance1 -location
 /grid -daemonport 6624 -csport 6625
/grid/instance1/bin/ttenv ttGridAdmin instanceCreate host5.instance1 -location
 /grid -daemonport 6624 -csport 6625
/grid/instance1/bin/ttenv ttGridAdmin instanceCreate host6.instance1 -location
 /grid -daemonport 6624 -csport 6625
/grid/instance1/bin/ttenv ttGridAdmin instanceCreate host7.instance1 -location
 /grid -daemonport 6624 -csport 6625
/grid/instance1/bin/ttenv ttGridAdmin instanceCreate host8.instance1 -location
 /grid -daemonport 6624 -csport 6625
/grid/instance1/bin/ttenv ttGridAdmin dbdefCreate /mydir/database1.dbdef
/grid/instance1/bin/ttenv ttGridAdmin modelApply
/grid/instance1/bin/ttenv ttGridAdmin dbCreate -wait 180 database1
/grid/instance1/bin/ttenv ttGridAdmin dbDistribute database1 -add all -apply
/grid/instance1/bin/ttenv ttGridAdmin dbOpen -wait 180 database1
/grid/instance1/bin/ttenv ttGridAdmin connectableCreate -dbdef database1 -cs
 /mydir/database1CS.connect
/grid/instance1/bin/ttenv ttGridAdmin modelApply
/grid/instance1/bin/ttenv ttGridAdmin instanceExec -only host3.instance1 "ttIsql
 database1 <<EOF
CREATE USER terry IDENTIFIED BY password;
 
GRANT CREATE SESSION TO terry;
 
CREATE TABLE terry.account_type
(
    type            CHAR(1) NOT NULL PRIMARY KEY,
    description     VARCHAR2(100) NOT NULL
)
DUPLICATE;
 
CREATE TABLE terry.account_status
(
    status          NUMBER(2,0) NOT NULL PRIMARY KEY,
    description     VARCHAR2(100) NOT NULL
)
DUPLICATE;
 
CREATE TABLE terry.customers
(
    cust_id            NUMBER(10,0) NOT NULL PRIMARY KEY,
    first_name         VARCHAR2(30) NOT NULL,
    last_name          VARCHAR2(30) NOT NULL,
    addr1              VARCHAR2(64),
    addr2              VARCHAR2(64),
    zipcode            VARCHAR2(5),
    member_since       DATE NOT NULL
)
DISTRIBUTE BY HASH;
 
CREATE TABLE terry.accounts
(
    account_id         NUMBER(10,0) NOT NULL PRIMARY KEY,
    phone              VARCHAR2(16) NOT NULL,
    account_type       CHAR(1) NOT NULL,
    status             NUMBER(2,0) NOT NULL,
    current_balance    NUMBER(10,2) NOT NULL,
    prev_balance       NUMBER(10,2) NOT NULL,
    date_created       DATE NOT NULL,
    cust_id            NUMBER(10,0) NOT NULL,
    CONSTRAINT fk_customer
        FOREIGN KEY (cust_id)
            REFERENCES terry.customers(cust_id),
    CONSTRAINT fk_acct_type
        FOREIGN KEY (account_type)
            REFERENCES terry.account_type(type),
    CONSTRAINT fk_acct_status
        FOREIGN KEY (status)
            REFERENCES terry.account_status(status)
)
DISTRIBUTE BY REFERENCE (fk_customer);
 
CREATE TABLE terry.transactions
(
    transaction_id      NUMBER(10,0) NOT NULL,
    account_id          NUMBER(10,0) NOT NULL ,
    transaction_ts      TIMESTAMP NOT NULL,
    description         VARCHAR2(60),
    optype              CHAR(1) NOT NULL,
    amount              NUMBER(6,2) NOT NULL,
    PRIMARY KEY (account_id, transaction_id, transaction_ts),
    CONSTRAINT fk_accounts
        FOREIGN KEY (account_id)
            REFERENCES terry.accounts(account_id)
)
DISTRIBUTE BY REFERENCE (fk_accounts);
 
CREATE SEQUENCE terry.txn_seq CACHE 100 BATCH 1000000;
 
EOF"
 
================================================================================
6-instance (2x3) grid successfully created.
 
 
Management Instance Locations
-----------------------------
- int-host1:/grid/instance1
- int-host2:/grid/instance1
 
Please source ttenv script under Management Instances for grid management via
 "ttGridAdmin" commands.
 
  For example, to use the first management instance, on int-host1:
  sh:  . /grid/instance1/bin/ttenv.sh
  csh: source /grid/instance1/bin/ttenv.csh
 
 
Data Instance Locations
-----------------------
- host3.instance1 ==> int-host3:/grid/instance1
- host4.instance1 ==> int-host4:/grid/instance1
- host5.instance1 ==> int-host5:/grid/instance1
- host6.instance1 ==> int-host6:/grid/instance1
- host7.instance1 ==> int-host7:/grid/instance1
- host8.instance1 ==> int-host8:/grid/instance1
 
Please source ttenv script under Data Instances for database operations.
 
  For example, to use instance1, on int-host3:
  sh:  . /grid/instance1/bin/ttenv.sh
  csh: source /grid/instance1/bin/ttenv.csh

Connect to the Database

Connect to your database through a direct or client connection. For a direct connection, set your environment to one of the data instances, host3.instance1 for example, and use the database1 connectable to connect to the database.

% source /grid/instance1/bin/ttenv.csh
...
% ttIsql -connStr "DSN=database1;UID=terry"

See Connecting to a Database.