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

本文涉及的产品
云数据库 Redis 版,社区版 2GB
推荐场景:
搭建游戏排行榜
简介: 一、今天有个同学问我,为什么明明安装了redis,修改了配置,启动的时候,配置还是不生效。如下图是安装后的redis文件图。root@iZbp17cj14ulhfrlj02rkaZ:~/redis-4.

一、今天有个同学问我,为什么明明安装了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

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

相关实践学习
基于Redis实现在线游戏积分排行榜
本场景将介绍如何基于Redis数据库实现在线游戏中的游戏玩家积分排行榜功能。
云数据库 Redis 版使用教程
云数据库Redis版是兼容Redis协议标准的、提供持久化的内存数据库服务,基于高可靠双机热备架构及可无缝扩展的集群架构,满足高读写性能场景及容量需弹性变配的业务需求。 产品详情:https://www.aliyun.com/product/kvstore     ------------------------------------------------------------------------- 阿里云数据库体验:数据库上云实战 开发者云会免费提供一台带自建MySQL的源数据库 ECS 实例和一台目标数据库 RDS实例。跟着指引,您可以一步步实现将ECS自建数据库迁移到目标数据库RDS。 点击下方链接,领取免费ECS&RDS资源,30分钟完成数据库上云实战!https://developer.aliyun.com/adc/scenario/51eefbd1894e42f6bb9acacadd3f9121?spm=a2c6h.13788135.J_3257954370.9.4ba85f24utseFl
目录
相关文章
|
3天前
|
Ubuntu Linux 编译器
【Linux】详解动静态库的制作和使用&&动静态库在系统中的配置步骤
【Linux】详解动静态库的制作和使用&&动静态库在系统中的配置步骤
|
1天前
|
IDE Linux 开发工具
Linux 系统上安装
在Linux和Mac上安装Lua 5.3.0只需下载源码,解压,编译和安装。Windows用户可选择SciTE IDE或通过LuaForWindows在Github或Google Code下载安装。创建 HelloWorld.lua,使用`lua HelloWorld.lua`运行显示"Hello World!"。另可参考LuaDist官方推荐方式安装。
|
3天前
|
Oracle 关系型数据库 Linux
SuSE linux server 11通过SAP来安装oracle11g
SuSE linux server 11通过SAP来安装oracle11g
|
3天前
|
Linux C语言
suse linux 11 安装GCC开发环境
suse linux 11 安装GCC开发环境
|
5天前
|
关系型数据库 MySQL Linux
在Linux系统上实现高效安装与部署环境的全方位指南
在Linux系统上实现高效安装与部署环境的全方位指南
|
5天前
|
NoSQL Linux Redis
Redis的介绍,以及Redis的安装(本机windows版,虚拟机Linux版)和Redis常用命令的介绍
Redis的介绍,以及Redis的安装(本机windows版,虚拟机Linux版)和Redis常用命令的介绍
18 0
|
1月前
|
存储 NoSQL 算法
09- Redis分片集群中数据是怎么存储和读取的 ?
Redis分片集群使用哈希槽分区算法,包含16384个槽(0-16383)。数据存储时,通过CRC16算法对key计算并模16383,确定槽位,进而分配至对应节点。读取时,根据槽位找到相应节点直接操作。
68 12
|
3天前
|
存储 监控 NoSQL
Redis哨兵&分片集群
Redis哨兵&分片集群
7 0
|
4天前
|
NoSQL 算法 Java
深入浅出Redis(八):Redis的集群模式
深入浅出Redis(八):Redis的集群模式