Linux系统之使用yum安装Redis数据库

本文涉及的产品
云数据库 Redis 版,社区版 2GB
推荐场景:
搭建游戏排行榜
简介: Linux系统之使用yum安装Redis数据库

一、检查系统版本

[root@server ~]# cat /etc/os-release 
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

二、检查yum仓库状态

[root@server ~]# yum repolist all |grep  enable
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
!appnode/x86_64                      AppNode's RPM repository fo enabled:  4,266
!appnode-agent/x86_64                AppNode Agent Repository -  enabled:    332
!appnode-ccenter/x86_64              AppNode CCenter Repository  enabled:     71
!appnode-extras/x86_64               AppNode Extras Repository - enabled:     88
!base/7/x86_64                       CentOS-7 - Base - mirrors.a enabled: 10,072
!docker-ce-stable/7/x86_64           Docker CE Stable - x86_64   enabled:    169
!epel/x86_64                         Extra Packages for Enterpri enabled: 13,735
!extras/7/x86_64                     CentOS-7 - Extras - mirrors enabled:    515
!updates/7/x86_64                    CentOS-7 - Updates - mirror enabled:  4,300

三、查看系统默认提供的redis版本

[root@server ~]# yum info redis
Loaded plugins: fastestmirror
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
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.

四、安装redis

1.安装redis

[root@server ~]# yum install -y redis
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
appnode                                                                                                                     | 3.0 kB  00:00:00     
appnode-agent                                                                                                               | 2.9 kB  00:00:00     
appnode-ccenter                                                                                                             | 2.9 kB  00:00:00     
appnode-extras                                                                                                              | 2.9 kB  00:00:00     
base                                                                                                                        | 3.6 kB  00:00:00     
docker-ce-stable                                                                                                            | 3.5 kB  00:00:00     
epel                                                                                                                        | 4.7 kB  00:00:00     
extras                                                                                                                      | 2.9 kB  00:00:00     
updates                                                                                                                     | 2.9 kB  00:00:00     
(1/5): epel/x86_64/group_gz                                                                                                 |  98 kB  00:00:00     
(2/5): epel/x86_64/updateinfo                                                                                               | 1.0 MB  00:00:00     
(3/5): docker-ce-stable/7/x86_64/primary_db                                                                                 |  87 kB  00:00:00     
(4/5): updates/7/x86_64/primary_db                                                                                          |  17 MB  00:00:01     
(5/5): epel/x86_64/primary_db                                                                                               | 7.0 MB  00:00:01     
Resolving Dependencies
--> Running transaction check
---> Package redis.x86_64 0:3.2.12-2.el7 will be installed
--> Processing Dependency: libjemalloc.so.1()(64bit) for package: redis-3.2.12-2.el7.x86_64
--> Running transaction check
---> Package jemalloc.x86_64 0:3.6.0-1.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===================================================================================================================================================
 Package                           Arch                            Version                                  Repository                        Size
===================================================================================================================================================
Installing:
 redis                             x86_64                          3.2.12-2.el7                             epel                             544 k
Installing for dependencies:
 jemalloc                          x86_64                          3.6.0-1.el7                              appnode                          107 k

Transaction Summary
===================================================================================================================================================
Install  1 Package (+1 Dependent package)

Total download size: 651 k
Installed size: 1.7 M
Downloading packages:
(1/2): redis-3.2.12-2.el7.x86_64.rpm                                                                                        | 544 kB  00:00:00     
(2/2): jemalloc-3.6.0-1.el7.x86_64.rpm                                                                                      | 107 kB  00:00:00     
---------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                              2.3 MB/s | 651 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : jemalloc-3.6.0-1.el7.x86_64                                                                                                     1/2 
  Installing : redis-3.2.12-2.el7.x86_64                                                                                                       2/2 
  Verifying  : redis-3.2.12-2.el7.x86_64                                                                                                       1/2 
  Verifying  : jemalloc-3.6.0-1.el7.x86_64                                                                                                     2/2 

Installed:
  redis.x86_64 0:3.2.12-2.el7                                                                                                                      

Dependency Installed:
  jemalloc.x86_64 0:3.6.0-1.el7                                                                                                                    

Complete!

2.启动redis服务

[root@server ~]# systemctl enable --now redis
Created symlink from /etc/systemd/system/multi-user.target.wants/redis.service to /usr/lib/systemd/system/redis.service.

五、连接redis

[root@server ~]# redis-cli
127.0.0.1:6379> info
# Server
redis_version:3.2.12
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:7897e7d0e13773f
redis_mode:standalone
os:Linux 3.10.0-957.el7.x86_64 x86_64
arch_bits:64
multiplexing_api:epoll
gcc_version:4.8.5
process_id:17174
run_id:0db6caf4f1e1f630fded8256fcf2d032fc9e0ad7
tcp_port:6379
uptime_in_seconds:21
uptime_in_days:0
hz:10
lru_clock:6804044
executable:/usr/bin/redis-server
config_file:/etc/redis.conf

# Clients
connected_clients:1
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0

