摘要
RedisTimeSeries 简介
RedisTimeSeries 是 Redis 官方提供的一个 时序数据模块(Time Series Module),用于高效地存储、查询和分析时间序列数据。它可以作为 Redis 的一个模块加载使用(在 Redis Stack 中内置支持),将时序数据建模、存储和聚合能力扩展到 Redis 之外。
该模块以 Redis Module 方式加载,可无缝集成到现有 Redis 实例中。
Redis8+,RedisTimeSeries 已经内置在 Redis 中,可以在安装redis同时安装全部 Stack 模块。
安装 RedisTimeSeries
安装时需要科学上网,主要是安装依赖时需要从海外网下载,如果要部署在国内服务器,可能会连接失败。
可以在海外的相同配置的服务器上进行编译,之后将编译好的redistimeseries.so上传到国内服务器即可。
1 2 3 4 5 6 7 8 9 10 sudo dnf install -y \ gcc \ gcc-c++ \ make \ cmake \ autoconf \ automake \ libtool \ pkgconfig \ openssl-devel
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 mkdir -p /usr/local/soft/modules/cd /usr/local/soft/modulesgit clone --recursive https://github.com/RedisTimeSeries/RedisTimeSeries.git cd RedisTimeSeriesgit checkout v1.12.9 git submodule update --init --recursive ./sbin/setup dnf install -q -y ca-certificates dnf install -q -y wget unzip dnf install -q -y git jq /usr/local/soft/modules/RedisTimeSeries/deps/readies/bin/enable-utf8 dnf install -q -y autoconf libtool m4 automake dnf install -q -y openssl dnf install -q -y which /usr/local/soft/modules/RedisTimeSeries/deps/readies/bin/getepel dnf install -q -y openssl-devel /usr/local/soft/modules/RedisTimeSeries/deps/readies/bin/getgcc --modern dnf install -q -y valgrind /usr/bin/python3 /usr/local/soft/modules/RedisTimeSeries/deps/readies/bin/getcmake --usr dnf install -q -y lcov /usr/local/soft/modules/RedisTimeSeries/deps/readies/bin/getaws /usr/bin/python3 /usr/local/soft/modules/RedisTimeSeries/deps/readies/bin/getrmpytools --reinstall --modern /usr/bin/python3 -m pip install --disable-pip-version-check --user -r /usr/local/soft/modules/RedisTimeSeries/tests/flow/requirements.txt NO_PY2=1 /usr/local/soft/modules/RedisTimeSeries/deps/readies/bin/getpudb amazon_linux_2023 make
./sbin/setup 报错
本人使用的是 Amazon Linux 2023(内核 6.1),即 EL9,类似于CentOS 9,第一次运行会报错,大致报错信息如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 ./sbin/setup …… Status code: 403 for https://dyn.su/el9/base/x86_64/raven-release.el9.noarch.rpm (IP: 172.67.157.246) In /usr/local/soft/modules/RedisTimeSeries/deps/readies/bin/getepel: 346 347 fi 348 349 >>> install_raven 350 install_remi 351 352 command failed: /usr/local/soft/modules/RedisTimeSeries/deps/readies/bin/getepelIn /usr/local/soft/modules/RedisTimeSeries/sbin/setup: 18 python3 -m pip list 19 fi 20 21 >>> $ROOT /sbin/system-setup.py $SETUP_ARGS 22 if [[ $VERBOSE == 1 ]]; then 23 python3 -m pip list 24 fi
Redis 启用模块
1 2 cp bin/linux-x64-release/redistimeseries.so /usr/local/soft/redis-7.4.7/modules/redistimeseries.so
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 loadmodule /usr/local/soft/redis-7.4.7/modules/redistimeseries.so redis-server redis.conf redis-cli --user admin --pass 123456 127.0.0.1:6379> MODULE LIST 1) 1) "name" 2) "timeseries" 3) "ver" 4) (integer ) 11209 5) "path" 6) "/usr/local/soft/redis-7.4.7/modules/redistimeseries.so" 7) "args" 8) (empty array) 2) 1) "name" 2) "ReJSON" 3) "ver" 4) (integer ) 20816 5) "path" 6) "/usr/local/soft/redis-7.4.7/modules/rejson.so" 7) "args" 8) (empty array) 3) 1) "name" 2) "bf" 3) "ver" 4) (integer ) 20817 5) "path" 6) "/usr/local/soft/redis-7.4.7/modules/redisbloom.so" 7) "args" 8) (empty array) 4) 1) "name" 2) "search" 3) "ver" 4) (integer ) 21025 5) "path" 6) "/usr/local/soft/redis-7.4.7/modules/redisearch.so" 7) "args" 8) (empty array)