Redis中设置开机自动启动
Redis在设置开机自动启动时需要配置Redis.service,网上的教程就是写入一段代码,但是我写入这段代码时报了下面的错:
localhost.localdomain systemd[1]: [/usr/lib/systemd/system/redis.service:4] Missing '='.
localhost.localdomain systemd[1]: [/usr/lib/systemd/system/redis.service:4] Missing '='.
localhost.localdomain systemd[1]: [/usr/lib/systemd/system/redis.service:2] Assignment outside of section. Ignoring.
localhost.localdomain systemd[1]: [/usr/lib/systemd/system/redis.service:3] Assignment outside of section. Ignoring.
localhost.localdomain systemd[1]: [/usr/lib/systemd/system/redis.service:4] Assignment outside of section. Ignoring.
localhost.localdomain systemd[1]: [/usr/lib/systemd/system/redis.service:9] Missing '='.
localhost.localdomain systemd[1]: [/usr/lib/systemd/system/redis.service:2] Assignment outside of section. Ignoring.
localhost.localdomain systemd[1]: [/usr/lib/systemd/system/redis.service:3] Assignment outside of section. Ignoring.
localhost.localdomain systemd[1]: [/usr/lib/systemd/system/redis.service:4] Assignment outside of section. Ignoring.
localhost.localdomain systemd[1]: [/usr/lib/systemd/system/redis.service:9] Missing '='.
如果修修改改,就变成下面的这个样子了:
[Unit]
Description = Redis Server
After = network.target
[Service]
ExecStart = /usr/local/redis/redis-5.0.3/src/redis-server /usr/local/redis/redis-5.0.3/redis.conf --daemonize no
ExecStop = /usr/local/redis/redis-5.0.3/src/redis-cli -p 6379 shutdown
Restart = always
[Install]
WantedBy = multi-user.target
和之前的代码相比,我是把等于号前后都空了一个格出来,代码上下行的空行删除。
然后就设置成功了,这个解决办法仅供大家参考,因为我也是半桶水。
附上修改前的代码:(我是按照博客名为最右303的博主的,地址:https://www.cnblogs.com/zy-303/p/10273167.html,大家也可以参考一下)
[Unit]
Description=Redis Server
After=network.target
[Service]
ExecStart=/usr/local/redis/redis-5.0.3/src/redis-server /usr/local/redis/redis-5.0.3/redis.conf --daemonize no
ExecStop=/usr/local/redis/redis-5.0.3/src/redis-cli -p 6379 shutdown
Restart=always
[Install]
WantedBy=multi-user.target