Switching the Time Series Engine¶
Overview¶
This article describes how to switch the time series engine in Guance. This operation is applicable when switching from InfluxDB to GuanceDB.
Prerequisites¶
- GuanceDB for Metrics is already deployed. If not, refer to GuanceDB Installation.
Deployment Information¶
| Name | Value |
|---|---|
| guance-insert Default Address | guancedb-cluster-guance-select.middleware |
| guance-insert Default Port | 8480 |
| guance-select Default Address | guancedb-cluster-guance-select.middleware |
| guance-select Default Port | 8481 |
Switch Procedure¶
Backup Tables¶
CREATE TABLE `main_workspace_bak` LIKE `main_workspace`;
INSERT INTO `main_workspace_bak` SELECT * FROM `main_workspace`;
CREATE TABLE `main_influx_db_bak` LIKE `main_influx_db`;
INSERT INTO `main_influx_db_bak` SELECT * FROM `main_influx_db`;
Insert GuanceDB Information¶
- Log in to the Guance df_core database and execute the following statement:
INSERT INTO `main_influx_instance` (`uuid`, `host`, `authorization`, `configJSON`,`dbcount`, `user`, `pwd`, `dbType`, `priority`, `status`, `creator`, `updator`, `createAt`, `deleteAt`, `updateAt`)
VALUES
('276f8404252347d18e469f65f5a1abdd', 'http://0.0.0.0', '{\"admin\": {\"password\": \"*\", \"username\": \"*\"}}','{"read": {"host": "http://guancedb-cluster-guance-select.middleware:8481"}, "write": {"host": "http://guancedb-cluster-guance-insert.middleware:8480"}}', 0, '', '', 'guancedb', 50, 0, '', '', UNIX_TIMESTAMP(), -1, UNIX_TIMESTAMP());
Verification:
select count(1) from main_influx_instance where uuid='276f8404252347d18e469f65f5a1abdd';
+----------+
| count(1) |
+----------+
| 1 |
+----------+
1 row in set (0.00 sec)
If the query result is greater than or equal to 1, the execution is successful.
Replace InfluxDB with GuanceDB Information¶
- Change the InfluxDB status
Verification:
select count(1) from main_influx_instance where status=3 and dbType='influxdb';
+----------+
| count(1) |
+----------+
| 1 |
+----------+
1 row in set (0.00 sec)
If the query result is greater than or equal to 1, the execution is successful.
- Batch update the time series database information for all workspaces
update main_influx_db set influxInstanceUUID=(select uuid from main_influx_instance where status=0 and dbType='guancedb' order by priority desc limit 1) , dbType='guancedb' where status=0;
Verification:
SELECT count(1)
FROM main_influx_db AS db
JOIN main_influx_instance AS instance ON db.influxInstanceUUID = instance.uuid
WHERE db.status = 0
AND db.dbType = 'guancedb';
+----------+
| count(1) |
+----------+
| 26 |
+----------+
1 row in set (0.01 sec)
If the query result is greater than or equal to 1, the execution is successful.
- Batch update the
metricvalue indatastoreof themain_workspacetable
update main_workspace set datastore=JSON_SET(datastore, "$.metric", "guancedb") where status=0 and datastore ->> "$.metric" = "influxdb";
Verification:
SELECT count(1)
FROM main_workspace
WHERE status = 0
AND datastore ->> "$.metric" = "guancedb";
+----------+
| count(1) |
+----------+
| 26 |
+----------+
1 row in set (0.00 sec)
If the query result is greater than or equal to 1, the execution is successful.
- Update the DB ID
UPDATE df_core.main_influx_db
SET df_core.main_influx_db.db =(
SELECT df_core.main_workspace.id
FROM df_core.main_workspace
WHERE df_core.main_workspace.dbUUID = df_core.main_influx_db.UUID
);
Verification:
SELECT count(1)
FROM df_core.main_influx_db AS db
JOIN df_core.main_workspace AS ws ON ws.dbUUID = db.UUID;
+----------+
| count(1) |
+----------+
| 26 |
+----------+
1 row in set (0.00 sec)
If the query result is greater than or equal to 1, the execution is successful.
Restart All Kodo Services¶
Clear Redis¶
Choose one of the two methods:
- Restart Redis
- Execute the cache clearing command
# Delete all "dbinfo:*" cache records, execute the following batch delete command
redis-cli -h <host> -p <port> -n 0 -a <password> keys dbinfo:* | xargs -r -t -n1 redis-cli -h <host> -p <port> -n 0 -a <password> del
# Delete all "wkspInfo:*" cache records, execute the following batch delete command
redis-cli -h <host> -p <port> -n 0 -a <password> keys wkspInfo:* | xargs -r -t -n1 redis-cli -h <host> -p <port> -n 0 -a <password> del
# Delete all "tkn_info:*" cache records, execute the following batch delete command
redis-cli -h <host> -p <port> -n 0 -a <password> keys tkn_info:* | xargs -r -t -n1 redis-cli -h <host> -p <port> -n 0 -a <password> del