準備工做java
點擊 官網 下載安裝包mysql
使用 tar -zxvf 把安裝包解壓到 /usr/local 目錄下,命名爲 redis,步驟省略,結果以下nginx
[root@iZ2xxxxxuf9Z local]# pwd /usr/local [root@iZ2xxxxxuf9Z local]# ls aegis etc include lib libexec nginx redis share bin games java lib64 mysql nginx-1.14.1 sbin src
編譯安裝redis
注意要在 redis 目錄下執行sql
[root@iZ2xxxxxuf9Z local]# cd redis/ [root@iZ2xxxxxuf9Z redis]# make #一大堆安裝日誌輸出 LINK redis-benchmark INSTALL redis-check-rdb INSTALL redis-check-aof Hint: It's a good idea to run 'make test' ;) make[1]: Leaving directory `/usr/local/redis/src' [root@iZ2xxxxxuf9Z redis]# make install cd src && make install make[1]: Entering directory `/usr/local/redis/src' CC Makefile.dep make[1]: Leaving directory `/usr/local/redis/src' make[1]: Entering directory `/usr/local/redis/src' Hint: It's a good idea to run 'make test' ;) INSTALL install INSTALL install INSTALL install INSTALL install INSTALL install make[1]: Leaving directory `/usr/local/redis/src' [root@iZ2xxxxxuf9Z redis]#
註冊redis服務vim
#複製utils下redis_init_script到/etc/rc.d/init.d/ 並命名爲redis [root@iZ2xxxxxuf9Z redis]# cp utils/redis_init_script /etc/rc.d/init.d/redis #修改腳本文件 在第1行下面添加下面兩行 # chkconfig: 2345 80 90 # description: Redis is a persistent key-value database [root@iZ2xxxxxuf9Z redis]# vim #!/bin/sh # chkconfig: 2345 80 90 # description: Redis is a persistent key-value database # Simple Redis init.d script conceived to work on Linux systems # as it does use of the /proc filesystem. ### BEGIN INIT INFO # Provides: redis_6379 # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Redis data structure server # Description: Redis data structure server. See https://redis.io ### END INIT INFO REDISPORT=6379 EXEC=/usr/local/bin/redis-server CLIEXEC=/usr/local/bin/redis-cli PIDFILE=/var/run/redis_${REDISPORT}.pid CONF="/etc/redis/${REDISPORT}.conf"
初步配置文件修改centos
從上一步的 /etc/rc.d/init.d/redis 文件中能夠看到,CONF="/etc/redis/${REDISPORT}.conf"
,若不修改此行配置文件指向,則須要把配置文件以 端口號.conf 放在 /etc/redis 目錄下ide
[root@iZ2xxxxxuf9Z redis-5.0.0]# mkdir -p /etc/redis #複製配置文件到/etc/redis/下,並命名爲6379.conf [root@iZ2xxxxxuf9Z redis]# cp redis.conf /etc/redis/6379.conf [root@iZ2xxxxxuf9Z redis]# vim /etc/redis/6379.conf #註釋bind 127.0.0.1(用於遠程鏈接),將「daemonize no」修改成「daemonize yes」 #bind 127.0.0.1 daemonize yes
啓動與開機啓動centos7
#啓動redis [root@iZ2xxxxxuf9Z redis]# systemctl start redis #設置開機啓動 [root@iZ2xxxxxuf9Z redis]# systemctl enable redis
參考文檔:wliet - centos7源碼安裝redis-5.0.0idea