Rdis-部署搭建

服务环境:

  • centos-7.2.1511
  • redis-4.0

Redis是内存数据库,可以用来做持久化缓存,也可以做消息队列。


部署搭建:

  • 安装前配置
grep 'vm.overcommit_memory' /etc/sysctl.conf  || \
echo "vm.overcommit_memory=1" >>/etc/sysctl.conf && \
sysctl -p
echo never > /sys/kernel/mm/transparent_hugepage/enabled
  • 下载并编译安装
wget http://download.redis.io/releases/redis-4.0.11.tar.gz
tar xf redis-4.0.11.tar.gz
mkdir /opt/redis
mkdir /data/redis/redis_7000/{conf,log,data} -p
mv redis-4.0.11 /opt/redis/
ln -s /opt/redis/redis-4.0.11/ /usr/local/redis
cd /usr/local/redis/
make -j4 && make install
  • redis基础配置文件
cat > /data/redis/redis_7000/conf/redis_7000.conf <<EOF
bind 127.0.0.1
port 7000
daemonize yes
tcp-backlog 511
protected-mode no
loglevel notice
always-show-logo yes
dbfilename "redis_7000.rdb"
dir "/data/redis/redis_7000/data"
logfile "/data/redis/redis_7000/log/redis_7000.log"
pidfile "/data/redis/redis_7000/redis_7000.pid"
save 900 1
save 300 10
save 60 1000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
EOF
  • 启动redis服务
/usr/local/bin/redis-server  /data/redis/redis_7000/conf/redis_7000.conf
  • 测试并进入redis
redis-cli  -h 127.0.0.1 -p 7000 ping
redis-cli  -h 127.0.0.1 -p 7000
  • 关闭redis服务
redis-cli shutdown

  • PHP5.6 安装redis扩展
wget https://github.com/phpredis/phpredis/archive/4.1.1.tar.gz
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
点赞

发表评论

电子邮件地址不会被公开。 必填项已用*标注