码迷,mamicode.com
首页 > 其他好文 > 详细

Redis 之 安装步骤

时间:2018-08-13 17:02:41      阅读:142      评论:0      收藏:0      [点我收藏+]

标签:服务启动   priority   repos   mit   start   51cto   使用   init   永久   

一、Redis yum安装方法

1、根据操作系统,下载相应的epel源

epel(RHEL 7)
    wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
epel(RHEL 6)
    wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
epel(RHEL 5)
    wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-5.repo

2、查看epel源是否存在

[root@localhost ~]# ll /etc/yum.repos.d/
总用量 32
drwxr-xr-x  2 root root 4096 7月  31 22:57 bak
-rw-r--r--. 1 root root 1991 3月  28 2017 CentOS-Base.repo
-rw-r--r--. 1 root root  647 3月  28 2017 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  289 3月  28 2017 CentOS-fasttrack.repo
-rw-r--r--. 1 root root  630 3月  28 2017 CentOS-Media.repo
-rw-r--r--. 1 root root 7989 3月  28 2017 CentOS-Vault.repo
-rw-r--r--  1 root root  664 5月  11 11:34 epel.repo

3、通过外部源安装redis

[root@localhost ~]# yum -y install redis        安装方法
[root@localhost ~]# rpm -ql redis
/etc/logrotate.d/redis
/etc/rc.d/init.d/redis        #redis服务启动文件
/etc/rc.d/init.d/redis-sentinel      #redis哨兵启动文件
/etc/redis-sentinel.conf              #redis哨兵配置文件
/etc/redis.conf          #配置文件
/etc/security/limits.d/95-redis.conf
/usr/bin/redis-benchmark
/usr/bin/redis-check-aof
/usr/bin/redis-check-rdb
/usr/bin/redis-cli               #redis客户端
/usr/bin/redis-sentinel      #redis哨声
/usr/bin/redis-server        #redis-server服务
/usr/libexec/redis-shutdown
/var/lib/redis
/var/log/redis     #日志存放路径
/var/run/redis     #redis_pid 存放路径

4、redis 配置文件理解

[root@localhost ~]# cat /etc/redis.conf | grep -v ‘#‘ | grep -v ‘^$‘
bind 127.0.0.1          #绑定本机可访问,可修改为本机的IP地址,或0.0.0.0
protected-mode yes
port 6379                 #redis 启动端口
tcp-backlog 511 
timeout 0                 #会话连接保持时间,0为不限制
tcp-keepalive 300
daemonize no        #是否后台运行,应设置为yes
supervised no
pidfile /var/run/redis_6379.pid     #redis_pid存放位置
loglevel notice                              #日志等级
logfile /var/log/redis/redis.log      #日专存放路径
databases 16                               #总共有17个数据库
save 900 1                                   #900秒 有一个key变化,即把内存数据写入dump.rdb文件
save 300 10                                 #300秒 有10个key变化,即把内存数据写入dump.rdb文件
save 60 10000                             #60秒有1万个key变化,即把内存数据写入dump.rdb文件
stop-writes-on-bgsave-error yes
rdbcompression yes                   #启用压缩 
rdbchecksum yes     
dbfilename dump.rdb                 #rdb文件名
dir /var/lib/redis                           #指定rdb的存放路径
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
slave-priority 100
appendonly no                        #是否开启aof,永久持久化
appendfilename "appendonly.aof"         #aof的文件名
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes

5、redis 的启动与停止方法

[root@localhost ~]# service redis start
启动 :[确定]
[root@localhost ~]# service redis stop

6、redis 简单使用方法

[root@localhost ~]# redis-cli      #客户端连接
127.0.0.1:6379> keys *              #查看现在所有的key
(empty list or set)
127.0.0.1:6379> set mykey aa   #设置一个mykey的key,值为aa
OK
127.0.0.1:6379> get mykey        #读取mykey的key 的值 
"aa"
127.0.0.1:6379> 
127.0.0.1:6379> info 查看redis的详细信息

二、编译安装redis方法

http://blog.51cto.com/12965094/2129325

Redis 之 安装步骤

标签:服务启动   priority   repos   mit   start   51cto   使用   init   永久   

原文地址:http://blog.51cto.com/12965094/2159119

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!