valkey README

The project's README from github.com/valkey-io/valkey. As one markdown file: README.md.

codecov OpenSSF Scorecard

This project was forked from the open source Redis project right before the transition to their new source available licenses.

This README is just a fast quick start document. More details can be found under valkey.io

What is Valkey?

Valkey is a high-performance data structure server that primarily serves key/value workloads. It supports a wide range of native structures and an extensible plugin system for adding new data structures and access patterns.

Building Valkey using Makefile

Valkey can be compiled and used on Linux, macOS, OpenBSD, NetBSD, FreeBSD. We support big endian and little endian architectures, and both 32 bit and 64 bit systems.

It may compile on Solaris derived systems (for instance SmartOS) but our support for this platform is best effort and Valkey is not guaranteed to work as well as in Linux, macOS, and *BSD.

It is as simple as:

% make

To build with TLS support, you'll need OpenSSL development libraries (e.g. libssl-dev on Debian/Ubuntu).

To build TLS support as Valkey built-in:

% make BUILD_TLS=yes

To build TLS as Valkey module:

% make BUILD_TLS=module

Note that sentinel mode does not support TLS module.

To build with experimental RDMA support you'll need RDMA development libraries (e.g. librdmacm-dev and libibverbs-dev on Debian/Ubuntu).

To build RDMA support as Valkey built-in:

% make BUILD_RDMA=yes

To build RDMA as Valkey module:

% make BUILD_RDMA=module

To build with systemd support, you'll need systemd development libraries (such as libsystemd-dev on Debian/Ubuntu or systemd-devel on CentOS) and run:

% make USE_SYSTEMD=yes

To build with enhanced stack traces that include file names and line numbers for all functions (including static functions), use libbacktrace:

% make USE_LIBBACKTRACE=yes

To build Valkey without the Lua engine:

% make BUILD_LUA=no

To append a suffix to Valkey program names, use:

% make PROG_SUFFIX="-alt"

You can build a 32 bit Valkey binary using:

% make 32bit

After building Valkey, it is a good idea to test it using:

% make test

The above runs the main integration tests. Additional tests are started using:

% make test-unit     # Unit tests
% make test-modules  # Tests of the module API
% make test-sentinel # Valkey Sentinel integration tests
% make test-cluster  # Valkey Cluster integration tests

More about running the integration tests can be found in tests/README.md and for unit tests, see src/unit/README.md.

Performance monitoring

Valkey Performance Dashboards provide a consolidated view of throughput trends across versions, helping contributors validate improvements and identify regressions quickly.

Fixing build problems with dependencies or cached build options

Valkey has some dependencies which are included in the deps directory. make does not automatically rebuild dependencies even if something in the source code of dependencies changes.

When you update the source code with git pull or when code inside the dependencies tree is modified in any other way, make sure to use the following command in order to really clean everything and rebuild from scratch:

% make distclean

This will clean: jemalloc, lua, libvalkey, linenoise and other dependencies.

Also if you force certain build options like 32bit target, no C compiler optimizations (for debugging purposes), and other similar build time options, those options are cached indefinitely until you issue a make distclean command.

Fixing problems building 32 bit binaries

If after building Valkey with a 32 bit target you need to rebuild it with a 64 bit target, or the other way around, you need to perform a make distclean in the root directory of the Valkey distribution.

In case of build errors when trying to build a 32 bit binary of Valkey, try the following steps:

Allocator

Selecting a non-default memory allocator when building Valkey is done by setting the MALLOC environment variable. Valkey is compiled and linked against libc malloc by default, with the exception of jemalloc being the default on Linux systems. This default was picked because jemalloc has proven to have fewer fragmentation problems than libc malloc.

To force compiling against libc malloc, use:

% make MALLOC=libc

To compile against jemalloc on Mac OS X systems, use:

% make MALLOC=jemalloc

Monotonic clock

By default, Valkey uses the processor's internal instruction clock (TSC on x86, CNTVCT on ARM) for monotonic time tracking, which provides approximately 3x faster time access compared to POSIX clock_gettime (~10-30ns vs ~100ns). This is enabled by default on supported architectures (x86_64 Linux and aarch64) and automatically falls back to POSIX clock_gettime on unsupported systems.

For more information about processor clock usage, see: http://oliveryang.net/2015/09/pitfalls-of-TSC-usage/

