您好,登錄后才能下訂單哦!
系統: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
創建安裝目錄
# mkdir /usr/local/redis
解壓
# tar xvf redis-3.2.5.tar.gz
編譯安裝
# cd redis-3.2.5
# make PREFIX=/usr/local/redis/ install
創建配置文件、日志、rdb、pid、啟動腳本目錄
# cd /usr/local/redis/
# mkdir log data pid initscript conf
配置redis啟動腳本并重命名
# cp ~/redis-3.2.5/utils/redis_init_script /usr/local/redis/initscript/
# cd /usr/local/redis/initscript/
# mv redis_init_script redis
修改啟動腳本
# 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
復制配置文件并修改redis.conf并重命名(和啟動腳本一致)
# 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參數 # bind 127.0.0.1 2.關閉保護模式 protected-mode no 3.設置端口 prot 6379 4.設置redis為后臺啟動 daemonize yes 5.設置pid文件目錄 pidfile /usr/local/redis/pid/redis_6379.pid 6.設置log文件目錄 logfile"/usr/local/redis/log/redis_6379.log" 7.設置rdb文件存儲名 dbfilename dump_6379.rdb 8.設置rdb文件存儲目錄 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
設置Redis到環境變量
# vim /etc/profile
export PATH=$PATH:/usr/local/redis/bin
使Redis環境變量生效
# source /etc/profile
啟動redis
# /usr/local/redis/initscript/redis start
通過客戶端檢驗
# redis-cli –p 6379
關閉redis
# /usr/local/redis/initscript/redis stop
設置redis為開機啟動
# vim /etc/rc.local
/usr/local/redis/initscript/redis start
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。