# Memory
used_memory:813448
used_memory_human:794.38K
used_memory_rss:2523136
used_memory_rss_human:2.41M
used_memory_peak:813448
used_memory_peak_human:794.38K
total_system_memory:7968645120
total_system_memory_human:7.42G
used_memory_lua:37888
used_memory_lua_human:37.00K
maxmemory:0
maxmemory_human:0B
maxmemory_policy:noeviction
mem_fragmentation_ratio:3.10
mem_allocator:jemalloc-3.6.0

# Persistence
loading:0
rdb_changes_since_last_save:0
rdb_bgsave_in_progress:0
rdb_last_save_time:1667748407
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:-1
rdb_current_bgsave_time_sec:-1
aof_enabled:0
aof_rewrite_in_progress:0
aof_rewrite_scheduled:0
aof_last_rewrite_time_sec:-1
aof_current_rewrite_time_sec:-1
aof_last_bgrewrite_status:ok
aof_last_write_status:ok

# Stats
total_connections_received:1
total_commands_processed:1
instantaneous_ops_per_sec:0
total_net_input_bytes:31
total_net_output_bytes:9928
instantaneous_input_kbps:0.00
instantaneous_output_kbps:0.00
rejected_connections:0
sync_full:0
sync_partial_ok:0
sync_partial_err:0
expired_keys:0
evicted_keys:0
keyspace_hits:0
keyspace_misses:0
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:0
migrate_cached_sockets:0

# Replication
role:master
connected_slaves:0
master_repl_offset:0
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0

# CPU
used_cpu_sys:0.04
used_cpu_user:0.01
used_cpu_sys_children:0.00
used_cpu_user_children:0.00

# Cluster
cluster_enabled:0

# Keyspace
相关实践学习
基于Redis实现在线游戏积分排行榜
本场景将介绍如何基于Redis数据库实现在线游戏中的游戏玩家积分排行榜功能。
云数据库 Redis 版使用教程
云数据库Redis版是兼容Redis协议标准的、提供持久化的内存数据库服务,基于高可靠双机热备架构及可无缝扩展的集群架构,满足高读写性能场景及容量需弹性变配的业务需求。 产品详情:https://www.aliyun.com/product/kvstore     ------------------------------------------------------------------------- 阿里云数据库体验:数据库上云实战 开发者云会免费提供一台带自建MySQL的源数据库 ECS 实例和一台目标数据库 RDS实例。跟着指引,您可以一步步实现将ECS自建数据库迁移到目标数据库RDS。 点击下方链接,领取免费ECS&RDS资源,30分钟完成数据库上云实战!https://developer.aliyun.com/adc/scenario/51eefbd1894e42f6bb9acacadd3f9121?spm=a2c6h.13788135.J_3257954370.9.4ba85f24utseFl
相关文章
|
3天前
|
监控 Linux 数据处理
lslocks:Linux系统中的锁信息查看利器
`lslocks`是Linux工具,用于查看系统上的文件锁信息,帮助诊断进程同步问题。它显示持有锁的进程、锁类型(如POSIX、flock)和状态。通过简洁的输出,用户能识别死锁和资源争用,优化性能。结合其他命令如`grep`和`awk`可增强分析能力。需适当权限运行,定期监控以预防并发访问问题,处理死锁时要谨慎。
|
3天前
|
监控 Linux 数据处理
探索Linux中的`lsmem`命令:深入了解系统内存布局
`lsmem`是Linux命令,用于显示系统内存布局和大小,帮助管理员和开发者理解内存使用情况。它提供详细输出,包括内存块的大小、范围、类型和关联,支持多种格式展示,如树状图。命令参数如`-h`显示帮助,`-t`以树形展示,`--human-readable`使大小更易读。需root权限运行,常与`free`、`vmstat`等工具结合使用,用于监控和优化内存。注意不同发行版可能存在兼容性差异。
|
3天前
|
存储 安全 Linux
一行代码使Linux系统崩溃?
一行代码使Linux系统崩溃?
11 1
|
1天前
|
存储 NoSQL Linux
Linux下Redis简介、安装、设置、启动
Linux下Redis简介、安装、设置、启动
4 0
|
1天前
|
关系型数据库 MySQL Linux
Linux系统中Mysql5.7建立远程连接
Linux系统中Mysql5.7建立远程连接
4 0
|
2天前
|
Oracle 关系型数据库 数据库
Oracle 11G数据库安装步骤及截图操作2
Oracle 11G数据库安装步骤及截图操作
6 0
|
2天前
|
Oracle 安全 关系型数据库
Oracle 11G数据库安装步骤及截图操作1
Oracle 11G数据库安装步骤及截图操作
10 0
|
1月前
|
NoSQL Linux 网络安全
Linux安装Redis(详细教程)
Linux安装Redis(详细教程)
98 2
|
30天前
|
NoSQL Linux Redis
Redis -- 安装客户端redis-plus-plus
Redis -- 安装客户端redis-plus-plus
55 0
|
4天前
|
NoSQL Redis Windows
win10下Redis安装、启动教程
win10下Redis安装、启动教程
14 2

热门文章

最新文章