首页 > 技术文章 > 一、redis单例安装(linux)

yclh 2021-05-07 19:30 原文

系列导航

一、redis单例安装(linux)

二、redis主从环境搭建

三、redis集群搭建

四、redis增加密码验证

五、java操作redis

 

环境:centos7.5
需要的安装包: redis-4.0.10.tar.gz

安装步骤
1、安装包解压
拷贝redis-4.0.10.tar.gz 到/opt目录下
cd /opt
tar -xzvf redis-4.0.10.tar.gz

2、编译
[root]# cd  /opt/redis-4.0.10
[root]# make


注:contos7.9编译时会报错 /bin/sh: cc: command not found
解决:yum -y install gcc gcc-c++ libstdc++-devel

3、启动redis
 
[root@minio4 redis-4.0.10]# /opt/redis-4.0.10/src/redis-server  /opt/redis-4.0.10/redis.conf
注:启动后当前界面不能退出,退出服务就停了

nohup /opt/redis-4.0.10/src/redis-server  /opt/redis-4.0.10/redis.conf & 这样就是后台启动,启动后退出当前页面服务不会停止。

启动成功后如下所示
187320:C 07 May 19:16:21.702 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
187320:C 07 May 19:16:21.702 # Redis version=4.0.10, bits=64, commit=00000000, modified=0, pid=187320, just started
187320:C 07 May 19:16:21.702 # Configuration loaded
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 4.0.10 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 187320
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

187320:M 07 May 19:16:21.706 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
187320:M 07 May 19:16:21.707 # Server initialized
187320:M 07 May 19:16:21.707 # 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.
187320:M 07 May 19:16:21.707 # 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.
187320:M 07 May 19:16:21.707 * Ready to accept connections


4、启动客户端
[root@minio4 src]# cd /opt/redis-4.0.10/src
[root@minio4 src]# ./redis-cli
127.0.0.1:6379>

5、退出客户端
127.0.0.1:6379> exit

6、关闭服务端
[root@minio4 src]# cd /opt/redis-4.0.10/src
[root@minio4 src]# ./redis-cli -p 6379 shutdown

                                                    

推荐阅读