1. Unzip redis
$:tar -zxvf Downloads/redis-3.2.4.tar.gz -C /usr/local/
2. Rename
$:mv /usr/local/redis-3.2.4/ /usr/local/redis3.2
3. Compile
$ make /usr/local/redis-3.2.4/
4. Start redis3.2
$./src/redis-server
Close the process: $ kill -9
5. Open the client
$./src/redis-cli
Quit the client: $:quit
6. Set startup
1. Copy : $ cp /usr/local/redis3.2/utils/redis_init_script /etc/init.d/redis
2. Edit : $ vi /etc/init.d/redis
3. Copy:
# chkconfig: 2345 90 10
# description: Start and Stop redis
to the /etc/init.d/redis file and put it in the head
4. Modify the corresponding: path (mainly the installation path of redis ) /usr/local/redis3.2/src/redis-server
EXEC=/usr/local/redis3.2/src/redis-server
CLIEXEC=/usr/local/redis3.2/src/redis-cli
5. Create the /etc/redis folder, $ mkdir /etc/redis
6. To this we need to copy the redis.conf file to the /etc/redis directory
$ cp /usr/local/redis3.2/redis.conf /etc/redis/6379.conf
7. Redis does not run as a daemon process by default, you can modify it through this configuration item and use yes to enable the daemon process
daemonize no
8. Configure permissions: $ chmod +x /etc/init.d/redis
9. Set boot up: chkconfig redis on
10. Manual start: service redis start , manual shutdown: service redis stop
11. Open port 6379 : $: firewall-cmd --zone=public --add-port=6379/tcp --permanent
12. Restart the firewall: $ systemctl restart firewalld.service
13. Bind vi /etc/redis/6379.conf ( remote access will not be possible without binding ip )
$:bind 192.168.83.136
Attachment /etc/init.d/redis configuration file:
# chkconfig: 2345 90 10
# descriptio: Star=/usr/local/redis3.2/src/redis-server
CLIEXEC=/usr/local/redis3.2/src/redis-cli
# Simple Redis init.d script conceived to work on Linux systems
# as it does use of the /proc filesystem.
REDISPORT=6379
EXEC=/usr/local/redis3.2/src/redis-server
CLIEXEC=/usr/local/redis3.2/src/redis-cli
PIDFILE=/var/run/redis_${REDISPORT}.pid
CONF="/etc/redis/${REDISPORT}.conf"
case "$1" in
start)
if [ -f $PIDFILE ]
then
echo "$PIDFILE exists, process is already running or crashed"
else
echo "Starting Redis server..."
$EXEC $CONF
be
;;
stop)
if [ ! -f $PIDFILE ]
then
echo "$PIDFILE does not exist, process is not running"
else
PID=$(cat $PIDFILE)
echo "Stopping ..."
$CLIEXEC -p $REDISPORT shutdown
while [ -x /proc/${PID} ]
do
echo "Waiting for Redis to shutdown ..."
sleep 1
done
echo "Redis stopped"
be
;;
*)
echo "Please use start or stop as first argument"
;;
esac