安裝remi源
# wget http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
# rpm -Uvh remi-release-7.rpm
# sed -i -e "s/enabled=1/enabled=0/g" /etc/yum.repos.d/remi.repo
確認使用remi源時安裝的Redis版本。
安裝Redis
使用remi源yum安裝Redis。
# yum install redis --enablerepo=remi
確認Redis版本。
# redis-server --version
修改Redis配置文件/etc/redis.conf
想以服務形式使用Redis因此進行daemonize參數從no改為yes。
/etc/redis.conf
Redis重要特點就是數據的持久性,Redis保存數據的方法RDB文件(RDB=Redis DataBase?)及AOF(Append Only File),可同時使用RDB文件保存及AOF。RDB文件保存目錄是參數dir指定的目錄。
# save <seconds> <changes>
# Will save the DB if both the given number of seconds and the given
# In the example below the behaviour will be to save:
# Note: you can disable saving completely by commenting out all "save" lines.
# It is also possible to remove all the previously configured save
# points by adding a save directive with a single empty string argument
# save ""
save 900 1 # 15分鐘之內有一次變更時進行保存
save 300 10# 5分鐘之內有10次變更時進行保存
save 60 10000# 1分鐘之內有10000次變更時進行保存
redis-cli 命令 命令行打開客戶端
安裝php-redis擴展及簡單使用