Redis bis - single node structures

This article is only for personal learning, free to reprint, but beginners will inevitably be flawed, caution

2019-06-05 00:37:42

First, prepare the environment

Install gcc

[root@redis ~]# yum install -y gcc

Upload Package to specify the path to extract the specified path, change the directory name

[root@redis ~]# cd /data/software/
[root@redis software]# ls
redis-3.0.0-rc2.tar.gz
[root@redis software]# tar zxvf redis-3.0.0-rc2.tar.gz -C /data
[root@redis software]# mv /data/redis-3.0.0-rc2 /data/redis-3.0.0

Second, compile and install and modify the configuration file

Compile

[root@redis data]# cd redis-3.0.0/
[root@redis redis-3.0.0]# ls
00-RELEASENOTES  CONTRIBUTING  deps     Makefile   README      runtest          runtest-sentinel  src    utils
BUGS             COPYING       INSTALL  MANIFESTO  redis.conf  runtest-cluster  sentinel.conf     tests
[root@redis redis-3.0.0]# make

The following figure shows the output of the compiler success

installation

[root@redis redis-3.0.0]# ls
00-RELEASENOTES  CONTRIBUTING  deps     Makefile   README      runtest          runtest-sentinel  src    utils
BUGS             COPYING       INSTALL  MANIFESTO  redis.conf  runtest-cluster  sentinel.conf     tests
[root@redis redis-3.0.0]# cd src
[root@redis src]# make install

Hint: It's a good idea to run 'make test' ;)

    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
[root@redis src]# 

Profile Description

redis-server: service startup script

redis-cli: client startup script

redis-3.0.0 / redis.conf Detailed profiles:

# Startup mode, the default is no representation reception start instead yes, backstage start 
daemonize yes 
# listening port, default is 6379 
Port 6379 
# startup log file name, the default is empty, see mood set 
logfile " log-Start " 
# will redis divided into a number of databases, the default is 16, starting from 0 
databases 16 
# data file name, redis default persistent way rdb mode 
dbfilename dump.rdb 
storage path # data files and log files, the default yes. / ie redis.conf in the same directory, you can create a new file to store logs
 dir ./ logs 
# is turned aof persistent way, turned off by default 
appendOnly NO 
#aof data file name, the default appendonly.aof 
appendFileName " appendonly.aof "

New log file path and start

[root@redis redis-3.0.0]# pwd
/data/redis-3.0.0
[root@redis redis-3.0.0]# mkdir logs
[root@redis redis-3.0.0]# ./src/redis-server ./redis.conf

Stop command

./src/redis-cli shutdown

View the boot log

 When you start, it will create an empty boot log file in the same directory under redis.conf (./), at the same time create a boot log file in the specified path (./logs), expressed as follows successful start

[root@redis redis-3.0.0]# ls
00-RELEASENOTES  CONTRIBUTING  deps     logs       Makefile   README      runtest          runtest-sentinel  src    utils
BUGS             COPYING       INSTALL  log-start  MANIFESTO  redis.conf  runtest-cluster  sentinel.conf     tests
[root@redis redis-3.0.0]# cat log-start 
[root@redis redis-3.0.0]# cd logs
[root@redis logs]# ls
log-start
[root@redis logs]# cat log-start 
4045:M 05 Jun 01:31:01.075 * Increased maximum number of open files to 10032 (it was originally set to 1024).
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 2.9.102 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 4045
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

4045:M 05 Jun 01:31:01.076 # Server started, Redis version 2.9.102
4045:M 05 Jun 01:31:01.076 # 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.
4045:M 05 Jun 01:31:01.076 # 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.
4045:M 05 Jun 01:31:01.076 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
4045:M 05 Jun 01:31:01.076 * The server is now ready to accept connections on port 6379
[root@redis logs]# 

Login Client

[root@redis redis-3.0.0]# pwd
/data/redis-3.0.0
[root@redis redis-3.0.0]# ./src/redis-cli 
127.0.0.1:6379> 

Basic Commands

127.0.0.1:6379> keys *
(empty list or set)
127.0.0.1:6379> set name Sara
OK
127.0.0.1:6379> get name
"Sara"
127.0.0.1:6379> set age 17
OK
127.0.0.1:6379> get age
"17"
127.0.0.1:6379> keys *
1) "age"
2) "name"
127.0.0.1:6379> del age
(integer) 1
127.0.0.1:6379> keys *
1) "name"
127.0.0.1:6379> quit
[root@redis redis-3.0.0]#

 

Guess you like

Origin www.cnblogs.com/is-raining/p/10977316.html