美文网首页
Linux安装Redis

Linux安装Redis

作者: 程序员小杰 | 来源:发表于2020-07-10 19:45 被阅读0次

一、准备好 gcc 环境。

yum install gcc-c++

Loaded plugins: fastestmirror
Determining fastest mirrors
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     
nginx                                                                                                                       | 2.9 kB  00:00:00     
updates                                                                                                                     | 2.9 kB  00:00:00     
(1/7): epel/x86_64/group_gz                                                                                                 |  95 kB  00:00:00     
(2/7): epel/x86_64/updateinfo                                                                                               | 1.0 MB  00:00:00     
(3/7): docker-ce-stable/x86_64/primary_db                                                                                   |  45 kB  00:00:00     
(4/7): extras/7/x86_64/primary_db                                                                                           | 205 kB  00:00:00     
(5/7): updates/7/x86_64/primary_db                                                                                          | 3.0 MB  00:00:00     
(6/7): epel/x86_64/primary_db                                                                                               | 6.8 MB  00:00:00     
(7/7): nginx/x86_64/primary_db                                                                                              |  55 kB  00:00:02     
Package gcc-c++-4.8.5-39.el7.x86_64 already installed and latest version
Nothing to do
[root@root ~]# 

二、下载并安装

[root@root /]# cd usr/java
[root@root java]# mkdir redis
[root@root java]# cd redis/
[root@root redis]# wget http://download.redis.io/releases/redis-5.0.7.tar.gz
[root@root redis]# tar -zxvf redis-5.0.7.tar.gz
 [root@root redis]# cd redis-5.0.7
[root@root redis-5.0.7]# make
[root@root redis-5.0.7]# make install

三、启动

[root@root redis-5.0.7]# redis-server redis.conf 
12513:C 10 Jul 2020 19:38:14.179 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
12513:C 10 Jul 2020 19:38:14.179 # Redis version=5.0.7, bits=64, commit=00000000, modified=0, pid=12513, just started
12513:C 10 Jul 2020 19:38:14.179 # Configuration loaded
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 5.0.7 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 12513
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

12513:M 10 Jul 2020 19:38:14.181 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
12513:M 10 Jul 2020 19:38:14.181 # Server initialized
12513:M 10 Jul 2020 19:38:14.181 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
12513:M 10 Jul 2020 19:38:14.181 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
12513:M 10 Jul 2020 19:38:14.181 * Ready to accept connections

但是这样没有办法在这个tab页下做任何操作了,因为这个时候使用Ctrl+c之后,就变成了这个样子


^C13082:signal-handler (1594381754) Received SIGINT scheduling shutdown...
13082:M 10 Jul 2020 19:49:14.132 # User requested shutdown...
13082:M 10 Jul 2020 19:49:14.132 * Saving the final RDB snapshot before exiting.
13082:M 10 Jul 2020 19:49:14.135 * DB saved on disk
13082:M 10 Jul 2020 19:49:14.135 * Removing the pid file.
13082:M 10 Jul 2020 19:49:14.135 # Redis is now ready to exit, bye bye...

四、后台启动

[root@root redis-5.0.7]# vim redis.conf 
#打开之后,在命令窗口按下/输入daem然后回车/daem

image.png

修改为yes

daemonize yes

再次启动

[root@root redis-5.0.7]# redis-server redis.conf 
13352:C 10 Jul 2020 19:54:34.301 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
13352:C 10 Jul 2020 19:54:34.301 # Redis version=5.0.7, bits=64, commit=00000000, modified=0, pid=13352, just started
13352:C 10 Jul 2020 19:54:34.301 # Configuration loaded

五、连接Redis

[root@root redis-5.0.7]# redis-cli 
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> config get requirepass
#查看密码
1) "requirepass"
2) ""
127.0.0.1:6379> 

我们发现竟然不需要密码就可以进入redis。那怎么设置呢?
1、临时设置

config set requirepass 123456

2、永久设置

[root@root redis-5.0.7]# vim redis.conf 
image.png
image.png

记住永久设置需要重启redis。

[root@root redis-5.0.7]# redis-server redis.conf 
[root@root redis-5.0.7]# redis-cli 
127.0.0.1:6379> ping
(error) NOAUTH Authentication required.
127.0.0.1:6379> auth xxx
OK
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> 

可以看到第一次ping的时候提示我需要身份验证。auth xxx这是连接后输入密码。也可以在连接的时候输入:

[root@root redis-5.0.7]# redis-cli -p 6379 -a xxx

在线体验:https://try.redis.io/
以上所以只是均来自于大佬江南一点雨
个人博客:http://www.javaboy.org/

相关文章

  • 记一次搭建生产服务器

    Linux JDK 安装 Linux Maven 安装 Linux node 安装 Linux redis安装 L...

  • linux redis 安装及基本配置

    每次 linux redis安装,都要百度,索性将 linux redis 源码安装及配置记下,含 redis ...

  • Linux 安装

    Linux下安装mysql CentOS7.x系统安装Redis6.0.1 Linux安装redis和部署 Red...

  • redis

    linux安装redis

  • redis操作小结

    安装redis(windows、Linux、Ubuntu和Mac):Redis 安装 redis的启动、连接、停止...

  • linux下安装redis

    linux下的redis安装 1.首先将redis安装包下载到linux系统 redis官网https://red...

  • linux redis

    linux 安装redis wget http://download.redis.io/redis-stable....

  • 六. Redis集群

    一. Linux中Redis的安装 Linux版Redis的下载地址为:https://redis.io/down...

  • redis 生产环境安装

    redis 生产环境安装 linux 安装redis need tcl 8.5 or newer wget htt...

  • 【5】安装redis

    安装 下载Linux安装包,解压 进入redis目录 cd redis 编译redis,直接敲 make 回车 编...

网友评论

      本文标题:Linux安装Redis

      本文链接:https://www.haomeiwen.com/subject/hqxvcktx.html