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天前
|
NoSQL Redis Docker
使用docker安装redis
该文档介绍了如何使用Docker快速搭建Redis数据库,以便于Spring Boot学习。主要内容包括获取Redis镜像、创建容器、配置持久化存储目录和修改默认配置文件,以及检查和访问Redis容器服务。此外,还提到若需外部访问,需开启宿主机防火墙相应端口。注意,本教程不深入讲解Docker,若想深入学习Docker,建议另寻专门课程。
|
3天前
|
NoSQL Redis
mac下安装redis
mac下安装redis
|
4天前
|
存储 关系型数据库 MySQL
linux安装MySQL8.0,密码修改权限配置等常规操作详解
linux安装MySQL8.0,密码修改权限配置等常规操作详解
|
5天前
|
存储 安全 数据管理
【专栏】如何在 Rocky Linux 8 上安装和配置 Elasticsearch
【4月更文挑战第28天】本文指导在Rocky Linux 8上安装配置Elasticsearch,包括添加仓库,运行`yum install elasticsearch`进行安装,修改配置文件如`cluster.name`和`network.host`,启动服务并验证其正常运行。同时,文章提及了内存、文件描述符设置及安全配置,并列出常见问题及解决方法,帮助用户成功搭建Elasticsearch。
|
5天前
|
Linux 网络安全 Docker
【Linux】-docker配置容器并打包成镜像
【Linux】-docker配置容器并打包成镜像
|
5天前
|
网络协议 Linux 开发工具
|
7天前
|
监控 关系型数据库 MySQL
|
6月前
|
Linux Shell Docker
|
12月前
|
Linux Shell 网络安全
Linux 系统启动过程
Linux 系统启动过程
91 0
|
Linux
Linux 系统启动过程
Linux 系统启动过程
104 0