Linux安装redis,启动配置不生效(指定启动加载配置文件)

一、今天有个同学问我,为什么明明安装了redis,修改了配置,启动的时候,配置还是不生效。如下图是安装后的redis文件图。

root@iZbp17cj14ulhfrlj02rkaZ:~/redis-4.0.9# ls
00-RELEASENOTES  COPYING    Makefile   redis.conf       runtest-sentinel  tests
BUGS             INSTALL    README.md  runtest          sentinel.conf     utils
CONTRIBUTING     MANIFESTO  deps       runtest-cluster  src
root@iZbp17cj14ulhfrlj02rkaZ:~/redis-4.0.9#

二、想加载上图中的redis.conf,进入到src中寻找到启动文件redis-server

root@iZbp17cj14ulhfrlj02rkaZ:~/redis-4.0.9/src# ls
Makefile      endianconv.c      pqsort.h           sentinel.o
adlist.c      endianconv.h      pqsort.o           server.c
adlist.h      endianconv.o      pubsub.c           server.h
adlist.o      evict.c           pubsub.o           server.o
ae.c          evict.o           quicklist.c        setproctitle.c
ae.h          expire.c          quicklist.h        setproctitle.o
ae.o          expire.o          quicklist.o        sha1.c
ae_epoll.c    fmacros.h         rand.c             sha1.h
ae_evport.c   geo.c             rand.h             sha1.o
ae_kqueue.c   geo.h             rand.o             siphash.c
ae_select.c   geo.o             rax.c              siphash.o
anet.c        geohash.c         rax.h              slowlog.c
anet.h        geohash.h         rax.o              slowlog.h
anet.o        geohash.o         rax_malloc.h       slowlog.o
aof.c         geohash_helper.c  rdb.c              solarisfixes.h
aof.o         geohash_helper.h  rdb.h              sort.c
asciilogo.h   geohash_helper.o  rdb.o              sort.o
atomicvar.h   help.h            redis-benchmark    sparkline.c
bio.c         hyperloglog.c     redis-benchmark.c  sparkline.h
bio.h         hyperloglog.o     redis-benchmark.o  sparkline.o
bio.o         intset.c          redis-check-aof    syncio.c
bitops.c      intset.h          redis-check-aof.c  syncio.o
bitops.o      intset.o          redis-check-aof.o  t_hash.c
blocked.c     latency.c         redis-check-rdb    t_hash.o
blocked.o     latency.h         redis-check-rdb.c  t_list.c
childinfo.c   latency.o         redis-check-rdb.o  t_list.o
childinfo.o   lazyfree.c        redis-cli          t_set.c
cluster.c     lazyfree.o        redis-cli.c        t_set.o
cluster.h     lzf.h             redis-cli.o        t_string.c
cluster.o     lzfP.h            redis-sentinel     t_string.o
config.c      lzf_c.c           redis-server       t_zset.c
config.h      lzf_c.o           redis-trib.rb      t_zset.o
config.o      lzf_d.c           redisassert.h      testhelp.h
crc16.c       lzf_d.o           redismodule.h      util.c
crc16.o       memtest.c         release.c          util.h
crc64.c       memtest.o         release.h          util.o
crc64.h       mkreleasehdr.sh   release.o          valgrind.sup
crc64.o       module.c          replication.c      version.h
db.c          module.o          replication.o      ziplist.c
db.o          modules           rio.c              ziplist.h
debug.c       multi.c           rio.h              ziplist.o
debug.o       multi.o           rio.o              zipmap.c
debugmacro.h  networking.c      scripting.c        zipmap.h
defrag.c      networking.o      scripting.o        zipmap.o
defrag.o      notify.c          sds.c              zmalloc.c
dict.c        notify.o          sds.h              zmalloc.h
dict.h        object.c          sds.o              zmalloc.o
dict.o        object.o          sdsalloc.h
dump.rdb      pqsort.c          sentinel.c

三、启动时指定加载的配置文件

root@iZbp17cj14ulhfrlj02rkaZ:~/redis-4.0.9/src# ./redis-server /root/redis-4.0.9/redis.conf
4384:C 14 Apr 23:35:14.742 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
4384:C 14 Apr 23:35:14.742 # Redis version=4.0.9, bits=64, commit=00000000, modified=0, pid=4384, just started
4384:C 14 Apr 23:35:14.742 # Configuration loaded
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 4.0.9 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 4384
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

4384:M 14 Apr 23:35:14.744 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
4384:M 14 Apr 23:35:14.744 # Server initialized
4384:M 14 Apr 23:35:14.744 # 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.
4384:M 14 Apr 23:35:14.744 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
4384:M 14 Apr 23:35:14.744 * DB loaded from disk: 0.000 seconds
4384:M 14 Apr 23:35:14.744 * Ready to accept connections

四、如下图所示,加载的配置文件,你修改的信息均会生效。

上一篇:Linux安装阿里云命令行工具 CLI(Alibaba Cloud CLI)


下一篇:webpack配置