TimesTen内存数据库是否支持高可用?若支持该如何配置?
Absolutely! TimesTen In-Memory Database fully supports high availability—its Active Standby Pair configuration is built specifically to keep your mission-critical workloads running without interruption, even if a primary node goes down. Let me break down what you need to know, plus a step-by-step setup guide to get you started.
Yes, absolutely. The core high availability feature is the Active Standby Pair:
- The active (primary) node handles all read/write operations.
- The standby node maintains real-time synchronization with the primary via transaction logs.
- If the primary node fails, the standby can be quickly promoted to active (either manually or automatically) to minimize downtime.
- Once the original primary recovers, it can be set back to standby to restore the HA pair.
Prerequisites First
Before you start, make sure you have:
- Two servers/nodes with identical versions of TimesTen installed (same patch level too—critical for compatibility).
- Unrestricted network connectivity between nodes (default replication port is 53396; ensure firewalls don't block it).
- The same OS user account running TimesTen on both nodes (to align file permissions).
- Matching memory configuration parameters (
PermSize,TempSize) on both nodes—mismatches can break replication.
Configure DSNs on Both Nodes
Edit your ODBC configuration file (either sys.odbc.ini for system-wide access or ~/.odbc.ini for user-specific) on each node:
- Primary Node DSN Example:
[TT_PRIMARY] DataStore=/opt/timesten/ttstore/primary PermSize=4096 TempSize=2048 LogAutoTruncate=0 LogBufMB=128 LogFileSize=2048 ConnectionCharacterSet=AL32UTF8 ReplicationPort=53396 - Standby Node DSN Example:
[TT_STANDBY] DataStore=/opt/timesten/ttstore/standby PermSize=4096 TempSize=2048 LogAutoTruncate=0 LogBufMB=128 LogFileSize=2048 ConnectionCharacterSet=AL32UTF8 ReplicationPort=53396
Note:
LogAutoTruncate=0is required to prevent logs from being deleted before they're replicated to the standby.
Create the Active Standby Pair
Connect to the primary node's DSN using ttIsql:
ttIsql TT_PRIMARY
Then run the SQL command to define the replication pair (replace with your actual hostnames):
CREATE ACTIVE STANDBY PAIR TT_PRIMARY ON 'primary-node.yourdomain.com', TT_STANDBY ON 'standby-node.yourdomain.com';
Optional: If you need read-only replicas to scale read workloads, add them with the READ ONLY SUBSCRIBERS clause.
Start Replication
- On the primary node (still in
ttIsql):START REPLICATION; - On the standby node, connect to its DSN with
ttIsql TT_STANDBYand run:CALL ttRepStart;
Verify Replication is Working
Test data synchronization to confirm everything’s set up correctly:
- On the primary node, create a test table and insert data:
CREATE TABLE ha_test (id INT PRIMARY KEY, data VARCHAR(100)); INSERT INTO ha_test VALUES (1, 'TimesTen HA Test'); - On the standby node, query the table:
SELECT * FROM ha_test;
You should see the inserted row immediately if replication is functioning as expected.
Handle Failover & Failback
- Manual Failover: If the primary node fails, promote the standby to active on the standby node:
CALL ttRepStateSet('ACTIVE'); - Failback: Once the original primary is restored, set it back to standby:
CALL ttRepStateSet('STANDBY'); - Automatic Failover: For hands-off failover, configure it using the
ttRepAdmintool with the-automaticTakeoveroption. This requires setting up a watchdog process to monitor node health.
- Always keep both nodes on the same TimesTen version and patch level—upgrade the standby first, then failover, then upgrade the original primary.
- Monitor replication status regularly with
ttRepAdmin -showstatus TT_PRIMARYto catch issues early. - Ensure sufficient disk space for transaction logs on the primary node—logs won’t truncate until they’re replicated to the standby.
内容的提问来源于stack exchange,提问作者user7880058

