[十二省聯考2019]字串問題
一、hightlights
1、data type
2、persistence
(1)When snapshot, it will block client request;
(2)“aof” is not used to master-slave synchronization.
二、installation and configuration
1、installation
(1)Decompression redisà” redis-3.2.10.tar.gz”
(2)“tar zxvf redis-3.2.10.tar.gz”
(3)“make”
(4)“make PREFIX=/usr/common/redis/ install”
2、basic commands
(1)“redis-server”àthe daemon boot program of server
(2)“redis-cli”àcommand line operation toolàtelnet
(3)Redis Desktop Manageràgraphical interfaces
(4)“redis-benchmark”àperformance testing tool,test the write and read capacity on your system.
(5)“redis-check-aof”àcheck update log appendonly.aof,
(6)“redis-check-dump”àcheck rdb files in the local dump.
3、configuration
(1)environment variables
1 export JAVA_HOME=/usr/local/java/jdk1.8.0_261 2 export CLASSPATH=.:$JAVA_HOME/lib.tool.jar:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar3 export NODE_HOME=/usr/local/node 4 export REDIS_HOME=/usr/local/redis 5 export PATH=$JAVA_HOME/bin:$NODE_HOME/bin:$REDIS_HOME/bin:$PATH
(2)” cp redis.conf /usr/local/redis/conf/”
(3)start-->"redis-server /usr/common/redis/conf/redis.conf &"
(4)remote login:
(4.1)bind ip address
(4.2)protected mode no
(5)client login-->"redis-cli –h ip –p port -a"
(6)setup auto start
(6.1)startup script(utils/redis_init_script)
1 #!/bin/sh
2 # chkconfig: 2345 90 10
3 # Simple Redis init.d script conceived to work on Linux systems
4 # as it does use of the /proc filesystem.
5
6 #redis伺服器監聽的埠
7 REDISPORT=6379
8
9 #服務端所處位置
10 EXEC=/usr/local/bin/redis-server
11
12 #客戶端位置
13 CLIEXEC=/usr/local/bin/redis-cli
14
15 #redis的PID檔案位置,需要修改
16 PIDFILE=/var/run/redis_${REDISPORT}.pid
17
18 #redis的配置檔案位置,需將${REDISPORT}修改為檔名
19 CONF="/etc/redis/${REDISPORT}.conf"
20
21 case "$1" in
22 start)
23 if [ -f $PIDFILE ]
24 then
25 echo "$PIDFILE exists, process is already running or crashed"
26 else
27 echo "Starting Redis server..."
28 $EXEC $CONF
29 fi
30 ;;
31 stop)
32 if [ ! -f $PIDFILE ]
33 then
34 echo "$PIDFILE does not exist, process is not running"
35 else
36 PID=$(cat $PIDFILE)
37 echo "Stopping ..."
38 $CLIEXEC -p $REDISPORT shutdown
39 while [ -x /proc/${PID} ]
40 do
41 echo "Waiting for Redis to shutdown ..."
42 sleep 1
43 done
44 echo "Redis stopped"
45 fi
46 ;;
47 *)
48 echo "Please use start or stop as first argument"
49 ;;
50 esac
(6.2)setup
1 mkdir /etc/redis 2 cp redis.conf /etc/redis/6379.conf 3 # 將啟動指令碼複製到/etc/init.d目錄下,本例將啟動指令碼命名為redisd(通常都以d結尾表示是# 後臺自啟動服務) 4 cp redis_init_script /etc/init.d/redisd 5 # 設定為開機自啟動伺服器 6 chkconfig redisd on 7 # 開啟服務 8 service redisd start 9 # 關閉服務 10 service redisd stop
4、warning
(1)“WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.”
1 “vim /etc/sysctl.conf” 2 “net.core.somaxconn= 1024” 3 “sysctl -p”
(2)” WARNING overcommit_memory is set to 0! Background save may fail under low memory condition.”
1 “vim /etc/sysctl.conf”prevent save failure because memory is not enough 2 “vm.overcommit_memory=1” 3 “sysctl –p”
三、operations
1、basic operation
1 “set key value” 2 “get key” 3 “del key” 4 “nil”-->NULL 5 “exists key” 6 “keys *”-->get all
2、dump
1 There are 16 default databases in the redis 2 Identifier-->0-15 3 “select id”-->switch between dumps
3、telnet
1 “telnet ip port” 2 “set key value” 3 “get key”