您好,登錄后才能下訂單哦!
系統(tǒng):CentOS 6.8 64X
Redis版本:redis-3.2.5
下載安裝包
# wget http://download.redis.io/releases/redis-3.2.5.tar.gz
安裝編譯所需包
# yum -y install gcc tcl
創(chuàng)建安裝目錄
# mkdir /usr/local/redis
解壓
# tar xvf redis-3.2.5.tar.gz
編譯安裝
# cd redis-3.2.5
# make PREFIX=/usr/local/redis/ install
創(chuàng)建配置文件、日志、rdb、pid、啟動(dòng)腳本目錄
# cd /usr/local/redis/
# mkdir log data pid initscript conf
配置redis啟動(dòng)腳本并重命名
# cp ~/redis-3.2.5/utils/redis_init_script /usr/local/redis/initscript/
# cd /usr/local/redis/initscript/
# mv redis_init_script redis
修改啟動(dòng)腳本
# vim redis
#!/bin/sh # # Simple Redis init.d script conceived towork 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=/usr/local/redis/pid/redis_${REDISPORT}.pid CONF="/usr/local/redis/conf/${REDISPORT}.conf" case "$1" in start) if [ -f $PIDFILE ] then echo "$PIDFILE exists, processis already running or crashed" else echo "Starting Redisserver..." $EXEC $CONF fi ;; stop) if [ ! -f $PIDFILE ] then echo "$PIDFILE does notexist, process is not running" else PID=$(cat $PIDFILE) echo "Stopping ..." $CLIEXEC -p $REDISPORT shutdown while [ -x /proc/${PID} ] do echo "Waiting forRedis to shutdown ..." sleep 1 done echo "Redis stopped" fi ;; *) echo "Please use start or stop as first argument" ;; esac
復(fù)制配置文件并修改redis.conf并重命名(和啟動(dòng)腳本一致)
# cp /home/roger/package/redis-3.2.5/redis.conf/usr/local/redis/conf/
# cd /usr/local/redis/conf/
# mv redis.conf 6379.conf
# vim 6379.conf
1.注釋bind參數(shù) # bind 127.0.0.1 2.關(guān)閉保護(hù)模式 protected-mode no 3.設(shè)置端口 prot 6379 4.設(shè)置redis為后臺(tái)啟動(dòng) daemonize yes 5.設(shè)置pid文件目錄 pidfile /usr/local/redis/pid/redis_6379.pid 6.設(shè)置log文件目錄 logfile"/usr/local/redis/log/redis_6379.log" 7.設(shè)置rdb文件存儲(chǔ)名 dbfilename dump_6379.rdb 8.設(shè)置rdb文件存儲(chǔ)目錄 dir /usr/local/redis/data/
修改防火墻,打開6379端口
# vim /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp--dport 6379 -j ACCEPT
重啟防火墻
# service iptables restart
設(shè)置Redis到環(huán)境變量
# vim /etc/profile
export PATH=$PATH:/usr/local/redis/bin
使Redis環(huán)境變量生效
# source /etc/profile
啟動(dòng)redis
# /usr/local/redis/initscript/redis start
通過(guò)客戶端檢驗(yàn)
# redis-cli –p 6379
關(guān)閉redis
# /usr/local/redis/initscript/redis stop
設(shè)置redis為開機(jī)啟動(dòng)
# vim /etc/rc.local
/usr/local/redis/initscript/redis start
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。