Redis installation configuration record under CentOS 6.6

Time:2020-3-9

In the previous article, redis was introduced. The following is the record of installing redis on CentOS. For later improvement.

1. Support environment required for installation

The first thing to do before installing redis is to install the TCL tool of UNIX. If you do not install it, you will not be able to test redis later. You need TCL 8.xuyao de5 or new in order to run the redis test, the specific process is as follows:

Copy codeThe code is as follows:
cd /usr/local/src
wget http://downloads.sourceforge.net/tcl/tcl8.6.3-src.tar.gz
tar -zxvf tcl8.6.3-src.tar.gz
cd ​tcl8.6.3/unix/
./configure
make
make install

2. Install redis

The process of installing redis is very simple. There are also specific tutorials on the official website. The details are as follows: http://redis.io/download

Copy codeThe code is as follows:
cd /usr/local/src
wget http://download.redis.io/releases/redis-2.8.19.tar.gz
tar zxvf redis-2.8.19.tar.gz
cd redis-2.8.19
make
make PREFIX=/usr/local/redis install

Where prefix = / usr / local / redis can be omitted. If it is omitted, redis will be installed in / usr / local / bin directory by default.

3. Test redis

Copy codeThe code is as follows:
cd src
make test

Through the above command, you need to be able to test redis.

4. Configure redis

A. Copy and modify configuration documents

Copy codeThe code is as follows:
cp ./redis.conf /usr/local/redis/
vim /usr/local/redis/redis.conf

I only modified the following two items:

Daemonize yes ා redis will run as a daemons. No will temporarily use your terminal by default
Timeout 300 ා when the client is idle for how long, close the connection. If 0 is specified, close the function

More configuration content will be released after subsequent sorting.

B. Set auto start

Copy codeThe code is as follows:
vim /etc/init.d/redis

The following contents are saved in the file:

Copy codeThe code is as follows:
#!/bin/sh
#
# redis        Startup script for Redis Server
#
# chkconfig: – 80 12
# description: Redis is an open source, advanced key-value store.
#
# processname: redis-server
# config: /etc/redis.conf
# pidfile: /var/run/redis.pid
source /etc/init.d/functions
BIN=”/usr/local/redis/bin”
CONFIG=”/usr/local/redis/redis.conf”
PIDFILE=”/var/run/redis.pid”
### Read configuration
[ -r “$SYSCONFIG” ] && source “$SYSCONFIG”
RETVAL=0
prog=”redis-server”
desc=”Redis Server”
start() {
        if [ -e $PIDFILE ];then
             echo “$desc already running….”
             exit 1
        fi
        echo -n $”Starting $desc: “
        daemon $BIN/$prog $CONFIG
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
        return $RETVAL
}
stop() {
        echo -n $”Stop $desc: “
        killproc $prog
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog $PIDFILE
        return $RETVAL
}
restart() {
        stop
        start
}
case “$1” in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart)
        restart
        ;;
  condrestart)
        [ -e /var/lock/subsys/$prog ] && restart
        RETVAL=$?
        ;;
  status)
        status $prog
        RETVAL=$?
        ;;
   *)
        echo $”Usage: $0 {start|stop|restart|condrestart|status}”
        RETVAL=1
esac
exit $RETVAL

C. Start or shut down the service

Copy codeThe code is as follows:
service redis start
service redis stop

5. Use redis

Copy codeThe code is as follows:
[[email protected] redis]# cd /usr/local/redis/bin
[[email protected] bin]# ./redis-cli
127.0.0.1:6379> set foo bar
OK
127.0.0.1:6379> get foo
“bar”
127.0.0.1:6379>

Recommended Today

asp.net Application of regular expression

1. Balanced group / recursive matching (?’ Group ‘), which is called the corresponding content of group, and counts it on the stack;(?’- Group ‘), and count the corresponding content named group out of the stack(?!) Zero width negative look ahead assertion. Since there is no suffix expression, attempts to match always failRegular example:,{0,1}”5″:\[[^\[\]]*(((?’Open’\[)[^\[\]]*)+((?’-Open’\])[^\[\]]*)+)*(?(Open)(?!))\],{0,1} Test […]