Kubernetes/Docker/Docs/Mysql容器纳入System管理.md
offends 7a2f41e7d6
All checks were successful
continuous-integration/drone Build is passing
synchronization
2024-08-07 18:54:39 +08:00

656 B

本文作者:丁辉

Mysql容器纳入System管理

  1. 创建 Systemd Service 文件

    vi /usr/lib/systemd/system/mysql.service
    

    内容如下

    [Unit]
    Description=Mysql container
    Requires=docker.service
    After=docker.service
    [Service]
    RemainAfterExit=yes
    ExecStop=/usr/bin/docker stop mysql # 容器名
    ExecStart=/usr/bin/docker start mysql
    ExecReload=/usr/bin/docker restart mysql
    Restart=on-abnormal
    [Install]
    WantedBy=multi-user.target
    
  2. 重载配置文件

    systemctl daemon-reload
    
  3. 启动 Mysql

    systemctl start mysql