1、下載軟件包html
官網地址:https://redis.io
wget http://download.redis.io/releases/redis-4.0.2.tar.gzc++
2、安裝redis
解壓:tar zxvf redis-5.0.0.tar.gzvim
移動文件到/usr/local: mv ./redis-5.0.0 /usr/local/服務器
進入redis目錄: cd /usr/local/redis-5.0.0工具
3、安裝手冊:https://redis.io/download 性能
檢查是否安裝了gcc 、gcc-c++、tcl學習
yum install gcc測試
yum install gcc-c++spa
yum install tcl
執行編譯:
make
建立目錄bin 和 conf:
mkdir ./bin
mkdir ./conf
複製文件:
#拷貝redis開頭的全部文件
cp ./src/redis* ./bin/
cp redis.conf ./conf
將全部文件夾刪除,只保留bin和conf目錄
刪除編譯文件:
rm -f ./bin/*.c
rm -f ./bin/*.o
rm -f ./bin/*.h
修改配置文件:
vim ./conf/redis.conf
daemonize no
修改成:
daemonize yes (後臺程序方式運行)
bind 127.0.0.1 在前面加#註釋
protected-mode yes
修改成
protected-mode no
啓動Redis:
./bin/redis-server ./conf/redis.conf
使用內置客戶端與Redis進行交互:
./redis-cli
命令 |
簡介 |
redis-server |
Redis服務器端啓動程序 |
redis-cli |
Redis客戶端操做工具。也能夠用telnet根據其純文本協議來操做 |
redis-benchmark |
Redis性能測試工具 |
redis-check-aof |
數據修復工具 |
redis-check-dump |
檢查導出工具 |
推薦學習Redis基本命令網址:http://www.runoob.com/redis/redis-commands.html
配置開機自啓腳本:
vim /etc/init.d/redis
#!/bin/sh # chkconfig:2345 90 10 # description:Redis is a persistent key-value database REDISPORT=6379 EXEC=/usr/local/redis-5.0.0/bin/redis-server CLIEXEC=/usr/local/redis-5.0.0/bin/redis-cli PIDFILE=/var/run/redis_${REDISPORT}.pid CONF="/usr/local/redis-5.0.0/conf/redis.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 fi ;; 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" fi ;; *) echo "Please use start or stop as first argument" ;; esac
賦予權限:
chmod 777 /etc/init.d/redis
便可使用如下命令啓動服務:
service redis start
加入開機啓動項:
chkconfig --add redis