redis搭建及相应问题整理

php-redis中文帮助手册.chm

官网安装教程:http://www.redis.net.cn/download/
参考网站:http://blog.csdn.net/shachao888/article/details/60139108

 

本文安装位置为/usr/local/redis,首先进入/usr/local/redis/bin目录
cd /usr/local/redis/bin
//******************开始安装****************************************
1: 下载redis
wget http://download.redis.io/releases/redis-3.0.6.tar.gz



2: 解压
tar xzf redis-3.0.6.tar.gz
并重命名为redis

3: 进入目录
cd redis-3.0.6


4: 编译: 
make && make install


5:创建文件启动
mkdir -p /usr/local/redis/bin //创建可执行文件夹 
mkdir -p /usr/local/redis/etc //创建配置文件夹
mv redis.conf /usr/local/redis/etc
cd src
mv mkreleasehdr.sh redis-benchmark redis-check-aof redis-cli redis-server /usr/local/redis/bin


5:启动redis -- 指定配置文件
启动:
/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf &
客户端连接:
/usr/local/redis/bin/redis-cli -h 127.0.0.1 -p 63798 -a "password" 
停止:
/usr/local/redis/bin/redis-cli -h 127.0.0.1 -p 63798 -a "password" shutdown
查看当前服务状态:
ps -ef | grep -i redis
停止某个redis服务
kill -9 PID
查看redis版本:
./redis-cli -v

 

------------------------------------------------------------------------------------------------------
3.0
启动:
/usr/local/redis_h/bin/redis-server /usr/local/redis_h/etc/redis.conf &
客户端连接:
/usr/local/redis_h/bin/redis-cli -h 127.0.0.1 -p 63798 -a "jufaQAZwsx" 
停止:
/usr/local/redis_h/bin/redis-cli -h 127.0.0.1 -p 63798 -a "jufaQAZwsx" shutdown
查看当前服务状态:
------------------------------------------------------------------------------------------------------


1,设置auth密码?
http://www.runoob.com/redis/redis-security.html
密码为:jufaQAZwsx
命令为:
CONFIG set requirepass "jufaQAZwsx"

 

2:redis2.8和3.2区别是什么?

3:rdb和aof的区别?
转自:http://huangyunbin.iteye.com/blog/1894583

redis的持久化有rdb和aof两种。 
rdb是记录一段时间内的操作,一盘的配置是一段时间内操作超过多少次就持久化。 
aof可以实现每次操作都持久化。 
这里我们使用aof。

配置方式,打开redis的配置文件。找到appendonly。默认是appendonly no。改成appendonly yes。

再找到appendfsync 
默认是:

# appendfsync always #每次收到写命令就立即强制写入磁盘,最慢的,但是保证完全的持久化,不推荐使用 
appendfsync everysec #每秒钟强制写入磁盘一次,在性能和持久化方面做了很好的折中,推荐 
# appendfsync no #完全依赖os,性能最好,持久化没保证 
默认每秒持久化满足我的需求。 
其实改下appendonly 就ok了。


4:redis dump.rdb appendonly.aof 文件路径如何修改?
转自:http://blog.csdn.net/yangxujia/article/details/51010222
# The working directory.
#
# The DB will be written inside this directory, with the filename specified
# above using the 'dbfilename' configuration directive.
#
# The Append Only File will also be created inside this directory.
#
# Note that you must specify a directory here, not a file name.
dir ./

-------------------------
这里默认是启动后的相对路径也就是你的Redis在哪里启动,dump.rdb 文件或者appendonly.aof 
文件就会产生在启动所在的目录;
这也就是有些人重启后key值消失的原因,那是因为又产生了其他ump.rdb 文件或者appendonly.aof
这里建议改成绝对路径
dir /usr/local/redis/data/

posted on 2018-10-24 09:26  ziyi_ang  阅读(79)  评论(0)    收藏  举报

导航