Redis(REmote DIctionary Server)基础
Redis是一个开放源代码(BSD许可)的内存数据结构存储,用作数据库、缓存和消息代理。它支持字符串、哈希、列表、集合、带范围查询的排序集合、位图、超日志、带半径查询和流的地理空间索引等数据结构。Redis具有内置的复制、Lua脚本、LRU收回、事务和不同级别的磁盘上持久性,并通过Redis Sentinel和Redis群集的自动分区提供高可用性。官方地址:https://redis.io/
在生产环境中Redis一般有三种用途,可以用作数据库(Database),缓存(Cache),消息队列(Message Queue)。因此不关你是开发还是运维人员,学习一下Redis还是很有必要的!
一.安装Redis
1.本篇博客操作环境介绍
[[email protected] ~]#
[[email protected] ~]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
[[email protected] ~]#
[[email protected] ~]# uname -r
3.10.0-957.el7.x86_64
[[email protected] ~]#
[[email protected] ~]# uname -m
x86_64
[[email protected] ~]#
[[email protected] ~]#
2.安装epel源
安装epel源
[[email protected] ~]# ll /etc/yum.repos.d/ #安装epel源之前
total 4
drwxr-xr-x. 2 root root 30 Mar 23 22:29 back
-rw-r--r--. 1 root root 2523 Mar 23 22:26 CentOS-Base.repo
drwxr-xr-x. 2 root root 187 Mar 23 22:26 default
[[email protected] ~]#
[[email protected] ~]# yum -y install epel-release
[[email protected] ~]# ll /etc/yum.repos.d/ #安装epel源之后,会生成2个文件
total 12
drwxr-xr-x. 2 root root 30 Mar 23 22:29 back
-rw-r--r--. 1 root root 2523 Mar 23 22:26 CentOS-Base.repo
drwxr-xr-x. 2 root root 187 Mar 23 22:26 default
-rw-r--r-- 1 root root 951 Oct 2 2017 epel.repo
-rw-r--r-- 1 root root 1050 Oct 2 2017 epel-testing.repo
[[email protected] ~]#
3.利用epel源安装Redis服务
yum info redis #查看Redis安装包的相应信息
[[email protected] ~]#
[[email protected] ~]# yum info redis
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
epel/x86_64/metalink | 5.8 kB 00:00:00
* base: mirrors.aliyun.com
* epel: mirrors.yun-idc.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
epel | 4.7 kB 00:00:00
(1/3): epel/x86_64/group_gz | 88 kB 00:00:00
epel/x86_64/updateinfo FAILED
https://mirrors.tuna.tsinghua.edu.cn/epel/7/x86_64/repodata/27797f54681404f3261395d766df370206f7d92cd3e1551a698663a6317d5c5a-updateinfo.xml.bz2: [Errno 14] HTTPS Error 404 - Not Found
Trying other mirror.
To address this issue please refer to the below wiki article
https://wiki.centos.org/yum-errors
If above article doesn't help to resolve this issue please use https://bugs.centos.org/.
(2/3): epel/x86_64/updateinfo | 1.0 MB 00:00:00
(3/3): epel/x86_64/primary_db | 6.6 MB 00:00:06
Available Packages
Name : redis
Arch : x86_64
Version : 3.2.12
Release : 2.el7
Size : 544 k
Repo : epel/x86_64
Summary : A persistent key-value database
URL : http://redis.io
License : BSD
Description : Redis is an advanced key-value store. It is often referred to as a data
: structure server since keys can contain strings, hashes, lists, sets and
: sorted sets.
:
: You can run atomic operations on these types, like appending to a string;
: incrementing the value in a hash; pushing to a list; computing set
: intersection, union and difference; or getting the member with highest
: ranking in a sorted set.
:
: In order to achieve its outstanding performance, Redis works with an
: in-memory dataset. Depending on your use case, you can persist it either
: by dumping the dataset to disk every once in a while, or by appending
: each command to a log.
:
: Redis also supports trivial-to-setup master-slave replication, with very
: fast non-blocking first synchronization, auto-reconnection on net split
: and so forth.
:
: Other features include Transactions, Pub/Sub, Lua scripting, Keys with a
: limited time-to-live, and configuration settings to make Redis behave like
: a cache.
:
: You can use Redis from most programming languages also.
[[email protected] ~]#