Redis¶
Redis is an open source (BSD licensed), in-memory data structure store, used as a database, cache and message broker.
Installation¶
Linux¶
Install Redis with yum install redis
or from source code as follows:
- Download Redis here.
- Upload to the VM.
- Unzip the file:
tar –zxvf redis-x.x.x.tar.gz
- Open the unzipped directory and compile Redis with
make
, .c files compiled to .o files. Install gcc withyum install gcc-c++
if gcc is unavailable. - Install Redis to target directory with
make install PREFIX=/usr/local/redis
. Several executable files are available now under the target directory, such as redis-cli, redis-server. - Copy redis.conf to the installation directory. Modify relative configurations if necessary.
- Execute redis-server directly to start Redis server in the front. Then execute redis-cli to connect to the server.
- Configure
daemonize yes
in the redis.conf and start the server with the specified configuration file, so the server can run in the background.
Start Redis at startup with systemctl enable redis
.
Windows¶
The Microsoft Open Tech group instead of the official offer Redis for Windows. Follow the instructions to install Redis and then set Redis as Windows service.
Notes¶
Set different configuration files, service names and ports for different instances of Redis if needed.
Modify bind 127.0.0.1
when connecting remotely, otherwise the server can't be accessed to except localhost. Open the port that may be forbidden by firewall when remote connection is refused.
Connecting through SSH is also optional.
Configuration¶
Configure options in the redis.conf file.
- bind [host1] [host2]
- requirepass [password]