Redis ——环境安装

Posted augusduan

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Redis ——环境安装相关的知识,希望对你有一定的参考价值。

环境安装

Linux

redis下载地址

[[email protected]_0_4_centos ~]# http://download.redis.io/releases/redis-4.0.10.tar.gz
[[email protected]_0_4_centos ~]# tar xzf redis-4.0.10.tar.gz
[[email protected]_0_4_centos ~]# cd redis-4.0.10/
[[email protected]_0_4_centos redis-4.0.10]# make

我在linux安装redis的时候,因为是刚刚在腾讯云上买的服务器,所以没安装编译器,make命令报错

make[3]: gcc: Command not found
make[3]: *** [net.o] Error 127
make[3]: Leaving directory `/root/redis-4.0.10/deps/hiredis‘
make[2]: *** [hiredis] Error 2
make[2]: Leaving directory `/root/redis-4.0.10/deps‘
make[1]: [persist-settings] Error 2 (ignored)
    CC adlist.o
/bin/sh: cc: command not found
make[1]: *** [adlist.o] Error 127
make[1]: Leaving directory `/root/redis-4.0.10/src‘
make: *** [all] Error 2

解决办法就是安装编译器,在运行make即可

[[email protected]_0_4_centos ~]# yum install gcc
[[email protected]_0_4_centos ~]# yum install gcc -c++
linux 环境就安装好了
运行测试一下

进入reids目录的src目录下 启动服务 如果有reids那个大大Logo构成就代表成功了

[[email protected]_0_4_centos redis-4.0.10]#  cd src/
[[email protected]_0_4_centos src]# ./redis-server

26783:C 06 Jul 22:08:26.085 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
26783:C 06 Jul 22:08:26.085 # Redis version=4.0.10, bits=64, commit=00000000, mo                          dified=0, pid=26783, just started
26783:C 06 Jul 22:08:26.085 # Warning: no config file specified, using the defau                          lt config. In order to specify a config file use ./redis-server /path/to/redis.c                          onf
                _._
           _.-``__ ‘‘-._
      _.-``    `.  `_.  ‘‘-._           Redis 4.0.10 (00000000/0) 64 bit
  .-`` .-```.  ```/    _.,_ ‘‘-._
 (    ‘      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|‘` _.-‘|     Port: 6379
 |    `-._   `._    /     _.-‘    |     PID: 26783
  `-._    `-._  `-./  _.-‘    _.-‘
 |`-._`-._    `-.__.-‘    _.-‘_.-‘|
 |    `-._`-._        _.-‘_.-‘    |           http://redis.io
  `-._    `-._`-.__.-‘_.-‘    _.-‘
 |`-._`-._    `-.__.-‘    _.-‘_.-‘|
 |    `-._`-._        _.-‘_.-‘    |
  `-._    `-._`-.__.-‘_.-‘    _.-‘
      `-._    `-.__.-‘    _.-‘
          `-._        _.-‘
              `-.__.-‘

26783:M 06 Jul 22:08:26.086 # WARNING: The TCP backlog setting of 511 cannot be                           enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
26783:M 06 Jul 22:08:26.086 # Server initialized
26783:M 06 Jul 22:08:26.086 # WARNING overcommit_memory is set to 0! Background                           save may fail under low memory condition. To fix this issue add ‘vm.overcommit_m                          emory = 1‘ to /etc/sysctl.conf and then reboot or run the command ‘sysctl vm.ove                          rcommit_memory=1‘ for this to take effect.
26783:M 06 Jul 22:08:26.086 # WARNING you have Transparent Huge Pages (THP) supp                          ort enabled in your kernel. This will create latency and memory usage issues wit                          h Redis. To fix this issue run the command ‘echo never > /sys/kernel/mm/transpar                          ent_hugepage/enabled‘ as root, and add it to your /etc/rc.local in order to reta                          in the setting after a reboot. Redis must be restarted after THP is disabled.
26783:M 06 Jul 22:08:26.086 * Ready to accept connections
进去redis客户端测试下存储数据

./redis-cli 和 ./redis-server 都是在src 目录下

[[email protected]_0_4_centos src]# ./redis-cli
127.0.0.1:6379> set name augus
OK
127.0.0.1:6379> get name
"augus"
127.0.0.1:6379>

测试成功,得到了自己的名字,整个环境就算完成了

Windows

windows的安装就简单的说下

windows redis github下载地址 : https://github.com/MSOpenTech/redis/releases

直接解压,cmd命令进入redis目录下,运行redis-server.exe,运行redis-cli.exe启动即可,操作和linux的差不多的,只不过是在redis目录下,不是src目录

以上是关于Redis ——环境安装的主要内容,如果未能解决你的问题,请参考以下文章

Redis的安装

redis集群搭建

Redis单机版安装

Linux下Redis服务器搭建

redis安装教程

02 Redis 菜鸟到高手 | Linux 平台安装 Redis