3 Using systemd to Manage a TimesTen Service
Traditionally Linux systems used the System V init mechanism to coordinate system startup operations. More recently, Linux has moved to a new method based on the systemd daemon and its associated infrastructure. Although systemd is currently the standard for system startup coordination and for service management on Linux, the System V init mechanism is still supported.
It has always been possible to set a TimesTen instance's main daemon to start automatically on system startup. This is achieved by installing suitable System V init startup scripts. TimesTen provides the setuproot
utility script for this purpose. On systems that support systemd, as an alternative to using the System V init mechanism, it is possible to configure a TimesTen instance's main daemon to run as a system service.
Note:
You can only use systemd in TimesTen Classic.The chapter provides an overview of how systemd can be used for automatic management of the TimesTen daemon. It explains the importance of the systemd service unit configuration file as a mechanism for setting operating system limits for the TimesTen environment. The chapter details the process for creating and modifying an instance for automatic systemd management. It concludes with examples illustrating how to create and modify an instance for automatic systemd management.
See the Oracle TimesTen In-Memory Database Release Notes for information on the TimesTen Linux platforms that support systemd.
Topics:
-
About creating a TimesTen instance that uses automatic systemd management
-
Creating a TimesTen instance that uses automatic systemd management
-
About modifying a TimesTen instance to enable or disable management by systemd
- Modifying a TimesTen instance to enable management by systemd
- Modifying a TimesTen instance to disable management by systemd
About creating a TimesTen instance that uses automatic systemd management
systemd is a system and service manager for Linux operating systems. If you have a Linux system that supports both the System V init mechanism and systemd, you have choices as to how to manage the TimesTen daemon. This section focuses on systemd.
Note:
- If TimesTen is managed by Oracle Clusterware, you cannot use systemd for automatic management of the TimesTen daemon.
- Using systemd for automatic management of the TimesTen daemon is supported in TimesTen Classic only. It is not supported in TimesTen Scaleout.
systemd provides a service unit type to start and control daemons and their associated processes. systemd uses a systemd service unit configuration file, whose name ends in .service
, to encode information about the daemon process. systemd then uses this information to control and manage the process.
The TimesTen full distribution provides a systemd service unit configuration file customized for TimesTen. Its purpose is to provide the necessary information so that systemd can automatically control and manage the TimesTen daemon. TimesTen makes this file available in the timesten_home/startup
directory when the instance administrator creates the TimesTen instance. This file is called the TimesTen service file. It has the naming convention of tt_myinstance.service
, where myinstance
is the name of the TimesTen instance. The systemd service that is created from this TimesTen service file is called the TimesTen service. This TimesTen service, when enabled and started, allows for automatic management of the TimesTen daemon by systemd.
The TimesTen service file is in a format specific to the requirements of the systemd service unit configuration file and the settings have been customized for TimesTen. systemd ignores the memlock
entries in the /etc/security/limits.conf
file. These memlock
entries control the amount of memory a user can lock and are important settings when configuring the operating system requirements for TimesTen. Instead of using the memlock
entries in the /etc/security/limits.conf
file, systemd uses the LimitMEMLOCK
setting in the #Service Limit Settings
section of the service unit configuration file (TimesTen service file). This setting and two other settings are important for your TimesTen environment. Modify them as appropriate.
-
LimitNOFILE
:65536
-
LimitMEMLOCK
:infinity
-
TasksMax
:65536
For example, here is the section in the TimesTen service file:
% cat timesten_home/start/tt_myinstance.service
#
# Oracle TimesTen In-Memory Database
# Copyright (c) 2020, 2021, Oracle and/or its affiliates.
...
# Service Limit Settings
LimitNOFILE = 65536
LimitMEMLOCK = infinity
TasksMax=65536
...
Note:
Do not make any other modifications to this file. Doing so alters the systemd configuration for TimesTen.-
Configuring the TimesTen instance for systemd: The instance administrator uses the
ttInstanceCreate
utility with the-systemd
option to create the TimesTen instance. Alternatively, the instance administrator can run thettInstanceCreate
utility interactively. When prompted with theWould you like to use systemd to manage TimesTen
question, the instance adminstrator answersYes
(or takes the default). -
Configuring the Linux kernel parameters: You must configure Linux kernel parameters after creating the TimesTen full instance. These include
shmmax
andshmmall
shared memory kernel parameters, HugePages, semaphores, and theSHMMNI
parameter. -
Modifying the TimesTen service file:
If necessary, the instance administrator modifies the
LimitNOFILE
, theLimitMEMLOCK
, and theTasksMax
settings in the# Service Limit Settings
section of thetimesten_home/startup/tt_myinstance.service
Times Ten service file (wheremyinstance
is the name of the TimesTen instance). This ensures the operating system limits requirements are met for the TimesTen environment. -
Installing the TimesTen utility script:
A TimesTen instance that is configured with systemd is not enabled automatically. The
root
user uses thetimesten_home/bin/setuproot
utility script with the-install
-systemd
options to enable automatic management of the TimesTen instance by systemd.
-
https://www.freedesktop.org/software/systemd/man/systemd.service.html for information on systemd.service - Service unit configuration.
-
https://www.freedesktop.org/software/systemd/man/systemd.exec.html for information on systemd.exec - Execution environment configuration. This is important for the
LimitNOFILE
and theLimitMEMLOCK
settings. -
https://www.freedesktop.org/software/systemd/man/systemd.resource-control.html for information on systemd.resource-control - Resource control unit settings. This is important for the
TasksMax
setting. -
"ttInstanceCreate" in the Oracle TimesTen In-Memory Database Reference for information on the TimesTen
ttInstanceCreate
utility.
Creating a TimesTen instance that uses automatic systemd management
Configure the TimesTen instance for systemd
Follow these steps to create the TimesTen instance with systemd:
Configure Linux kernel parameters for systemd
Configure shmmax and shmall
You must configure Linux shared memory so that the maximum size of a shared memory segment (the shmmax
memory kernel parameter) is large enough to contain the size of the total shared memory segment for the database. In TimesTen Classic, the entire database resides in a single shared memory segment. There is also a second memory segment used for PL/SQL.
On Linux, a shared memory segment consists of pages, where the default page size is normally 4 kB (4096 bytes). You can verify the default page size by running the getconf
PAGESIZE
command:
% getconf PAGESIZE 4096
Configure these shared memory kernel parameters to control the size of the shared memory segment:
-
shmmax
: The maximum size of a single shared memory segment expressed in bytes. The value must be large enough to accommodate the size of the total shared memory segment for the database. -
shmall
: The total size of shared memory segments system wide expressed in pages. The value is expressed in multiples of the page size (4 kB) andshmall * pagesize
must be greater or equal to the value ofshmmax
. It is recommended that you set the value ofshmall
to less than or equal to the total amount of physical RAM. To display the total amount of physical memory, run the Linuxcat /proc/meminfo
command.
Use the ttShmSize
utility to determine the size of the shared memory segment. The ttShmSize
utility uses the values of the PermSize
, the TempSize
, the LogBufMB
and the Connections
connection attributes (for a specified database) to determine this size. See "ttShmSize" in Oracle TimesTen In-Memory Database
Reference for details on the ttShmSize
utility and see "PermSize", "TempSize", "LogBufMB", and "Connections" in Oracle TimesTen In-Memory Database
Reference for details on each connection attribute.
ttShmSize
utility with the -connStr
option to determine the size of the shared memory segment using the database1
DSN. Supply a PermSize
value of 32GB (32768 MB), a TempSize
value of 4 GB (4096 MB), a LogBufMB
value of 1 GB (1024 MB) and a Connections
value of 2048. % ttShmSize -connstr "DSN=database1;PermSize=32768;TempSize=4096;LogBufMB=1024;Connections=2048"
The required shared memory size is 39991547720 bytes.
Note:
-
The
-connStr
option of thettShmSize
utility requires that you have defined a DSN in either the user.odbc.ini
or the systemsys.odbc.ini
file. You may use any DSN. Note that for any connection attribute not specified in the-connStr
option,ttShmSize
uses the setting defined in either the user.odbc.ini
file or the systemsys.odbc.ini
file for the specified DSN. If the connection attribute is missing from both the-connStr
option and either the user.odbc.ini
file or thesys.odbc.ini
file,ttShmSize
uses the default value for the connection attribute. -
You can add a DSN to either the user
.odbc.ini
file of the user or the systemsys.odbc.ini
file. For example, to add thedatabase1
DSN to the user.odbc.ini
file of the current operating system user:% vi ~/.odbc.ini ... [database1]
To size shmmax
and shmall
:
Note:
-
The settings for
shmmax
andshmall
in these examples can be increased if there are other applications that require them to be greater. -
If you are unsure of the size of your database, you can set
shmmax
andshmall
to correspond to a percentage of the size of physical memory (such as 80%).
Configure HugePages
You can configure HugePages
for more efficient memory management.
Once configured, the memory allocated for HugePages
is taken from the total RAM on the Linux host and is not available for any other use. In addition, the HugePages
memory segment is automatically locked and cannot be swapped to disk.
To configure HugePages
, you need to know:
-
The maximum size of the shared memory segment for the database
-
The
HugePages
page size on your Linux host -
The group ID of the instance administrator
Using the examples in the "Configure shmmax and shmall" section, where the value of shmmax
value is 39,054,246 kB, and the "Create the TimesTen Users Group" section, where the group ID of the instanceadmin
user is 10000:
-
The size of the total shared memory segment is is 39,054,246 kB.
-
The
HugePages
page size is 2048 KB. (This value is fixed for each platform and is not configurable.)To determine the HugePages page size, run the Linux
cat /proc/meminfo|grep
Hugepagesize
command:% cat /proc/meminfo | grep Hugepagesize Hugepagesize: 2048 kB
-
The group ID is 10000.
To determine the group ID of the instance administrator, log in as the
instanceadmin
user, and run the Linuxid
command:% id uid=55000(instanceadmin) gid=10000(g10000)groups=10000(g10000)
To configure HugePages
:
Note:
-
Because
HugePages
must be allocated in contiguous available memory space, the requested allocation may not be granted, or may be only partially granted, until after the host is restarted. Check theHugePages_Total
andHugePages_Free
values from/proc/meminfo
. Restarting grants the full allocation, assuming enough memory is available in the host. -
The TimesTen PL/SQL shared memory segment consumes some of the configured HugePages allocation, determined by the value of the
PLSQL_MEMORY_SIZE
connection attribute. See "PLSQL_MEMORY_SIZE" in the Oracle TimesTen In-Memory Database Reference for more information. -
On Linux, the
HugePages
segment is automatically locked such that the memory segment is not a candidate to be swapped to disk. Therefore, if you configureHugePages
, you do not need to set theMemoryLock
connection attribute.
Set the semaphore values
TimesTen has an upper bound on the maximum number of connections to the database. The database connections consist of:
-
User connections: established by user applications
-
System connections: established internally by TimesTen (set at 48 connections)
-
Other required connections (set at 107 connections)
Each of these connections is assigned one semaphore, such that the total semaphores for a database are:
Total semaphores = user connections (N) + system connections (48) + other required connections (107) Total semaphores = N + 155
The semaphore settings are located in the kernel.sem
configuration directive in /etc/sysctl.conf
:
kernel.sem = SEMMSL SEMMNS SEMOPM SEMMNI
where:
-
SEMMSL
is the maximum number of semaphores per array. This value is related to the maximum number of connections. Configure this value to be155
plus the number of simultaneous user connections. -
SEMMNS
is the maximum number of semaphores system wide. Use the formulaSEMMNS
= (SEMMNI
* SEMMSL
) as a guideline. However, in practice,SEMMNS
can be much less thanSEMMNI
* SEMMSL
. -
SEMOPM
is the maximum number of operations for eachsemop
call. -
SEMMNI
is the maximum number of arrays.
Follow these steps to configure the SEMMSL
and the SEMMNI
settings. Ensure that the user is root
:
Note:
If you are using replication, the Linux platform for each host on which the master databases reside must have similar kernel settings for shared memory and semaphores. Specifically, theSEMMSL
and SEMMNI
settings must be large enough on all hosts that participate in an active standby replication scheme before the duplication is performed. In the event of a failover, the standby must be able to accommodate the active.
Set the SHMMNI parameter
The SHMMNI
value controls the number of shared memory segments that the host can create simultaneously. TimesTen creates a shared memory segment for the TimesTen database and a shared memory segment for PL/SQL. In addition, there is a small shared memory segment that is allocated for the duration of each client/server connection. This shared memory segment is created at connect time and is destroyed when the client/server connection is disconnected from the TimesTen database. There is one shared memory segment per client/server connection.
You must configure the SHMMNI
parameter setting to account for the number of client/server connections. Set SHMMNI
to a value that is greater than number of expected client/server connections. (Ensure to also take into account the TimesTen shared memory segment, the PL/SQL shared memory segment, and other programs that use shared memory.) As an example, if you expect there to be 8000
client/server connections, an appropriate value is 9000
or greater. A value of 9000
or greater is appropriate as TimesTen has system connections that are not included in the client/server connections count.
Follow these steps to configure the SHMMNI
setting. Ensure that the user is root
:
Note:
If you are using replication, the Linux platform for each host on which the master databases reside must have a similarSHMMNI
kernel setting. Specifically, the SHMMNI
setting must be large enough on all hosts that participate in an active standby replication scheme before the duplication is performed. In the event of a failover, the standby must be able to accommodate the active.
Complete remaining steps for automatic systemd management
Complete the following steps to first review and, if necessary, modify the TimesTen service file. Then, install the TimesTen utility script by running the timesten_home/bin/setuproot
script. As a final step, run the systemd systemctl
start
command to start the TimesTen service.
About modifying a TimesTen instance to enable or disable management by systemd
The instance administrator uses the ttInstanceModify
utility to modify an existing TimesTen instance. The instance administrator specifies the -systemd
option to configure systemd for the existing instance or the -nosystemd
option to remove the systemd configuration from the existing instance.
If ttInstanceModify
-systemd
is used: The root
user runs the timesten_home/bin/setuproot
script with the -install
-systemd
options. This enables systemd to automatically manage the TimesTen daemon.
If ttInstanceModify
-nosystemd
is used: The root
user runs the timesten_home/bin/setuproot
script with the -uninstall
-systemd
options. This results in systemd no longer automatically managing the TimesTen daemon.
For more information, see:
-
"Modifying a TimesTen instance to enable management by systemd" for an example illustrating how to modify an instance using the
ttInstanceModify
-systemd
option. -
"Modifying a TimesTen instance to disable management by systemd" for an example illustrating how to modify an instance using the
ttInstanceModify
-nosystemd
option.
Modifying a TimesTen instance to enable management by systemd
This example assumes you have created the myinstance_2
TimesTen instance without systemd configured. It walks you through the process for modifying the myinstance_2
instance such that it is configured for systemd. It then performs the necessary steps for systemd to automatically manage the TimesTen daemon.
Modifying a TimesTen instance to disable management by systemd
This example assumes the myinstance_2
TimesTen instance is configured with systemd. The tt_myinstance_2
TimesTen service is running and is under automatic management of systemd. The example walks through the process of modifying the instance to remove the systemd configuration. It then performs the necessary steps to stop the tt_myinstance_2
TimesTen service and revert to manual control of the TimesTen daemon.
systemd
configuration. In addition, you have performed the steps to stop the automatic management of the TimesTen daemon by systemd. The instance administrator is now manually managing the TimesTen daemon.