当前位置:   article > 正文

E212: 无法打开并写入文件_/etc/hosts" e212: 无法打开并写入文件

/etc/hosts" e212: 无法打开并写入文件

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

E212: 无法打开并写入文件
  • 1
vi /etc/systemd/system/redis.service
  • 1
[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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

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

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

在这里插入图片描述

Loaded: loaded (/etc/systemd/system/redis.service; disabled; vendor preset: disabled)
  • 1
[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 ~]# 

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35

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

kill -9  pid
  • 1
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/不正经/article/detail/65764?site
推荐阅读
相关标签
  

闽ICP备14008679号