Redis安裝配置

2021-08-19 13:52:18 字數 2828 閱讀 4730

redis使用的埠號為6379,保證防火牆開啟6379埠號。

安裝過程:

[root@localhost ~]# tar -zxvf redis-4.0.1.tar.gz

[root@localhost ~]# cd redis-4.0.1

[root@localhost 4.0.1]# make

[root@localhost 4.0.1]# make prefix=/usr/local/redis install

# redis安裝到 /usr/local/redis/目錄下

[root@localhost 4.0.1]# mkdir -p /data/redisdb

# 建立redis資料存放目錄

# 修改redis配置檔案

[root@localhost 4.0.1]# cp ./redis.conf /usr/local/redis/

[root@localhost 4.0.1]# vim /usr/local/redis/redis.conf

將redis加入服務開機自啟動

[root@localhost 4.0.1]# vim /etc/init.d/redis

# chkconfig: 2345 90 10

# description: service of redis for start and stop add by tomener

path=/usr/local/bin:/sbin:/usr/bin:/bin

redisport=6379

exec=/usr/local/redis/bin/redis-server

redis_cli=/usr/local/redis/bin/redis-cli

pidfile=/var/run/redis_6379.pid

conf="/usr/local/redis/redis.conf"

auth="foobared"

case "$1" in

start)

if [ -f $pidfile ]

then

echo "$pidfile exists, process is already running or crashed."

else

echo "starting redis server..."

$exec $conf

fiif [ "$?"="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 -a $auth -p $redisport shutdown

sleep 2

while [ -x $pidfile ]

doecho "waiting for redis to shutdown..."

sleep 1

done

echo "redis stopped"

fi;;

restart|force-reload)

$ stop

$ start

;;*)

echo "usage: /etc/init.d/redis " >&2

exit 1

esac

# 配置核心引數,等redis指令碼在重啟或停止redis時,能提前同步資料到磁碟中(防止報錯)

[root@localhost 4.0.1]# vim /etc/sysctl.conf

新增如下:

vm.overcommit_memory = 1

[root@localhost 4.0.1]# sysctl -p

[root@localhost 4.0.1]# chmod 0755 /etc/init.d/redis

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

[root@localhost 4.0.1]# chkconfig --level 235 redis on

# redis的開啟、關閉、重啟

[root@localhost 4.0.1]# service redis start|stop|restart

安裝phpredis擴充套件:

[root@localhost ~]# tar -zxvf redis-4.0.1.tgz

[root@localhost ~]# cd redis-4.0.1

[root@localhost redis-4.0.1]# /usr/local/php/bin/phpize

[root@localhost redis-4.0.1]# ./configure --with-php-config=/usr/local/php/bin/php-config

[root@localhost redis-4.0.1]# make 

[root@localhost redis-4.0.1]# make install

[root@localhost redis-4.0.1]# vim /usr/local/php/etc/php.ini

新增如下:

extension="redis.so"

# 重啟php-fpm

[root@localhost redis-4.0.1]# /etc/init.d/php7-fpm restart

redis 安裝 配置

redis的安裝 配置 安裝步驟如下 wget wget tar zxvf redis 2.6.14.tar.gz cd redis 2.6.14 直接make就行了 make 執行完後,執行 make test 如果報如下錯誤 cd src make test you need tcl 8.5 o...

redis安裝配置

安裝環境 ubuntu 16.04.3 64位 wget io releases redis 4.0 6.tar gztar zxvf redis 4.0 6.tar gz2.安裝redis 進入解壓目錄執行 make 命令即可安裝 cd redis 4.0.6 make 注 執行 make 前需安...

Redis安裝配置

root jack31 wget2 解壓redis 4.0.6.tar.gz 3 編譯 4 編譯安裝 5 redis系統啟動 執行.utils install server.sh 6379 埠號 etc redis 6379.conf 配置檔案 var log redis 6379.log 日誌 v...