Go to the official website to download redis-3.2.0.tar.gz, redis-3.2.0.tar.gz into the/opt directory
Decompression redis-3.2.0.tar.gz
[email protected]:/opt$ sudo tar -zxvf redis-3.2.0.tar.gz
Compiling Redis
[email protected]:/opt$ cd redis-3.2.0/[email protected]:/opt/redis-3.2.0$ sudo make
Installation
[email protected]:/opt/redis-3.2.0$ sudo make install
Test whether the installation passes
[email protected]:/opt/redis-3.2.0$ sudo make test见到此字样:\o/ All tests passed without errors!表示测试安装通过
If a need TCL 8.5 or newer in order to run the Redis test error appears
Solutions
[email protected]:/opt/redis-3.2.0$ sudo apt-get install tcl8.5
Modify the configuration file so that other machines can connect to the Redis service
[email protected]:/opt/redis-3.2.0$ sudo vim /opt/redis-3.2.0/redis.conf
Change bind 127.0.0.1 to bind 0.0.0.0
Copy the redis.conf file to the/etc/redis directory
[email protected]:/opt/redis-3.2.0$ sudo mkdir /etc/redis[email protected]:/opt/redis-3.2.0$ sudo cp redis.conf /etc/redis/redis.conf
Start Redis Service
[email protected]:/opt/redis-3.2.0$ /usr/local/bin/redis-server /etc/redis/redis.conf
Go to Redis client and test Redis
[email protected]:/usr/local/bin$ ./redis-cli127.0.0.1:6379> pingPONG
There is no problem connecting to Redis via Redisclient software.
Set up boot from
Modify Redis.conf
#打开后台运行选项daemonize yes#设置日志文件路径logfile "/var/log/redis.log"
Writing scripts
[email protected]:/usr/local/bin$ sudo touch /etc/init.d/redis[email protected]:/usr/local/bin$ sudo vim /etc/init.d/redis
Here is the contents of the script
#!/bin/sh# chkconfig:2345 90# Description:start and Stop Redispath=/usr/local/binredisport=6379exec=/usr/local/bin /redis-serverredis_cli=/usr/local/bin/redis-clipidfile=/var/run/redis.pidconf= "/etc/redis/redis.conf" Case "$" 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, and process is not running." Else pid=$ (cat $PIDFILE) echo "Stopping ..." $REDIS _cli-p $REDISPORT SHUTDOWN While [-X $PIDFILE] do echo "waiting-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|fore-reload}" exit 1esac
To add execute permissions for a script
[email protected]:/usr/local/bin$ sudo chmod +x /etc/init.d/redis
Set boot auto-start
[email protected]:/usr/local/bin$ sudo update-rc.d redis defaults
Start a service with a script
开启redis[email protected]:/usr/local/bin$ service redis start停止redis[email protected]:/usr/local/bin$ service redis stop重启redis[email protected]:/usr/local/bin$ service redis restart
- Turn the machine off and restart
At this point, the Redis service is also started.
Ubuntu14.04 installation of redis-3.2.0 and boot-up