redis 高级应用— 安全性

安装完成redis 后接触一下高级应用:

   /home/grid/redis*/ redis.conf  下

Redis高级应用


1. 安全性


2. 主从复制


3. 事物处理


4. 持久化机制


5. 发布订阅消息(用这个东西可以做一个消息系统)


6. 虚拟内存的使用

看一下第一 安全性
vi  redis.conf     找到 # requirepass foobared 在下面一行添加 requirepass  123456(密码)
因为打开的内容太多 所以用vi 查找命令  输入 /requirepass  foobared可以直接到改行
添加一行
 requirepass  123456

退出出来
[root@h1 redis-2.8.12]# cd src
[root@h1 src]# redis-cli shutdown
Could not connect to Redis at 127.0.0.1:6379: Connection refused
[root@h1 src]# ps -ef|grep redis
root     12404 12271  0 14:38 pts/2    00:00:00 grep redis
[root@h1 src]# redis-server /home/grid/redis-2.8.12/redis.conf
[12410] 15 Dec 14:39:47.267 * Increased maximum number of open files to 10032 (it was originally set to 1024).
                _._                                                 
           _.-``__ ''-._                                            
      _.-``    `.  `_.  ''-._           Redis 2.8.12 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                  
 (    '      ,       .-`  | `,    )     Running in stand alone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 12410
  `-._    `-._  `-./  _.-'    _.-'                                  
 |`-._`-._    `-.__.-'    _.-'_.-'|                                 
 |    `-._`-._        _.-'_.-'    |           http://redis.io       
  `-._    `-._`-.__.-'_.-'    _.-'                                  
 |`-._`-._    `-.__.-'    _.-'_.-'|                                 
 |    `-._`-._        _.-'_.-'    |                                 
  `-._    `-._`-.__.-'_.-'    _.-'                                  
      `-._    `-.__.-'    _.-'                                      
          `-._        _.-'                                          
              `-.__.-'                                              
[12410] 15 Dec 14:39:47.268 # Server started, Redis version 2.8.12
[12410] 15 Dec 14:39:47.268 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
[12410] 15 Dec 14:39:47.268 * DB loaded from disk: 0.000 seconds
[12410] 15 Dec 14:39:47.268 * The server is now ready to accept connections on port 6379

接下来切换客户端:
root@h1 ~]# cd /home/grid/redis-2.8.12
[root@h1 redis-2.8.12]# ls
00-RELEASENOTES  BUGS  CONTRIBUTING  COPYING  deps  INSTALL  Makefile  MANIFESTO  README  redis.conf  runtest  runtest-sentinel  sentinel.conf  src  tests  utils
[root@h1 redis-2.8.12]# cd src/
[root@h1 src]# ls
adlist.c     aof.c        crc64.o       help.h         Makefile.dep     object.o       redis-benchmark     redis.h         scripting.o     slowlog.o       t_string.c    zipmap.h
adlist.h     aof.o        db.c          hyperloglog.c  memtest.c        pqsort.c       redis-benchmark.c   redis.o         sds.c           solarisfixes.h  t_string.o    zipmap.o
adlist.o     asciilogo.h  db.o          hyperloglog.o  memtest.o        pqsort.h       redis-benchmark.o   redis-sentinel  sds.h           sort.c          t_zset.c      zmalloc.c
ae.c         bio.c        debug.c       intset.c       migrate.c        pqsort.o       redis.c             redis-server    sds.o           sort.o          t_zset.o      zmalloc.h
ae_epoll.c   bio.h        debug.o       intset.h       migrate.o        pubsub.c       redis-check-aof     release.c       sentinel.c      syncio.c        util.c        zmalloc.o
ae_evport.c  bio.o        dict.c        intset.o       mkreleasehdr.sh  pubsub.o       redis-check-aof.c   release.h       sentinel.o      syncio.o        util.h
ae.h         bitops.c     dict.h        lzf_c.c        multi.c          rand.c         redis-check-aof.o   release.o       setproctitle.c  testhelp.h      util.o
ae_kqueue.c  bitops.o     dict.o        lzf_c.o        multi.o          rand.h         redis-check-dump    replication.c   setproctitle.o  t_hash.c        valgrind.sup
ae.o         config.c     dump.rdb      lzf_d.c        networking.c     rand.o         redis-check-dump.c  replication.o   sha1.c          t_hash.o        version.h
ae_select.c  config.h     endianconv.c  lzf_d.o        networking.o     rdb.c          redis-check-dump.o  rio.c           sha1.h          t_list.c        ziplist.c
anet.c       config.o     endianconv.h  lzf.h          notify.c         rdb.h          redis-cli           rio.h           sha1.o          t_list.o        ziplist.h
anet.h       crc64.c      endianconv.o  lzfP.h         notify.o         rdb.o          redis-cli.c         rio.o           slowlog.c       t_set.c         ziplist.o
anet.o       crc64.h      fmacros.h     Makefile       object.c         redisassert.h  redis-cli.o         scripting.c     slowlog.h       t_set.o         zipmap.c
[root@h1 src]# redis-cli
127.0.0.1:6379> keys *
(error) NOAUTH Authentication required.
127.0.0.1:6379> auth ultrapower
(error) ERR invalid password
127.0.0.1:6379> auth  123456
OK
127.0.0.1:6379> keys*
(error) ERR unknown command 'keys*'
127.0.0.1:6379> keys *
1) "myzset"
2) "name"
3) "user:1"

密码配置成功


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值