亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊(cè) 查看新帖 |

Chinaunix

  平臺(tái) 論壇 博客 文庫(kù)
最近訪問(wèn)板塊 發(fā)新帖
查看: 3826 | 回復(fù): 0
打印 上一主題 下一主題

分布式緩存Redis Centos下單節(jié)點(diǎn)安裝 [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2018-06-28 15:21 |只看該作者 |倒序?yàn)g覽

摘要: Redis官網(wǎng):http://redis.io  獨(dú)立緩存服務(wù)器:IP:xxx.xxx.xxx.xxx 安裝環(huán)境:CentOS 6.6 Redis 版本:redis-3.0 (因?yàn)?Redis3.0 在集群&#...

聲明: 網(wǎng)上關(guān)于分布式緩存Redis的學(xué)習(xí)資料很多,大家可以去網(wǎng)上找些資料去學(xué)習(xí)。

另外 JEESZ框架面向企業(yè)的大型互聯(lián)網(wǎng)分布式企業(yè)架構(gòu),分布式緩存是必不可少的,故這邊總結(jié)了一些關(guān)于分布式緩存Redis的實(shí)戰(zhàn)文章作為后期JEESZ分布式框架的教程,希望也可以幫助到大家,請(qǐng)勿吐槽。

Redis官網(wǎng):[color=rgb(49, 148, 20]http://redis.io

獨(dú)立緩存服務(wù)器:IP:xxx.xxx.xxx.xxx

安裝環(huán)境:CentOS 6.6

Redis 版本:redis-3.0 (因?yàn)?Redis3.0 在集群和性能提升方面的特性,rc 版為正式版的候選版,請(qǐng)?jiān)诎惭b時(shí)去官網(wǎng)選用最新版)

用戶:root

安裝目錄:/usr/local/redis

下面我們針對(duì)于Redis安裝做下詳細(xì)的記錄:

編譯和安裝所需的包:

# yum install gcc tcl

提醒:下載 3.0 版 Redis(當(dāng)前最新版 redis-3.0.0-rc5.tar.gz,請(qǐng)?jiān)诎惭b時(shí)去官網(wǎng)選用最新版)

# cd /usr/local/src

# wget[color=rgb(49, 148, 20]https://github.com/antirez/redis/archive/3.0.0-rc5.tar.gz

提醒:此路徑可以通過(guò)官網(wǎng)去下載目錄copy

創(chuàng)建安裝目錄:

# mkdir /usr/local/redis

解壓:

# tar -zxvf 3.0.0-rc5.tar.gz

# mv redis-3.0.0-rc5 redis3.0

# cd redis3.0

安裝(使用 PREFIX 指定安裝目錄):

# make PREFIX=/usr/local/redis install

安裝完成后,可以看到/usr/local/redis 目錄下有一個(gè) bin 目錄,bin 目錄里就是 redis 的命令腳本:

redis-benchmark redis-check-aof redis-check-dump redis-cli redis-server

將 Redis 配置成服務(wù):

按上面的操作步驟,Redis 的啟動(dòng)腳本為:/usr/local/src/redis3.0/utils/redis_init_script

將啟動(dòng)腳本復(fù)制到/etc/rc.d/init.d/目錄下,并命名為 redis

# cp /usr/local/src/redis3.0/utils/redis_init_script /etc/rc.d/init.d/redis

編輯/etc/rc.d/init.d/redis,修改相應(yīng)配置,使之能注冊(cè)成為服務(wù):

# vi /etc/rc.d/init.d/redis

#!/bin/sh

#

# Simple Redis init.d script conceived to work on Linux systems

# as it does use of the /proc filesystem.

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"

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 "lease use start or stop as first argument"

;;

esac

查看以上 redis 服務(wù)腳本,關(guān)注標(biāo)為橙色的幾個(gè)屬性,做如下幾個(gè)修改的準(zhǔn)備:

(1) 在腳本的第一行后面添加一行內(nèi)容如下:

#chkconfig: 2345 80 90

提醒:如果不添加上面的內(nèi)容,在注冊(cè)服務(wù)時(shí)會(huì)提示:service redis does not support chkconfig

(2) REDISPORT 端口保持 6379 不變;(特別注意:端口名將與下面的配置文件名有關(guān))

(3) EXEC=/usr/local/bin/redis-server 改為 EXEC=/usr/local/redis/bin/redis-server

(4) CLIEXEC=/usr/local/bin/redis-cli 改為 CLIEXEC=/usr/local/redis/bin/redis-cli

(5) 配置文件設(shè)置:

創(chuàng)建 redis 配置文件目錄

# mkdir /usr/local/redis/conf

復(fù)制 redis 配置文件/usr/local/src/redis3.0/redis.conf 到/usr/local/redis/conf 目錄并按端口號(hào)重命名為6379.conf

# cp /usr/local/src/redis3.0/redis.conf /usr/local/redis/conf/6379.conf

做了以上準(zhǔn)備后,再對(duì) CONF 屬性作如下調(diào)整:

CONF="/etc/redis/${REDISPORT}.conf" 改為 CONF="/usr/local/redis/conf/${REDISPORT}.conf"

(6) 更改 redis 開(kāi)啟的命令,以后臺(tái)運(yùn)行的方式執(zhí)行:

$EXEC $CONF &   #“&”作用是將服務(wù)轉(zhuǎn)到后面運(yùn)行

修改后的/etc/rc.d/init.d/redis 服務(wù)腳本內(nèi)容為:

#!/bin/sh

#chkconfig: 2345 80 90

#

# Simple Redis init.d script conceived to work on Linux systems

# as it does use of the /proc filesystem.

REDISPORT=6379

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

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

PIDFILE=/var/run/redis_${REDISPORT}.pid

CONF="/usr/local/redis/conf/${REDISPORT}.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 "lease use start or stop as first argument"

;;

esac

以上配置操作完成后,便可將 Redis 注冊(cè)成為服務(wù):

# chkconfig --add redis

防火墻中打開(kāi)對(duì)應(yīng)的端口

# vi /etc/sysconfig/iptables

添加:

-A INPUT -m state --state NEW -m tcp -p tcp --dport 6379 -j ACCEPT

重啟防火墻:

# service iptables restart

修改 redis 配置文件設(shè)置:

# vi /usr/local/redis/conf/6379.conf

修改如下配置

daemonize no 改為 daemonize yes

備注:如果不改為yes,pid文件是不會(huì)生成,start、stop命令是不會(huì)生效的(依賴pid文件)

pidfile /var/run/redis.pid 改為 pidfile /var/run/redis_6379.pid

啟動(dòng) Redis 服務(wù)

# service redis start

將 Redis 添加到環(huán)境變量中:

# vi /etc/profile

在最后添加以下內(nèi)容:

## Redis env

export PATH=$PATH:/usr/local/redis/bin

使配置生效:

# source /etc/profile

當(dāng)前可以直接使用 redis-cli 等 redis 命令了:

# redis-cli

關(guān)閉 Redis 服務(wù)

# service redis stop

提醒:默認(rèn)情況下,Redis 開(kāi)啟安全認(rèn)證,可以通過(guò)/usr/local/redis/conf/6379.conf 的 requirepass 指定一個(gè)

驗(yàn)證密碼


您需要登錄后才可以回帖 登錄 | 注冊(cè)

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號(hào)-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號(hào):11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報(bào)專(zhuān)區(qū)
中國(guó)互聯(lián)網(wǎng)協(xié)會(huì)會(huì)員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過(guò)ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請(qǐng)注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP