Redis is an open source project providing key/value store features in a database server. This means that basically you can store in the database a value that has a given key and then retrieve the value using its key. It supports advanced data types like strings, lists (elements sorted by insertion order), sets (unordered collection of elements) and sorted sets (collection of elements ordered by a key given by user). There are also other things supported like hashes or atomic integer incrementation. Feel free to have a look at the documentation about that.
This post will not deal with advanced aspects of Redis: this will be the subject of other articles. What is going to be described here is how to get Redis, run a server and then perform some simple operations.
Redis is honestly a famous project (5,000 followers on Github), so I am sure you will be able to install it easily whatever your environment. For example, in the case of Archlinux, you only need to use a simple pacman command.
pacman -S redis
For CentOS:
yum install redis
But you honestly feel more what you do if you compile and install the code yourself from Github for example. So let's get the code.
mkdir $REDIS_CODE
cd $REDIS_CODE
git init
git remote add origin https://github.com/antirez/redis.git
git fetch origin
git checkout unstable
The unstable branch is the main development branch, similar to master in the case of postgresql. You can refer to other branches for stable releases like 2.6 or 2.8.
The server code is located in folder src/, but you first need to compile the dependencies or you will get errors of the following type:
$ make
clang: error: no such file or directory: '../deps/hiredis/libhiredis.a'
clang: error: no such file or directory: '../deps/lua/src/liblua.a'
make[1]: *** [redis-server] Error 1
make: *** [all] Error 2
So here be sure to install first the dependencies as below.
cd deps
make lua hiredis linenoise
Then finalize compilation.
cd $REDIS_CODE/src
make
Finally install the binaries in a wanted folder.
make PREFIX=$REDIS_INSTALL install
Once installed, you will notice several binaries but the most important ones are redis-server (used to boot a server) and redis-cli (client to connect to a server).
In order to launch a server on default port 6379, simply launch this command, assuming that $REDIS_INSTALL is included in PATH:
redis-server
A Redis server can use a configuration file when booted, which can be specified like this:
redis-server /path/to/conf/redis.conf
There is also a template of redis.conf in the root tree of source code.
All the options of redis.conf can be specified via command line, here are some of them I find pretty useful for beginners.
- --dir $DIR, to specify the directory where database dump file or log files are written to. The default value is "./", so all the files are written in this case in the folder where redis-server is launched. I personally find that not really intuitive but...
- --port $PORT_NUMBER, port number where server listens to. Default is 6379.
- --logfile, name of file where logs are written. Default is stdout. Once again here I recommend using a clear file name combined with --dir to bring clarity to your database servers.
Then, in order to connect to the server, simply use redis-cli (see redis-cli --help for details about the options).
$ redis-cli
redis 127.0.0.1:6379>
Then you are ready to operate on your server. Let's do here a simple get/set.
redis 127.0.0.1:6379> set foo bar
OK
redis 127.0.0.1:6379> get foo
"bar"
A last thing, I quickly wrote two scripts in case you are interested:
- redis_compile, script that can be used to compile code, perform tests and do some other tricks
- redis_start, script that can be used to set up a Redis cluster with master and slaves
Please note that those scripts do not have the granularity necessary for a use in production and they are only dedicated to development.
I have not yet discussed about the numerous features of Redis like things related to the cluster structure (master/slave replication, memory management), or data structures (lists, sets), but they will be covered in some future posts.
相关推荐
linux上安装的redis
redis 3.0.6版本,免安装版本,解压就可以使用! REmote DIctionary Server(Redis) 是一个由Salvatore Sanfilippo写的key-value存储系统。 Redis是一个开源的使用ANSI C语言编写、遵守BSD协议、支持网络、可基于内存...
在本文中,我们将深入探讨Redis 3.0.6版本在Linux系统(包括CentOS 6.5和7)上的安装、配置和集群搭建。 首先,我们来看Redis 3.0.6的发布。这个版本包含了对先前版本的优化和一些新特性,如更高效的内存管理,以及...
银行麒麟、统信UOS,arm64架构下的redis deb 安装包,redis3.0.6.rpm 飞腾鲲鹏都可以用的redis
redis安装包redis
redis-3.0.6.gem集群搭建
安装依赖 [root@centos7-1 ~]# yum -y install gcc openssl-...安装 redis [root@centos7-1 ~]# wget http://download.redis.io/releases/redis-3.0.6.tar.gz [root@centos7-1 ~]# tar xvf redis-3.0.6.tar.gz [r
银行麒麟、统信UOS,mips64架构下的redis rpm安装包,redis3.0.6.rpm 龙芯可以用的redis
Redis-3.0.6和Redis-4.0.10是两个不同版本的Redis源码包,它们分别代表了Redis在不同时间点的稳定版本。在本篇文章中,我们将深入探讨这两个版本的Redis,以及如何从提供的压缩包文件中进行安装。 Redis-3.0.6是...
在本文档中,我们将详细介绍如何在CentOS 6.6和7.3上安装Redis 3.0.6。Redis是一个开源的、基于内存的数据结构存储系统,常被用作数据库、缓存和消息中间件。以下是安装和配置Redis 3.0.6的步骤: 1. **下载Redis...
Redis-3.0.6是Redis的一个稳定版本,它提供了丰富的数据结构,如字符串、哈希表、列表、集合和有序集合。这些数据结构为开发人员提供了灵活的数据操作方式,使得Redis适用于各种复杂的应用场景。 在Redis-3.0.6中,...
Redis 3.0.6版本引入了集群支持,这是一个重要的里程碑,使得Redis能够处理更大规模的数据和更高的并发请求。 **一、CentOS安装Redis** 1. **添加EPEL仓库**:由于Redis可能不在默认的CentOS仓库中,我们需要先...
### CentOS 6.6安装Redis 3.0教程详解 #### 一、前言 本文旨在详细介绍如何在CentOS 6.6上安装并配置Redis 3.0,包括从下载到安装再到设置开机自启的全过程。Redis是一款开源的高性能键值存储系统,它支持多种数据...
注path为解压后的安装包路径 /root/gsj/redis-3.0.6 8: 让redis以后台进程的形式运行 vim /usr/local/redis/redis.conf 编辑redis.conf配置文件,修改如下内容; daemonize yes 9: make install之后,cd /usr/...
redis集群部署所需的依赖包 redis-4.0.1.gem redis-4.0.11.tar.gz ruby-2.5.1.tar.gz rubygems-2.6.12.zip redis-2.10.6-py2.py3-none-any.whl redis-3.0.1-py2.py3-none-any.whl redis-py-cluster-1.3.5.tar....
本文将深入探讨`jredis`,一个Java客户端库,用于与Redis 3.0.6服务器进行交互。Redis是一种高性能的键值存储系统,广泛用于数据缓存、消息队列和数据库持久化等多个场景。`jredis`作为Java开发者与Redis通信的桥梁...
要使用 Redis,首先需要安装 Redis。可以通过 wget 命令下载 Redis 的源代码,然后编译和安装。 wget http://download.redis.io/releases/redis-3.0.6.tar.gz tar xzf redis-3.0.6.tar.gz cd redis-3.0.6 make ...