标签:filesyste script whereis 开机自启 启动 conf database 0.11 目录
设置条件:
在redis目录下找到 utils/redis_init_script 复制到 /etc/init.d/redis 打开文件进行修改
步骤:(主要Linux命令)
whereis redis # 查找redis目录 sudo cp redis_init_script /etc/init.d/redis # 复制文件 cd /etc/init.d/ # 进入文件目录 sudo vim redis # 编辑配置文件redis
1 #!/bin/sh 2 # 3 # Simple Redis init.d script conceived to work on Linux systems 4 # as it does use of the /proc filesystem. 5 ? 6 ### BEGIN INIT INFO 7 # Provides: redis_6379 8 # Default-Start: 2 3 4 5 9 # Default-Stop: 0 1 6 10 # Short-Description: Redis data structure server 11 # Description: Redis data structure server. See https://redis.io 12 ### END INIT INFO 13 ? 14 REDISPORT=6379 15 EXEC=/usr/local/bin/redis-server 16 CLIEXEC=/usr/local/bin/redis-cli 17 ? 18 PIDFILE=/var/run/redis_${REDISPORT}.pid 19 CONF="/etc/redis/${REDISPORT}.conf"
1 #!/bin/sh 2 # 3 # chkconfig: 2345 90 10 ---这里修改 4 # description: Redis is a persistent key-value database ---这里修改 5 ? 6 ### BEGIN INIT INFO 7 # Provides: redis_6379 8 # Required-Start: ---这里修改 9 # Required-Stop: ---这里修改 10 # Default-Start: 2 3 4 5 11 # Default-Stop: 0 1 6 12 # Short-Description: Redis data structure server 13 # Description: Redis data structure server. See https://redis.io 14 ### END INIT INFO 15 ? 16 REDISPORT=6379 17 EXEC=/usr/local/bin/redis-server 18 CLIEXEC=/usr/local/bin/redis-cli 19 ? 20 PIDFILE=/var/run/redis_${REDISPORT}.pid 21 CONF="/etc/redis/redis.conf" # ---这里修改
修改完配置文件后执行下面两条命令
sudo chmod +x /etc/init.d/redis # 取得权限 sudo update-rc.d redis defaults # 加载到系统自启动文件
测试命令:
kady@ubuntu:/etc/init.d$ sudo update-rc.d redis defaults kady@ubuntu:/etc/init.d$ service redis start # 启动redis服务 kady@ubuntu:/etc/init.d$ redis-cli 127.0.0.1:6379> # 设置成功
其他命令:
启动服务: service redis start 停止服务: service redis stop 重启服务: service redis restart
标签:filesyste script whereis 开机自启 启动 conf database 0.11 目录
原文地址:https://www.cnblogs.com/kadycui/p/9800951.html