Redis安裝與配置

2021-07-25 22:52:56 字數 3167 閱讀 7503

一、windows下安裝redis

由上圖可見redis服務的預設埠為6379

3、保持開啟redis服務剛剛開啟的視窗請不要關閉;另起乙個cmd視窗執行客戶端進驗證是否正常執行,使用cd命令切換到redis目錄執行redis-cli.exe -h 127.0.0.1 -p 6379命令。

設定鍵值對 set mykey abc

- 如果想方便的話,可以把 redis 的路徑加到系統的環境變數裡,這樣就省得再輸路徑了,後面的那個 redis.windows.conf 可以省略,如果省略,會啟用預設的配置。

- 在配置檔案中如果想啟用遠端訪問需要把 bind 127.0.0.1 改為bind 0.0.0.0

二、linux下安裝redis

[root@localhost ~]# cd /home

[root@localhost home]# wget

[root@localhost home]# tar -zxvf redis-3.0.6.tar.gz

#編譯檔案

[root@localhost home]# cd redis-3.0.6

[root@localhost redis-3.0.6]# make

#安裝檔案

[root@localhost redis-3.0.6]# cd src

[root@localhost redis-3.0.6]# make install

#安裝完成後會在/usr/local/bin目錄下生成6個檔案,在redis目錄建立bin資料夾,將6個檔案移動到bin下

[root@localhost redis-3.0.6]# cd /usr/local/bin

[root@localhost bin]# mv * /home/redis-3.0.6/bin

#將redis_init_script檔案拷貝到/etc/rc.d/init.d目錄下並改名為redis:

[root@localhost bin]#cp /home/redis-3.0.6/utils/redis_init_script /etc/rc.d/init.d/redis

#修改配置檔案

#1.在第二行插入

#chkconfig: 2345 80 90

#description:redis

#2.修改服務和客戶端執行檔案為 /home/redis-3.0.6/bin/redis-server /home/redis-3.0.6/bin/redis-cli

#3.將/var/run/redis_$.pid修改為/var/run/redis.pid

#4.修改配置檔案路徑

#5.在$exec $conf後加上「&」 作為後台啟動

#6.設定系統服務,完成編輯儲存退出後執行 chkconfig --add redis

[root@localhost bin]# vi /etc/rc.d/init.d/redis

#!/bin/sh

#chkconfig: 2345 80 90

#description:redis

# ****** redis init.d script conceived to work on linux systems

# as it does use of the /proc filesystem.

redisport=6379

exec=/home/redis-3.0.6/bin/redis-server

cliexec=/home/redis-3.0.6/bin/redis-cli

pidfile=/var/run/redis.pid

conf="/home/redis-3.0.6/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/$ ]

doecho

"waiting for redis to shutdown ..."

sleep 1

done

echo

"redis stopped"

fi ;;

*)echo

"please use start or stop as first argument"

;;esac

[root@localhost bin]# chkconfig --add redis

#啟動服務

[root@localhost init.d]# service redis start

starting redis server...

#停止服務

[root@localhost init.d]# service redis stop

stopping ...

redis stopped

修改配置檔案:redis.conf

daemonize yes 後台執行,否則會獨佔螢幕區域

port 6379監聽的埠

bind 127.0.0.1 繫結監聽的ip位址 0.0.0.0表示任意ip

Redis安裝與配置

1.1 編譯 redis 資料庫 1 將 redis 源 檔案上傳到 linux 系統之中,隨後將其解壓縮到 usr local src 目錄之中 tar xzvf srv ftp redis 3.2.5.tar.gz c usr local src 2 為了進行 redis 資料庫的編譯,那麼需要...

Redis安裝與配置

wget tar xf usr local redis 2.8.12.tar.gz cd redis 2.8.12 make 如果出現一下報錯 zmalloc.h 50 31 fatal error jemalloc jemalloc.h no such file or directory 解決辦法...

Redis安裝與配置

今天在使用redis的時候遇到了一些問題,這個問題的解決,發現很多人使用redis的時候沒有一點安全意識。所以又重溫了一下redis,覺得應該寫一下redis的安全和配置。安裝 wget tar xzf redis 4.0.10.tar.gz mv redis 4.0.10 usr local re...