redis如何启动
redis的三种启动方式
1.直接启动
进入redis根目录,执行命令:
#加上‘&’号使redis以后台程序方式运行./redis-server &2.通过指定配置文件启动(redis教程)
可以为redis服务启动指定配置文件,例如配置为/etc/redis/6379.conf
进入redis根目录,输入命令:./redis-server /etc/redis/6379.conf#如果更改了端口,使用`redis-cli`客户端连接时,也需要指定端口,例如:redis-cli -p 63803.使用redis启动脚本设置开机自启动
启动脚本 redis_init_script 位于位于Redis的 /utils/ 目录下,redis_init_script脚本代码如下:#!/bin/sh## Simple Redis init.d script conceived to work on Linux systems# as it does use of the /proc filesystem. #redis服务器监听的端口REDISPORT=6379 #服务端所处位置EXEC=/usr/local/bin/redis-server #客户端位置CLIEXEC=/usr/local/bin/redis-cli #redis的PID文件位置,需要修改PIDFILE=/var/run/redis_${REDISPORT}.pid #redis的配置文件位置,需将${REDISPORT}修改为文件名CONF="/etc/redis/${REDISPORT}.conf" case "$1" instart)if [ -f $PIDFILE ]thenecho "$PIDFILE exists, process is already running or crashed"elseecho "Starting Redis server..."$EXEC $CONFfi;;stop)if [ ! -f $PIDFILE ]thenecho "$PIDFILE does not exist, process is not running"elsePID=$(cat $PIDFILE)echo "Stopping ..."$CLIEXEC -p $REDISPORT shutdownwhile [ -x /proc/${PID} ]doecho "Waiting for Redis to shutdown ..."sleep 1doneecho "Redis stopped"fi;;*)echo "Please use start or stop as first argument";;esac以上就是redis如何启动的详细内容,更多请关注小潘博客其它相关文章!