To disable the processor clock and force POSIX clock_gettime, use:

% make CFLAGS="-DNO_PROCESSOR_CLOCK"

Verbose build

Valkey will build with a user-friendly colorized output by default. If you want to see a more verbose output, use the following:

% make V=1

Running Valkey

To run Valkey with the default configuration, just type:

% cd src
% ./valkey-server

If you want to provide your valkey.conf, you have to run it using an additional parameter (the path of the configuration file):

% cd src
% ./valkey-server /path/to/valkey.conf

It is possible to alter the Valkey configuration by passing parameters directly as options using the command line. Examples:

% ./valkey-server --port 9999 --replicaof 127.0.0.1 6379
% ./valkey-server /etc/valkey/6379.conf --loglevel debug

All the options in valkey.conf are also supported as options using the command line, with exactly the same name.

Running Valkey with TLS:

Running manually

To manually run a Valkey server with TLS mode (assuming ./utils/gen-test-certs.sh was invoked so sample certificates/keys are available):

Note that you can disable TCP by specifying --port 0 explicitly. It's also possible to have both TCP and TLS available at the same time, but you'll have to assign different ports.

Use valkey-cli to connect to the Valkey server:

./src/valkey-cli --tls \
    --cert ./tests/tls/valkey.crt \
    --key ./tests/tls/valkey.key \
    --cacert ./tests/tls/ca.crt

Specifying --tls-replication yes makes a replica connect to the primary.

Using --tls-cluster yes makes Valkey Cluster use TLS across nodes.

Running Valkey with RDMA:

Note that Valkey Over RDMA is an experimental feature. It may be changed or removed in any minor or major version. Currently, it is only supported on Linux.

It's possible to change bind address/port of RDMA by runtime command:

192.168.122.100:6379> CONFIG SET rdma-port 6380

It's also possible to have both RDMA and TCP available, and there is no conflict of TCP(6379) and RDMA(6379), Ex:

% ./src/valkey-server --protected-mode no \
     --loadmodule src/valkey-rdma.so --rdma-bind 192.168.122.100 --rdma-port 6379 \
     --port 6379

Note that the network card (192.168.122.100 of this example) should support RDMA. To test a server supports RDMA or not:

% rdma res show (a new version iproute2 package)

Or:

% ibv_devices

Playing with Valkey

You can use valkey-cli to play with Valkey. Start a valkey-server instance, then in another terminal try the following:

% cd src
% ./valkey-cli
valkey> ping
PONG
valkey> set foo bar
OK
valkey> get foo
"bar"
valkey> incr mycounter
(integer) 1
valkey> incr mycounter
(integer) 2
valkey>

Installing Valkey

In order to install Valkey binaries into /usr/local/bin, just use:

% make install

You can use make PREFIX=/some/other/directory install if you wish to use a different destination.

Note: For compatibility with Redis, we create symlinks from the Redis names (redis-server, redis-cli, etc.) to the Valkey binaries installed by make install. The symlinks are created in same directory as the Valkey binaries. The symlinks are removed when using make uninstall. The creation of the symlinks can be skipped by setting the makefile variable USE_REDIS_SYMLINKS=no.

make install will just install binaries in your system, but will not configure init scripts and configuration files in the appropriate place. This is not needed if you just want to play a bit with Valkey, but if you are installing it the proper way for a production system, we have a script that does this for Ubuntu and Debian systems:

% cd utils
% ./install_server.sh

Note: install_server.sh will not work on macOS; it is built for Linux only.

The script will ask you a few questions and will setup everything you need to run Valkey properly as a background daemon that will start again on system reboots.

You'll be able to stop and start Valkey using the script named /etc/init.d/valkey_<portnumber>, for instance /etc/init.d/valkey_6379.

Building using CMake

In addition to the traditional Makefile build, Valkey supports an alternative, experimental, build system using CMake.

To build and install Valkey, in Release mode (an optimized build), type this into your terminal:

mkdir build-release
cd $_
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/opt/valkey
sudo make install
# Valkey is now installed under /opt/valkey

Other options supported by Valkey's CMake build system:

Special build flags

Common flags

Verbose build

CMake generates a user-friendly colorized output by default. If you want to see a more verbose output, use the following:

