Redis服务器的启动和停止(redis如何启动服务器)

2023-08-21 18:00:46 趣味生活 0 阅读 投稿:villain
最佳答案 使用Redis内置的配置进行启动命令:redis-server &看看启动情况Output:2403:M 08 Apr 19:34:32.505 # WARNING: The TCP backlog setting of 511 cann

 使用Redis内置的配置进行启动

命令:

redis-server &

Redis服务器的启动和停止(redis如何启动服务器)[图]

看看启动情况

Output:

2403:M 08 Apr 19:34:32.505 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.

2403:M 08 Apr 19:34:32.506 # Server started, Redis version 3.0.6

2403:M 08 Apr 19:34:32.506 # 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.

2403:M 08 Apr 19:34:32.506 * DB loaded from disk: 0.000 seconds

2403:M 08 Apr 19:34:32.506 * The server is now ready to accept connections on port 6379

Redis服务器的启动和停止(redis如何启动服务器)[图]

如果需要指定监听端口呢

命令:

redis-server --port 8888 &

Redis服务器的启动和停止(redis如何启动服务器)[图]

使用脚本启动

将redis源代码下的文件utils/redis_init_script改名为redis_6380

然后将redis_6380复制到/etc/init.d/目录

来看下redis_init_script来内容

REDISPORT=6379

EXEC=/usr/local/bin/redis-server

CLIEXEC=/usr/local/bin/redis-cli

PIDFILE=/var/run/redis_${REDISPORT}.pid

CONF="/etc/redis/${REDISPORT}.conf"

因为redis_6380文件的名字中的端口号是6380,

REDISPORT=6379改为REDISPORT=6380

创建两个文件夹:

/var/run/

/etc/redis/

将redis源码目录下的redis.conf文件copy到/etc/redis目录,

然后改名为6380.conf

将port后面的端口号6379改为6380

Redis服务器的启动和停止(redis如何启动服务器)[图]

启动redis服务器

命令:

/etc/init.d/redis_6380 start&

Redis服务器的启动和停止(redis如何启动服务器)[图]

如果觉得使用脚本启动比较麻烦,则可以这样实现上面的脚本启动

命令:

redis-server  /etc/redis/6380.conf


查看一下启动的Redis实例

命令:

ps -ef|grep redis

Redis服务器的启动和停止(redis如何启动服务器)[图]

如何停止Redis服务器呢?

脚本启动的的停止方式

命令:

/etc/init.d/redis_6380 stop

Redis服务器的启动和停止(redis如何启动服务器)[图]
声明:百科巴巴知识网所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系 1004619@qq.com
--