- Notifications
You must be signed in to change notification settings - Fork970
A flexible distributed key-value database that is optimized for caching and other realtime workloads.
License
valkey-io/valkey
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
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 fastquick start document. More details can be found undervalkey.io
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.
Valkey can be compiled and used on Linux, macOS, OpenBSD, NetBSD, FreeBSD.We support big endian and little endian architectures, and both 32 bitand 64 bit systems.
It may compile on Solaris derived systems (for instance SmartOS) but oursupport for this platform isbest effort and Valkey is not guaranteed towork as well as in Linux, macOS, and *BSD.
It is as simple as:
% makeTo 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=yesTo build TLS as Valkey module:
% make BUILD_TLS=moduleNote 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=yesTo build RDMA as Valkey module:
% make BUILD_RDMA=moduleTo build with systemd support, you'll need systemd development libraries (suchas libsystemd-dev on Debian/Ubuntu or systemd-devel on CentOS) and run:
% make USE_SYSTEMD=yesSince Valkey version 8.1,fast_float has been introduced as an optionaldependency, which can speed up sorted sets and other commands that usethe double datatype. To build withfast_float support, you'll need aC++ compiler and run:
% make USE_FAST_FLOAT=yesTo append a suffix to Valkey program names, use:
% make PROG_SUFFIX="-alt"You can build a 32 bit Valkey binary using:
% make 32bitAfter building Valkey, it is a good idea to test it using:
% make testThe 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 testsMore about running the integration tests can be found intests/README.md and for unit tests, seesrc/unit/README.md.
Valkey has some dependencies which are included in thedeps directory.make does not automatically rebuild dependencies even if something inthe source code of dependencies changes.
When you update the source code withgit pull or when code inside thedependencies tree is modified in any other way, make sure to use the followingcommand in order to really clean everything and rebuild from scratch:
% make distcleanThis will clean: jemalloc, lua, libvalkey, linenoise and other dependencies.
Also if you force certain build options like 32bit target, no C compileroptimizations (for debugging purposes), and other similar build time options,those options are cached indefinitely until you issue amake distcleancommand.
If after building Valkey with a 32 bit target you need to rebuild itwith a 64 bit target, or the other way around, you need to perform amake distclean in the root directory of the Valkey distribution.
In case of build errors when trying to build a 32 bit binary of Valkey, trythe following steps:
- Install the package libc6-dev-i386 (also try g++-multilib).
- Try using the following command line instead of
make 32bit:make CFLAGS="-m32 -march=native" LDFLAGS="-m32"
Selecting a non-default memory allocator when building Valkey is done by settingtheMALLOC environment variable. Valkey is compiled and linked against libcmalloc by default, with the exception of jemalloc being the default on Linuxsystems. This default was picked because jemalloc has proven to have fewerfragmentation problems than libc malloc.
To force compiling against libc malloc, use:
% make MALLOC=libcTo compile against jemalloc on Mac OS X systems, use:
% make MALLOC=jemallocBy default, Valkey will build using the POSIX clock_gettime function as themonotonic clock source. On most modern systems, the internal processor clockcan be used to improve performance. Cautions can be found here:http://oliveryang.net/2015/09/pitfalls-of-TSC-usage/
To build with support for the processor's internal instruction clock, use:
% make CFLAGS="-DUSE_PROCESSOR_CLOCK"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=1To run Valkey with the default configuration, just type:
% cd src% ./valkey-serverIf you want to provide your valkey.conf, you have to run it using an additionalparameter (the path of the configuration file):
% cd src% ./valkey-server /path/to/valkey.confIt is possible to alter the Valkey configuration by passing parameters directlyas options using the command line. Examples:
% ./valkey-server --port 9999 --replicaof 127.0.0.1 6379% ./valkey-server /etc/valkey/6379.conf --loglevel debugAll the options in valkey.conf are also supported as options using the commandline, with exactly the same name.
To manually run a Valkey server with TLS mode (assuming./utils/gen-test-certs.shwas invoked so sample certificates/keys are available):
TLS built-in mode:
./src/valkey-server --tls-port 6379 --port 0 \ --tls-cert-file ./tests/tls/valkey.crt \ --tls-key-file ./tests/tls/valkey.key \ --tls-ca-cert-file ./tests/tls/ca.crtTLS module mode:
./src/valkey-server --tls-port 6379 --port 0 \ --tls-cert-file ./tests/tls/valkey.crt \ --tls-key-file ./tests/tls/valkey.key \ --tls-ca-cert-file ./tests/tls/ca.crt \ --loadmodule src/valkey-tls.so
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.
Usevalkey-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.crtSpecifying--tls-replication yes makes a replica connect to the primary.
Using--tls-cluster yes makes Valkey Cluster use TLS across nodes.
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.
RDMA built-in mode:
./src/valkey-server --protected-mode no \ --rdma-bind 192.168.122.100 --rdma-port 6379RDMA module mode:
./src/valkey-server --protected-mode no \ --loadmodule src/valkey-rdma.so --rdma-bind 192.168.122.100 --rdma-port 6379
It's possible to change bind address/port of RDMA by runtime command:
192.168.122.100:6379> CONFIG SET rdma-port 6380It's also possible to have both RDMA and TCP available, and there is noconflict 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 6379Note that the network card (192.168.122.100 of this example) should supportRDMA. To test a server supports RDMA or not:
% rdma res show (a new version iproute2 package)Or:
% ibv_devicesYou can use valkey-cli to play with Valkey. Start a valkey-server instance,then in another terminal try the following:
% cd src% ./valkey-clivalkey> pingPONGvalkey> set foo barOKvalkey> get foo"bar"valkey> incr mycounter(integer) 1valkey> incr mycounter(integer) 2valkey>In order to install Valkey binaries into /usr/local/bin, just use:
% make installYou can usemake PREFIX=/some/other/directory install if you wish to use adifferent destination.
Note: For compatibility with Redis, we create symlinks from the Redis names (redis-server,redis-cli, etc.) to the Valkey binaries installed bymake install.The symlinks are created in same directory as the Valkey binaries.The symlinks are removed when usingmake uninstall.The creation of the symlinks can be skipped by setting the makefile variableUSE_REDIS_SYMLINKS=no.
make install will just install binaries in your system, but will not configureinit scripts and configuration files in the appropriate place. This is notneeded if you just want to play a bit with Valkey, but if you are installingit the proper way for a production system, we have a script that does thisfor Ubuntu and Debian systems:
% cd utils% ./install_server.shNote: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 needto run Valkey properly as a background daemon that will start again onsystem 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.
In addition to the traditionalMakefile build, Valkey supports an alternative,experimental, build system usingCMake.
To build and installValkey, inRelease mode (an optimized build), type this into your terminal:
mkdir build-releasecd$_cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/opt/valkeysudo make install# Valkey is now installed under /opt/valkey
Other options supported by Valkey'sCMake build system:
-DBUILD_TLS=<yes|no>enable TLS build for Valkey. Default:no-DBUILD_RDMA=<no|module>enable RDMA module build (only module mode supported). Default:no-DBUILD_MALLOC=<libc|jemalloc|tcmalloc|tcmalloc_minimal>choose the allocator to use. Default on Linux:jemalloc, for other OS:libc-DBUILD_SANITIZER=<address|thread|undefined>build with address sanitizer enabled. Default: disabled (no sanitizer)-DBUILD_UNIT_TESTS=[yes|no]when set, the build will produce the executablevalkey-unit-tests. Default:no-DBUILD_TEST_MODULES=[yes|no]when set, the build will include the modules located under thetests/modulesfolder. Default:no-DBUILD_EXAMPLE_MODULES=[yes|no]when set, the build will include the example modules located under thesrc/modulesfolder. Default:no
-DCMAKE_BUILD_TYPE=<Debug|Release...>define the build type, see CMake manual for more details-DCMAKE_INSTALL_PREFIX=/installation/pathoverride this value to define a custom install prefix. Default:/usr/local-G"<Generator Name>"generate build files for "Generator Name". By default, CMake will generateMakefiles.
CMake generates a user-friendly colorized output by default.If you want to see a more verbose output, use the following:
make VERBOSE=1
During theCMake stage,CMake caches variables in a local file namedCMakeCache.txt. All variables generated by Valkeyare removed from the cache once consumed (this is done by calling tounset(VAR-NAME CACHE)). However, some variables,like the compiler path, are kept in cache. To start a fresh build either remove the cache fileCMakeCache.txt from thebuild folder, or delete the build folder completely.
It is important to re-runCMake when adding new source files.
During theCMake stage of the build,CMake generates a JSON file namedcompile_commands.json and places it under thebuild folder. This file is used by many IDEs and text editors for providing code completion (viaclangd).
A small caveat is that these tools will look forcompile_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
Please see theCONTRIBUTING.md. For security bugs and vulnerabilities, please seeSECURITY.md.
Valkey a Series of LF Projects, LLC2810 N Church St, PMB 57274Wilmington, Delaware 19802-4447
About
A flexible distributed key-value database that is optimized for caching and other realtime workloads.
Topics
Resources
License
Code of conduct
Contributing
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.