make VERBOSE=1

Troubleshooting

During the CMake stage, CMake caches variables in a local file named CMakeCache.txt. All variables generated by Valkey are removed from the cache once consumed (this is done by calling to unset(VAR-NAME CACHE)). However, some variables, like the compiler path, are kept in cache. To start a fresh build either remove the cache file CMakeCache.txt from the build folder, or delete the build folder completely.

It is important to re-run CMake when adding new source files.

Integration with IDE

During the CMake stage of the build, CMake generates a JSON file named compile_commands.json and places it under the build folder. This file is used by many IDEs and text editors for providing code completion (via clangd).

A small caveat is that these tools will look for compile_commands.json under the Valkey's top folder. A common workaround is to create a symbolic link to it:

cd /path/to/valkey/
# We assume here that your build folder is `build-release`
ln -sf $(pwd)/build-release/compile_commands.json $(pwd)/compile_commands.json

Restart your IDE and voila

Code contributions

Please see the CONTRIBUTING.md. For security bugs and vulnerabilities, please see SECURITY.md.

Valkey is an open community project under LF Projects

Valkey a Series of LF Projects, LLC 2810 N Church St, PMB 57274 Wilmington, Delaware 19802-4447

valkey (valkey-io/valkey)

Searching Database…

27.5K ·GitHub
这是什么?Valkey 是一个开源的高性能数据结构服务器,面向键值类型的业务场景,比如缓存和其他实时用途。它内置了丰富的原生数据结构,还提供插件系统,可以添加新的结构。
它和直接用 Redis 有什么区别?它是 Redis 的一个分支(fork),在 Redis 改用新的 source-available 许可证之前就已创建,因此 Valkey 在 BSD-3-Clause 许可证下保持完全开源。为了做到无缝兼容,make install 甚至会创建指向 Valkey 可执行文件的 redis-server 和 redis-cli 符号链接。
我怎么把它跑起来?先用 make 编译,然后运行 cd src && ./valkey-server —— 你可以传入配置文件路径,也可以用 --port 9999 这样的参数覆盖 valkey.conf 里的任意配置项。make install 会把可执行文件复制到 /usr/local/bin。
编译它需要装哪些东西?只需要一套 C 工具链:jemalloc、Lua 等依赖已经打包在 deps 目录里。只有可选功能才需要装系统软件包 —— TLS 需要 OpenSSL 的开发头文件,systemd 或 RDMA 集成需要相应的开发库。
部署之前有什么坑要注意?RDMA 支持还是实验性的,只在 Linux 上可用,可能在任何版本中变更或被移除;哨兵(sentinel)模式不支持以模块方式启用 TLS。用于配置守护进程的 install_server.sh 脚本只针对 Linux,在 macOS 上跑不了。
它能在哪些系统上运行?Linux、macOS、OpenBSD、NetBSD 和 FreeBSD,同时提供 32 位和 64 位版本,大端和小端 CPU 都支持。源自 Solaris 的系统只提供尽力而为的支持,Windows 则不受支持。
为什么要单独创建 Valkey 这个项目?社区在 Redis 改用新的 source-available 许可证之前将其分支,保留了一个完全开源的 BSD 许可后续版本。如今它作为 LF Projects 旗下的开放社区项目运作。
服务器启动之后,我怎么试一试?另开一个终端,打开 valkey-cli,然后输入类似 Redis 的命令:输入 ping 会返回 PONG,set foo bar 可以存一个值,get foo 可以把它读回来,incr mycounter 可以让计数器加一。
流量可以用 TLS 加密吗?可以。用 make BUILDTLS=yes 编译(或以模块方式启用),用 utils/gen-test-certs.sh 生成示例证书,然后让 TCP 和 TLS 在不同端口上并行运行。--tls-replication yes 会加密副本(replica)链路,--tls-cluster yes 会加密集群节点之间的流量。
我怎么验证编译出来的东西真的能用?运行 make test 执行主要的集成测试。其余部分由单独的测试套件覆盖:make test-unit、make test-modules、make test-sentinel 和 make test-cluster。
What are similar projects?phpredis, kividb, dragonfly, redis, dicedb, redisson, memcached, redis
Creator
valkey-io
Size
263.3 MB
Stars
27.5K
Age
2y
Commits · 90 Days