1, Install redis
1. Download redis installation package
Go to the official website http://redis.io , you can also use the wget command
cd /usr/local/soft/ wget http://download.redis.io/releases/redis-4.0.6.tar.gz
2. Unzip
tar xzf redis-4.0.6.tar.gz
3. Compile and install
cd redis-4.0.6 make
2, Remote access
1. Copy the redis configuration file to etc
cp /usr/local/soft/redis-4.0.6/src/redis.conf /etc/
2. Modify profile
#bind 127.0.0.1 comment out to make all ip access redis
protected-mode yes
3. Turn off firewall
service iptables status
chkconfig iptables off
4. Shutdown and restart
reboot
1. Set daemonize to yes in redis.conf to ensure that the daemons are turned on.
2. Writing startup script
vi /etc/init.d/redis
chkconfig: 2345 10 90 # description: Start and Stop redis PATH=/usr/local/bin:/sbin:/usr/bin:/bin REDISPORT=6379 EXEC=/usr/local/soft/redis-4.0.6/src/redis-server REDIS_CLI=/usr/local/soft/redis-4.0.6/src/redis-cli PIDFILE=/var/run/redis.pid CONF="/etc/redis.conf" AUTH="1234" case "$1" in start) if [ -f $PIDFILE ] then echo "$PIDFILE exists, process is already running or crashed." else echo "Starting Redis server..." $EXEC $CONF fi if [ "$?"="0" ] then echo "Redis is running..." fi ;; stop) if [ ! -f $PIDFILE ] then echo "$PIDFILE exists, process is not running." else PID=$(cat $PIDFILE) echo "Stopping..." $REDIS_CLI -p $REDISPORT SHUTDOWN sleep 2 while [ -x $PIDFILE ] do echo "Waiting for Redis to shutdown..." sleep 1 done echo "Redis stopped" fi ;; restart|force-reload) ${0} stop ${0} start ;; *) echo "Usage: /etc/init.d/redis {start|stop|restart|force-reload}" >&2 exit 1 esac
3. Save after writing exit VI
4. Set permissions
chmod 755 redis
5. Start test
/etc/init.d/redis start
The following message will be prompted if the startup is successful:
Starting Redis server... Redis is running...
Use redis cli to test:
[root@rk ~]# /usr/redisbin/redis-cli 127.0.0.1:6379> set foo bar OK 127.0.0.1:6379> get foo "bar" 127.0.0.1:6379> exit
6. Set power on self start
chkconfig redis on
7. Shutdown and restart test
reboot
Then you can test it with redis cli.