1、 Redis下载
1) 文件下载
Redis 官方下载地址,下载最新版redis-2.6.14.tar.gz
2) 命令行下载cd ~/Downloads/tool-server/
wgethttp://redis.googlecode.com/files/redis-2.6.13.tar.gz
tar-zxvfredis-2.6.13.tar.gz
cdredis-2.6.13
make
sudomakeinstall
2、默认安装
2.1 redis.conf
redis.conf 默认配置,安装到目录:/etc/redis/6379.conf
2.2、redis日志
redis默认日志路径:/var/log/redis_6379.log
redis默认数据库文件路径:/var/lib/redis/6379/dump.rdb
2.3、 redis命令
redis命令默认目录:/usr/local/bin/
homer2@ubuntu:/opt/redis-2.6.13$ ls -l /usr/local/bin/
total 8440
-rwxrwxr-x 1 homer2 homer2 2224542 Jul 3 12:45 redis-benchmark
-rwxrwxr-x 1 homer2 homer2 30547 Jul 3 12:45 redis-check-aof
-rwxrwxr-x 1 homer2 homer2 63515 Jul 3 12:45 redis-check-dump
-rwxrwxr-x 1 homer2 homer2 2326503 Jul 3 12:45 redis-cli
-rwxrwxr-x 1 homer2 homer2 3985830 Jul 3 12:45 redis-server
2.4 启动redis
sudo redis-server /etc/redis/6379.conf &
3、新增redis用户
3.1、 配置init脚本:wgethttps://github.com/ijonas/dotfiles/raw/master/etc/init.d/redis-server
wgethttps://github.com/ijonas/dotfiles/raw/master/etc/redis.conf
sudomvredis-server/etc/init.d/redis-server
sudochmod+x/etc/init.d/redis-server
sudomvredis.conf/etc/redis.conf
3.2、 初始化用户和日志路径
第一次启动Redis前,建议为Redis单独建立一个用户,并新建data和日志文件夹sudouseraddredis
sudomkdir-p/var/lib/redis
sudomkdir-p/var/log/redis
sudochownredis.redis/var/lib/redis
sudochownredis.redis/var/log/redis
注:redis 为新增用户,也可以使用当前系统默认用户(例如:homer),则需修改sudochownhomer.redis/var/lib/redis
3.3、 设置开机自动启动,关机自动关闭update-rc.dredis-serverdefaults
3.4、 启动Redis:/etc/init.d/redis-serverstart
6、 启动client客户端连接
$ redis-cli
redis> set foo bar
OK
redis> get foo
"bar"
7、关闭redis
redis-cli shutdown
参考推荐:
Redis 教程(官方)