系统:CentOS 6.8 64X
通许网站建设公司创新互联,通许网站设计制作,有大型网站制作公司丰富经验。已为通许上千提供企业网站建设服务。企业网站搭建\外贸营销网站建设要多少钱,请找那个售后服务好的通许做网站的公司定做!
redis版本:redis-3.2.5
下载安装包
# wgethttp://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