E212: 无法打开并写入文件

利用vi配置redis自启文件的时候,无法进行保存

E212: 无法打开并写入文件
vi /etc/systemd/system/redis.service
[Unit]
Description=redis-server
After=network.target

[Service]
Type=forking
ExecStart=/usr/local/bin/redis-server /usr/local/redis-stable/redis.conf
PrivateTmp=true

[Install]
WantedBy=multi-user.target

利用sudo 提高权限后 ,就可以利用 wq进行保存

sudo vi /etc/systemd/system/redis.service

在这里插入图片描述

Loaded: loaded (/etc/systemd/system/redis.service; disabled; vendor preset: disabled)
[root@localhost-cs8 ~]# systemctl restart redis
[root@localhost-cs8 ~]# systemctl status redis
● redis.service - redis-server
   Loaded: loaded (/etc/systemd/system/redis.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Wed 2023-10-18 20:21:34 CST; 2s ago
  Process: 15992 ExecStart=/usr/local/bin/redis-server /usr/local/redis-stable/redis.conf (code=exited, status=0/SUCCESS)
 Main PID: 15993 (code=exited, status=1/FAILURE)

1018 20:21:34 localhost-cs8 systemd[1]: Starting redis-server...
1018 20:21:34 localhost-cs8 systemd[1]: Started redis-server.
1018 20:21:34 localhost-cs8 systemd[1]: redis.service: Main process exited, code=exited, status=1/FAILURE
1018 20:21:34 localhost-cs8 systemd[1]: redis.service: Failed with result 'exit-code'.
[root@localhost-cs8 ~]# ps -ef | grep redis
root       12304       1  0 18:36 ?        00:00:06 redis-server *:6379
root       16291   15905  0 20:29 pts/1    00:00:00 grep --color=auto redis
[root@localhost-cs8 ~]# kill -9 12304
[root@localhost-cs8 ~]# ps -ef | grep redis
root       16314   15905  0 20:29 pts/1    00:00:00 grep --color=auto redis
[root@localhost-cs8 ~]# systemctl restart redis
[root@localhost-cs8 ~]# systemctl restart redis
[root@localhost-cs8 ~]# systemctl status redis
● redis.service - redis-server
   Loaded: loaded (/etc/systemd/system/redis.service; disabled; vendor preset: disabled)
   Active: active (running) since Wed 2023-10-18 20:30:34 CST; 19s ago
  Process: 16352 ExecStart=/usr/local/bin/redis-server /usr/local/redis-stable/redis.conf (code=exited, status=0/SUCCESS)
 Main PID: 16353 (redis-server)
    Tasks: 6 (limit: 23373)
   Memory: 6.9M
   CGroup: /system.slice/redis.service
           └─16353 /usr/local/bin/redis-server 0.0.0.0:6379 x0

1018 20:30:34 localhost-cs8 systemd[1]: Starting redis-server...
1018 20:30:34 localhost-cs8 systemd[1]: Started redis-server.
[root@localhost-cs8 ~]# 

基于以前service文件的进程还没有消灭,需要手动消灭,重启redis.以前的:可以看到redis-server是默认的,因此我们消灭这个进程,kill -9 PID,重启redis,查看redis状态,成功!!

kill -9  pid

猜你喜欢

转载自blog.csdn.net/Klhz555/article/details/133913750
今日推荐