CentOS 6.6 Redis installation configuration record
- 2020-05-07 20:38:55
- OfStack
redis was covered in a previous article, and the following is my record of installing Redis on CentOS. For later improvement.
1. Support environment for installation
The first thing to do before installing Redis is to install Unix's Tcl tool. If you do not install Redis, you will not be able to test Redis later. Error message: You need tcl 8.xuyao de5 or newer to run the Redis test
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 and is available on the tutorial website. Specific as follows: http: / / redis io/download
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, in the case of omission, redis will be installed by default to /usr/local/bin directory.
3. Test Redis
cd src
make test
With the above command you will be able to test redis on a larger scale.
4, configure redis
Copy and modify the configuration document
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 daemon. By default no will temporarily use your terminal
timeout 300 & # 8203; Close the connection when the client has been idle for a long time. If 0 is specified, this function is turned off
More configuration content will be released after the completion of the follow-up comb.
B, set to automatically start
vim /etc/init.d/redis
Save the following in the file:
#!/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 close the service
service redis start
service redis stop
5. Use redis
[root@localhost redis]# cd /usr/local/redis/bin
[root@localhost 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>