background

Why upgrade TDengine?

Since I started using TDengine, I chose the latest version 2.1.2.0, which should not be old. However, I found a problem today when I used the pagination function to query the table. TDengine is a new database after all, and it is normal to have problems.

[root@hadoop2 ~]# taos --versionVersion: 2.1.2.0Copy the code

Problem of repetition

After clicking different page numbers on the front page, the table data remains unchanged…

useSpringBootIntegrated withTDengine , MyBatisPlusAfter paging query on some tables, differentoffsetReturns the same value. Checked the front and back end parameter data interaction, no problem; The following is aMyBatisPlusSQL statements generated on the first 3 pages of a table query, holding these statements intaosClient execution returns the same data!! Amazing ~

SELECT ts,voltage,currente,temperature,sn,city,groupid  FROM power  WHERE sn = '1105' AND ts BETWEEN 'the 2021-09-07 09:15:11. 138' AND 'the 2021-09-07 10:15:11. 138' and groupid=2 LIMIT 10 offset 10;

SELECT ts,voltage,currente,temperature,sn,city,groupid  FROM power  WHERE sn = '1105' AND ts BETWEEN 'the 2021-09-07 09:15:11. 138' AND 'the 2021-09-07 10:15:11. 138' and groupid=2 LIMIT 10 offset 20;

SELECT ts,voltage,currente,temperature,sn,city,groupid  FROM power  WHERE sn = '1105' AND ts BETWEEN 'the 2021-09-07 09:15:11. 138' AND 'the 2021-09-07 10:15:11. 138' and groupid=2 LIMIT 10 offset 30;
Copy the code

After checking the code and configuration repeatedly, and searching the official Issues, we found that this might be a bug, and there is a corresponding PR, and the new version may have solved this problem. So why don’t you upgrade?

There are two main steps:

  1. Upgrade the server.
  2. Upgrade the client;

Version upgrade: Upgrade the server

Here I have upgraded from 2.1.2.0 to 2.2.0.0.

In order to prevent data loss, I took snapshots of the two virtual machines even though all the data was test data (official demo data and test data I built by myself)

The TDengine on my two virtual machines had already been clustered, but I did not move the second host out of the cluster during the upgrade. On the one hand, I wanted to see how TDengine handled the existing data and cluster during the upgrade. On the other hand, after all, snapshots were made. Time travel is always available.

  • Download the RPM
[root@hadoop1 local]Wget # https://www.taosdata.com/assets-download/TDengine-server-2.2.0.0-Linux-x64.rpm
Copy the code
  • Operations on the first host:
[root@hadoop1 ~]# taos --versionVersion: 2.1.2.0Stop the old version of taosd service
[root@hadoop1 ~]# systemctl stop taosd

Check the installed version information
[root@hadoop1 ~]# rpm -qa | grep tdengineTdengine 2.1.2.0-3. X86_64# Uninstall the old version
[root@hadoop1 ~]# rpm -e tdengineTDengine is removed successfully! Warning: file /usr/local/taos/ CFG /taos. CFG: Removal failed: there is no file or directoryInstall the new version
[root@hadoop1 local]# RPM - the ivh TDengine - server - 2.2.0.0 - Linux - x64. RPM

# Start the new version
[root@hadoop1 local]# systemctl start taosd

Confirm the status of the new version service
[root@hadoop1 local]# systemctl status taosdLow taosd. Service - TDengine server service the Loaded: the Loaded (/ etc/systemd/system/taosd. Service; enabled; Vendor PRESET: Disabled) Active: Active (running) since 5 2021-09-10 10:42:11 CST; 1s ago Process: 121891 ExecStartPre=/usr/local/taos/bin/startPre.sh (code=exited, status=0/SUCCESS) Main PID: 121899 (taosd) CGroup: / / system. Slice taosd. Service └ ─ 121899 / usr/bin/taosd September 10 10:42:11 hadoop1 systemd [1] : Starting TDengine server service... 9月 10 10:42:11 Hadoop1 SystemD [1]: Started TDengine Server. 9月 10 10:42:11 Hadoop1 TDengine:[121899]: Starting TDengine service... September 10 10:42:12 hadoop1 TDengine:[121899]: Started TDengine service successfully.Copy the code
  • Operation on the second host:
