论坛首页 编程语言技术论坛

Redis: 安装

浏览 532 次
锁定老帖子 主题:Redis: 安装
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2020-10-12  

Redis

 

安装

其实之前有一篇文章记录过redis的安装过程。redis安装其实很简单的。

 

# tar -zxvf redis-3.2.0.tar.gz

# make

# make PREFIX=/usr/local/redis-3.0.0 install

 

安装hiredis

# cd deps/hiredis

# make install

 

写道
# tree /usr/local/lib
/usr/local/lib
├── libhiredis.a
├── libhiredis.so -> libhiredis.so.0
├── libhiredis.so.0 -> libhiredis.so.0.11
└── libhiredis.so.0.11

0 directories, 4 files

 

写道
# tree /usr/local/include/
/usr/local/include/
└── hiredis
├── adapters
│   ├── ae.h
│   ├── libevent.h
│   ├── libev.h
│   └── libuv.h
├── async.h
└── hiredis.h

 

指定hiredis安装目录

# make PREFIX=/usr/local/redis-3.0.0 install

写道
# tree /usr/local/redis-3.0.0/lib
/usr/local/redis-3.0.0/lib
├── libhiredis.a
├── libhiredis.so -> libhiredis.so.0
├── libhiredis.so.0 -> libhiredis.so.0.11
└── libhiredis.so.0.11

0 directories, 4 files

 

写道
# tree /usr/local/redis-3.0.0/include/
/usr/local/redis-3.0.0/include/
└── hiredis
├── adapters
│   ├── ae.h
│   ├── libevent.h
│   ├── libev.h
│   └── libuv.h
├── async.h
└── hiredis.h

2 directories, 6 files

 

单独安装hiredis

$ tar -zxvf hiredis-1.0.0.tar.gz

$ make

$ make PREFIX=/usr/local/hiredis-1.0.0 install

 

├─include
│  └─hiredis
│      │  alloc.h
│      │  async.h
│      │  hiredis.h
│      │  read.h
│      │  sds.h
│      │
│      └─adapters
│              ae.h
│              glib.h
│              ivykis.h
│              libev.h
│              libevent.h
│              libuv.h
│              macosx.h
│              qt.h
│
└─lib
    │  libhiredis.a
    │  libhiredis.so.1.0.0
    │
    └─pkgconfig
            hiredis.pc

 

 

启动

# redis-server

4944:C 12 Oct 05:04:49.824 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf

4944:M 12 Oct 05:04:49.832 * Increased maximum number of open files to 10032 (it was originally set to 1024).

4944:M 12 Oct 05:04:49.885 # Warning: 32 bit instance detected but no memory limit set. Setting 3 GB maxmemory limit with 'noeviction' policy now.

                _._                                                  

           _.-``__ ''-._                                             

      _.-``    `.  `_.  ''-._           Redis 3.0.0 (00000000/0) 32 bit

  .-`` .-```.  ```\/    _.,_ ''-._                                   

 (    '      ,       .-`  | `,    )     Running in standalone mode

 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379

 |    `-._   `._    /     _.-'    |     PID: 4944

  `-._    `-._  `-./  _.-'    _.-'                                   

 |`-._`-._    `-.__.-'    _.-'_.-'|                                  

 |    `-._`-._        _.-'_.-'    |           http://redis.io        

  `-._    `-._`-.__.-'_.-'    _.-'                                   

 |`-._`-._    `-.__.-'    _.-'_.-'|                                  

 |    `-._`-._        _.-'_.-'    |                                  

  `-._    `-._`-.__.-'_.-'    _.-'                                   

      `-._    `-.__.-'    _.-'                                       

          `-._        _.-'                                           

              `-.__.-'                                               

 

4944:M 12 Oct 05:04:49.896 # Server started, Redis version 3.0.0

4944:M 12 Oct 05:04:49.920 # 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.

4944:M 12 Oct 05:04:49.923 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.

4944:M 12 Oct 05:04:49.924 * The server is now ready to accept connections on port 6379

 

连接

连接到redis可以通过redis提供的redis-cli工具,还可以通过telnet的方式连接到redis。

 

通过redis-cli工具连接到redis

 

# redis-cli

127.0.0.1:6379> help

redis-cli 3.0.0

Type: "help @<group>" to get a list of commands in <group>

      "help <command>" for help on <command>

      "help <tab>" to get a list of possible help topics

      "quit" to exit

 

# redis-cli -h 127.0.0.1 -p 6379

 

通过redis-cli工具还可以进入命令行模式下直接执行命令:

# redis-cli get hello

"this is c"

# redis-cli set key1 value1

OK

 

# redis-cli get key1

"value1"

 

通过telnet的方式连接到redis

>telnet 192.168.0.102 6379

 

论坛首页 编程语言技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics