在CentOs7上yum安装redis
在开始安装步骤之前,先把我的CentOs和redis版本号列出来:
| # | 系统/软件 | 版本号 |
| 1 |
CentOS7 |
CentOS Linux release 7.2.1511 (Core) |
| 2 | redis | redis.x86_64 0:3.2.12-2.el7 |
然后确保系统能上网,在我的操作系统下可以这样做:到Gnome图形桌面状态,点右上角的开关按钮,将PCI Ethernet选择为connect状态。
别看下面貌似有大段文字和许多步骤,其实真要操作的不多,蓝字才是关键。
第一步:进行yum安装redis
[root@localhost ~]# yum install redis
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.huaweicloud.com
* extras: mirrors.huaweicloud.com
* updates: mirrors.neusoft.edu.cn
No package redis available.
Error: Nothing to do
看到Nothing to do不要紧,只要先安装epel-release就好了。
root@localhost ~]# yum install epel-release
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.huaweicloud.com
* extras: mirrors.huaweicloud.com
* updates: mirrors.neusoft.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:7-11 will be installed
--> Finished Dependency Resolution Dependencies Resolved =======================================================================================
Package Arch Version Repository Size
=======================================================================================
Installing:
epel-release noarch 7-11 extras 15 k Transaction Summary
=======================================================================================
Install 1 Package Total download size: 15 k
Installed size: 24 k
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/extras/packages/epel-release-7-11.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for epel-release-7-11.noarch.rpm is not installed
epel-release-7-11.noarch.rpm | 15 kB 00:00:00
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
Package : centos-release-7-2.1511.el7.centos.2.10.x86_64 (@anaconda)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : epel-release-7-11.noarch 1/1
Verifying : epel-release-7-11.noarch 1/1 Installed:
epel-release.noarch 0:7-11 Complete!
看在Complete之后,再安装redis
[root@localhost ~]# yum install redis
Loaded plugins: fastestmirror, langpacks
epel/x86_64/metalink | 9.0 kB 00:00:00
epel | 5.3 kB 00:00:00
(1/3): epel/x86_64/group_gz | 90 kB 00:00:00
(2/3): epel/x86_64/updateinfo | 1.0 MB 00:00:04
(3/3): epel/x86_64/primary_db | 6.9 MB 00:00:05
Loading mirror speeds from cached hostfile
* base: mirrors.huaweicloud.com
* epel: mirrors.yun-idc.com
* extras: mirrors.huaweicloud.com
* updates: mirrors.neusoft.edu.cn
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 epel 105 k Transaction Summary
=======================================================================================
Install 1 Package (+1 Dependent package) Total download size: 648 k
Installed size: 1.7 M
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/epel/packages/redis-3.2.12-2.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
Public key for redis-3.2.12-2.el7.x86_64.rpm is not installed
(1/2): redis-3.2.12-2.el7.x86_64.rpm | 544 kB 00:00:01
(2/2): jemalloc-3.6.0-1.el7.x86_64.rpm | 105 kB 00:00:03
---------------------------------------------------------------------------------------
Total 176 kB/s | 648 kB 00:03
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Importing GPG key 0x352C64E5:
Userid : "Fedora EPEL (7) <epel@fedoraproject.org>"
Fingerprint: 91e9 7d7c 4a5e 96f1 7f3e 888f 6a2f aea2 352c 64e5
Package : epel-release-7-11.noarch (@extras)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Is this ok [y/N]: y
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!
[root@localhost ~]#
到了这,redis就装好了。
第二步:启动和关闭redis
装好后,可以用以下方式启动redis
[root@localhost ~]# systemctl start redis.service
按以下方式关闭redis
[root@localhost ~]# systemctl stop redis.service
按以下方式查看redis状态:
[root@localhost ~]# systemctl status redis.service
● redis.service - Redis persistent key-value database
Loaded: loaded (/usr/lib/systemd/system/redis.service; disabled; vendor preset: disabled)
Drop-In: /etc/systemd/system/redis.service.d
└─limit.conf
Active: inactive (dead) Jan 17 23:20:10 localhost.localdomain systemd[]: Starting Redis persistent key-val....
Jan 17 23:20:10 localhost.localdomain systemd[]: Started Redis persistent key-valu....
Jan 17 23:20:57 localhost.localdomain systemd[]: Started Redis persistent key-valu....
Jan 17 23:21:12 localhost.localdomain systemd[]: Stopping Redis persistent key-val....
Jan 17 23:21:13 localhost.localdomain systemd[]: Stopped Redis persistent key-valu....
Hint: Some lines were ellipsized, use -l to show in full.
执行以下命令让redis开机启动:
[root@localhost ~]# systemctl enable redis
Created symlink from /etc/systemd/system/multi-user.target.wants/redis.service to /usr/lib/systemd/system/redis.service.
然后开放端口和重启防火墙:
[root@localhost ~]# firewall-cmd --zone=public --add-port=80/tcp --permanent
success
[root@localhost ~]# firewall-cmd --zone=public --add-port=6379/tcp --permanent
success
[root@localhost ~]# systemctl restart firewalld
第三步:配置redis.conf
redis的配置文件放在了/etc下,使用vi来编辑它:
[root@localhost etc]# pwd
/etc
[root@localhost etc]# ls r*.conf
radvd.conf redis-sentinel.conf resolv.conf rsyslog.conf
redis.conf request-key.conf rsyncd.conf
用vi打开redis.conf,进行以下三项更改:
#bind 127.0.0.1 # 这里要注释掉,否则只有本机能访问
protected-mode no # 这里由yes改为no
requirepass 123456 # 这里设置上密码
改完后再重启下服务:
[root@localhost etc]# systemctl restart redis.service
然后用Redis-cli去探探:
[root@localhost etc]# redis-cli -h 127.0.0.1 -p 6379
127.0.0.1:6379> info
NOAUTH Authentication required.
127.0.0.1:6379> auth 123456
OK
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-327.el7.x86_64 x86_64
arch_bits:64
multiplexing_api:epoll
gcc_version:4.8.5
process_id:18025
run_id:3e1f70a2a356d5d1f71c7de12ea4122cd29f7755
tcp_port:6379
uptime_in_seconds:78
uptime_in_days:0
hz:10
lru_clock:2263691
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:813440
used_memory_human:794.38K
used_memory_rss:2527232
used_memory_rss_human:2.41M
used_memory_peak:813440
used_memory_peak_human:794.38K
total_system_memory:1025363968
total_system_memory_human:977.86M
used_memory_lua:37888
used_memory_lua_human:37.00K
maxmemory:0
maxmemory_human:0B
maxmemory_policy:noeviction
mem_fragmentation_ratio:3.11
mem_allocator:jemalloc-3.6.0 # Persistence
loading:0
rdb_changes_since_last_save:0
rdb_bgsave_in_progress:0
rdb_last_save_time:1579321917
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:71
total_net_output_bytes:73
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.11
used_cpu_user:0.03
used_cpu_sys_children:0.00
used_cpu_user_children:0.00 # Cluster
cluster_enabled:0 # Keyspace
127.0.0.1:6379> set name ufo
OK
127.0.0.1:6379> get name
"ufo"
127.0.0.1:6379>
到这里,redis就安装配置完毕了。
将再次完整操作记录粘贴如下,上面全操作成功的同学可以忽略:
[hy@localhost ~]$ su - root
Password:
[root@localhost ~]# pwd
/root
[root@localhost ~]# yum install epel-release
Loaded plugins: fastestmirror, langpacks
base | 3.6 kB 00:00
extras | 2.9 kB 00:00
updates | 2.9 kB 00:00
(1/4): base/7/x86_64/group_gz | 165 kB 00:00
(2/4): extras/7/x86_64/primary_db | 153 kB 00:01
(3/4): updates/7/x86_64/primary_db | 5.9 MB 00:04
(4/4): base/7/x86_64/primary_db | 6.0 MB 00:30
Determining fastest mirrors
* base: ap.stykers.moe
* extras: ap.stykers.moe
* updates: mirror.lzu.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:7-11 will be installed
--> Finished Dependency Resolution Dependencies Resolved ================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
epel-release noarch 7-11 extras 15 k Transaction Summary
================================================================================
Install 1 Package Total download size: 15 k
Installed size: 24 k
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/extras/packages/epel-release-7-11.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for epel-release-7-11.noarch.rpm is not installed
epel-release-7-11.noarch.rpm | 15 kB 00:00
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
Package : centos-release-7-2.1511.el7.centos.2.10.x86_64 (@anaconda)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : epel-release-7-11.noarch 1/1
Verifying : epel-release-7-11.noarch 1/1 Installed:
epel-release.noarch 0:7-11 Complete!
[root@localhost ~]# yum install redis
Loaded plugins: fastestmirror, langpacks
epel/x86_64/metalink | 9.4 kB 00:00
epel | 5.3 kB 00:00
(1/3): epel/x86_64/group_gz | 90 kB 00:00
(2/3): epel/x86_64/primary_db | 6.9 MB 00:02
(3/3): epel/x86_64/updateinfo | 1.0 MB 00:03
Loading mirror speeds from cached hostfile
* base: ap.stykers.moe
* epel: mirrors.yun-idc.com
* extras: ap.stykers.moe
* updates: mirror.lzu.edu.cn
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 epel 105 k Transaction Summary
================================================================================
Install 1 Package (+1 Dependent package) Total download size: 648 k
Installed size: 1.7 M
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/epel/packages/redis-3.2.12-2.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
Public key for redis-3.2.12-2.el7.x86_64.rpm is not installed
(1/2): redis-3.2.12-2.el7.x86_64.rpm | 544 kB 00:01
(2/2): jemalloc-3.6.0-1.el7.x86_64.rpm | 105 kB 00:02
--------------------------------------------------------------------------------
Total 211 kB/s | 648 kB 00:03
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Importing GPG key 0x352C64E5:
Userid : "Fedora EPEL (7) <epel@fedoraproject.org>"
Fingerprint: 91e9 7d7c 4a5e 96f1 7f3e 888f 6a2f aea2 352c 64e5
Package : epel-release-7-11.noarch (@extras)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Is this ok [y/N]: y
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!
[root@localhost ~]# systemctl start redis.service
[root@localhost ~]# systemctl stop redis.service
[root@localhost ~]# systemctl status redis.service
● redis.service - Redis persistent key-value database
Loaded: loaded (/usr/lib/systemd/system/redis.service; disabled; vendor preset: disabled)
Drop-In: /etc/systemd/system/redis.service.d
└─limit.conf
Active: inactive (dead) Jan 18 01:12:30 localhost.localdomain systemd[]: Starting Redis persistent k...
Jan 18 01:12:30 localhost.localdomain systemd[]: Started Redis persistent ke...
Jan 18 01:12:39 localhost.localdomain systemd[]: Stopping Redis persistent k...
Jan 18 01:12:40 localhost.localdomain systemd[]: Stopped Redis persistent ke...
Hint: Some lines were ellipsized, use -l to show in full.
[root@localhost ~]# systemctl enable redis
Created symlink from /etc/systemd/system/multi-user.target.wants/redis.service to /usr/lib/systemd/system/redis.service.
[root@localhost ~]# firewall-cmd --zone=public --add-port=80/tcp --permanent
success
[root@localhost ~]# firewall-cmd --zone=public --add-port=6379/tcp --permanent
success
[root@localhost ~]# systemctl restart firewalld
[root@localhost ~]# cd etc
-bash: cd: etc: No such file or directory
[root@localhost ~]#
[root@localhost ~]# cd /etc
[root@localhost etc]# vi redis.conf
[root@localhost etc]# systemctl restart redis.service
[root@localhost etc]# redis-cli -h 127.0.0.1 -p 6379
127.0.0.1:6379> auth 123456
OK
127.0.0.1:6379> set username ufo
OK
127.0.0.1:6379> get username
"ufo"
127.0.0.1:6379> exit
参考资料:https://www.cnblogs.com/hjw-zq/p/9778514.html
--END-- 2020年1月18日13点23分
在CentOs7上yum安装redis的更多相关文章
- Centos7上yum安装redis
下载tar包 wget http://download.redis.io/releases/redis-6.0.5.tar.gz 解压tar包 tar -zxvf redis-6.0.5.tar.gz ...
- CentOS7下yum安装Redis
(1).Redis概述 Redis是一个开源的使用ANSI C语言编写.支持网络.可基于内存亦可持久化的日志型.Key-Value(键值型)数据库(非关系型数据库),并提供多种语言的API. Redi ...
- CentOS7使用yum安装redis
#下载fedora的epel仓库yum install epel-release #安装redis数据库yum install redis # 启动Redisservice redis start # ...
- CentOS7下Yum安装Redis并配置主从
原文 :https://blog.51cto.com/11134648/2158209 Redis简介: Redis 是完全开源免费的,遵守BSD协议,是一个高性能的key-value数据库.它通常被 ...
- Centos7上yum安装mongodb4-2
vim /etc/yum.repos.d/mongodb-org-4.2.repo [mongodb-org-4.2] name=MongoDB Repository baseurl=https:// ...
- Centos7上yum安装mongodb(安装epel中的版本可能会比较老)
yum install epel-release 搜索mongodb-server 安装mongodb yum install mongodb-server.x86_64 配置mongodb vim ...
- centos7下使用yum安装redis
centos7下使用yum安装Redis 第一步:安装 yum –y install redis 第二步:启动 systemctl start redis.service 第三步:设置开机启动 sys ...
- centos7 yum安装redis(转)
正如我们所知的那样,Redis是一个开源的.基于BSD许可证的,基于内存的.键值存储NoSQL数据库.Redis经常被视为一个数据结构服务器,因为Redis支持字符串strings.哈希hashes. ...
- centos7 yum安装redis及常用命令
redis是什么 Redis是一种基于内存的数据结构存储,可持久化的日志型.Key-Value数据库.使用关系型数据库的站点达到一定并发量的时候,往往在磁盘IO上会有瓶颈,这时候配合redis就有一定 ...
随机推荐
- 11、Java 日期时间 日期工具类
一.简介 在Java8之前,日期时间API一直被开发者诟病,包括:java.util.Date是可变类型,SimpleDateFormat非线程安全等问题.故此,Java8引入了一套全新的日期时间处理 ...
- 盘点 35 个 Apache 顶级项目,我拜服了…
Apache 软件基金会 Apache 软件基金会,全称:Apache Software Foundation,简称:ASF,成立于 1999 年 7 月,是目前世界上最大的最受欢迎的开源软件基金会, ...
- C#LeetCode刷题之#13-罗马数字转整数(Roman to Integer)
问题 该文章的最新版本已迁移至个人博客[比特飞],单击链接 https://www.byteflying.com/archives/3842 访问. 罗马数字包含以下七种字符: I, V, X, L, ...
- Flutter 容器(7) - DecoratedBox
DecoratedBox: 装饰容器,在其子widget绘制前(或后)绘制一个装饰Decoration(如背景.边框.渐变等) import 'package:flutter/material.dar ...
- Vue Vuex 严格模式+实例解析+dispatch/commit + state/getter
1.严格模式 import getters from './getters' import mutations from './mutations' import actions from './ac ...
- 使用 VMware Workstation Pro让 PC 提供云桌面服务——学习笔记(三)
目标 当在前面两篇博客后,我们已经创建了一个能当服务器的虚拟机,这时我们需要通过复制虚拟机来让创建更多虚拟机 操作步骤 1.创建克隆 这里主要是VMware软件的操作 虚拟机->管理->克 ...
- 运用cookie实现记住密码自动登陆:
苦命的程序员:只有博客才能了解我的路!!! 废话不多说:直接上代码: 1.首先在现在登录的页面上来获取cookie的所有: 2.在验证页面来设置clookie的用户名和密码还有是否是自动登录: 到此就 ...
- 题解 SGU294 He's Circles
题目描述 失踪人口回归 根据\(Polya\)定理$$ans=\frac 1n \sum\limits_{i=1}^n2^{gcd(i, n)}$$ 考虑枚举\(gcd\),原式变成$$\frac 1 ...
- 手把手教你在win10下搭建pytorch GPU环境(Anaconda+Pycharm)
Anaconda指的是一个开源的Python发行版本,其主要优点如下: Anaconda默认安装了常见的科学计算包,用它搭建起Python环境后不用再费时费力安装这些包: Anaconda可以创建互相 ...
- 本blog的地图
欢迎 CTRL+F收索 / CTRL+D 持续更新 C++: C++快速排序 C++归并排序 高精度 CSS: CSS实现ps基础操作 PYTHON: python爬虫教程,一篇就够了 其他推荐 ...