[root@hadoop2 ~]# taos --versionVersion: 2.1.2.0Stop the old version of taosd service
[root@hadoop2 ~]# systemctl stop taosd

Check the installed version information
[root@hadoop2 ~]# rpm -qa | grep tdengineTdengine 2.1.2.0-3. X86_64# Uninstall the old version
[root@hadoop2 ~]# rpm -e tdengineTDengine is removed successfully! Warning: file /usr/local/taos/ CFG /taos. CFG: Removal failed: there is no file or directoryInstall the new version
[root@hadoop2 local]# RPM - the ivh TDengine - server - 2.2.0.0 - Linux - x64. RPM

# Start the new version
[root@hadoop2 local]# systemctl start taosd
[root@hadoop2 local]# taos --versionVersion: 2.2.0.0Confirm the status of the new version service
[root@hadoop2 local]# systemctl status taosdLow taosd. Service - TDengine server service the Loaded: the Loaded (/ etc/systemd/system/taosd. Service; enabled; Vendor PRESET: Disabled) Active: Active (running) since 5 2021-09-10 10:45:29 CST; 14min ago Process: 117249 ExecStartPre=/usr/local/taos/bin/startPre.sh (code=exited, status=0/SUCCESS) Main PID: 117256 (taosd) CGroup: / / system. Slice taosd. Service └ ─ 117256 / usr/bin/taosd September 10 10:45:29 hadoop2 systemd [1] : Starting TDengine server service... 9月 10 10:45:29 Hadoop2 SystemD [1]: Started TDengine Service. 9月 10 10:45:29 Hadoop2 TDengine:[117256]: Started TDengine Service. Starting TDengine service... September 10 10:45:30 hadoop2 TDengine:[117256]: Started TDengine service successfully.Copy the code

In this way, after the TAosd service is started on the two hosts, the cluster of the earlier version is automatically restored. GUI clients can be connected (using JDBC-restful mode), and all data is available. A question arises:

Q: Wow, after the service starts, data does not need to be migrated, and the cluster is automatically restored. A: In fact, after A brief observation, we can see that after executing the uninstall command, the configuration and data of the old version and even the log are not deleted. This is also the humanization of 'TDengine'. After all, the user's data cannot be deleted at will. The default installation directory is as follows: Configuration file: '/etc/taos/taos. CFG' Data directory: '/var/lib/taos' Log directory:' /var/log/taos'Copy the code

Version upgrade: Upgrade the client

After upgrading TDengine’s back-end services, you may also need to upgrade the client.

  1. Student: If you use thetaJDBC-RESTfulInterface mode, no need to rely on the local function library, there is no problem, no need to do other changes, can be used directly, to the end of the upgrade;
  2. Student: If you use thetaJDBC-JNIThe development environment client needs to be upgraded at the same time as the projecttaos-jdbcdriverThe version also needs to be updated; Only in this case do you need to perform the following operations.
  • Taos client version upgrade on Windows10

Of course, directly download the same version of the client with the server, don’t bother oh.

Here I have upgraded from 2.1.2.0 to 2.2.0.0.

Download the specified version of the client and install: https://www.taosdata.com/assets-download/TDengine-client-2.2.0.0-Windows-x64.exe

  • Pom filetaos-jdbcdriverVersion dependent upgrades

<dependency>
    <groupId>com.taosdata.jdbc</groupId>
    <artifactId>taos-jdbcdriver</artifactId>
    <version>2.0.30</version>
</dependency>
Copy the code

Is amended as:

<dependency>
    <groupId>com.taosdata.jdbc</groupId>
    <artifactId>taos-jdbcdriver</artifactId>
    <version>2.0.31</version>
</dependency>
Copy the code

Reference

  • www.taosdata.com/blog/2019/0…
  • www.taosdata.com/cn/document…

If you have any questions or any bugs are found, please feel free to contact me.

Your comments and suggestions are welcome!

This article has participated in the activity of “New person creation Ceremony”, and started the road of digging gold creation together.