Redis服务器的启动和停止使用脚本或服务命令
Redis是一种内存存储(in-memory)数据结构存储,可以用做数据库、Cache和消息队列
使用Redis内置的配置进行启动命令:redis-server &
image看看启动情况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.62403: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 seconds2403:M 08 Apr 19:34:32.506 * The server is now ready to accept connections on port 6379
image如果需要指定监听端口呢命令:redis-server --port 8888 &
image使用脚本启动将redis源代码下的文件utils/redis_init_script改名为redis_6380然后将redis_6380复制到/etc/init.d/目录来看下redis_init_script来内容REDISPORT=6379EXEC=/usr/local/bin/redis-serverCLIEXEC=/usr/local/bin/redis-cliPIDFILE=/var/run/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
image启动redis服务器命令:/etc/init.d/redis_6380 start&
image如果觉得使用脚本启动比较麻烦,则可以这样实现上面的脚本启动命令:redis-server /etc/redis/6380.conf
查看一下启动的Redis实例命令:ps -ef|grep redis
image如何停止Redis服务器呢?脚本启动的的停止方式命令:/etc/init.d/redis_6380 stop
image如果不是使用脚本启动则需要使用redis-cli shutdown命令来停止命令:redis-cli -p 8888 shutdownredis-cli -p 6379 shutdown
image