
# 如何卸载网关软件安装包？
网关软件包安装包安装成功后，CSG支持卸载已安装网关软件。
#### 操作步骤
1. 以root用户或csgmanager用户，登录本地安装网关软件包的服务器。 
   ![](https://support.huaweicloud.com/csg_faq/public_sys-resources/note_3.0-zh-cn.png)
   如果在安装阶段执行了安全加固命令"security_reinforce.sh"，将无法使用root账号通过ssh登录服务器。如果需继续卸载网关软件包，先使用csgmanager账号通过ssh登录服务器，执行命令"su root"，通过密码认证切换到root用户，再进行卸载操作。
   
   
2. 进入安装包action目录，执行以下命令。 
   ```
   sh appctl.sh uninstall
   ```
   - 如果网关未激活使用，回显如下信息，可直接完成卸载。
     ```
     # sh appctl.sh uninstall
     uninstall filegateway begin
     environment clear is over
     stop om success
     remove remain files start
     uninstall filegateway success
     uninstall filegateway successfully
     ```
     
   
   - 如果网关已经激活并使用，回显如下错误信息，需要执行下一步，删除网关信息和卸载网关软件。
     ```
     # sh appctl.sh uninstall
     uninstall filegateway begin
     Important process is still running, uninstall aborted!
     uninstall filegateway failed
     ```
     
   
   
   
   
3. 执行**sudo -u oam gwcli** 进入命令行模式。
   
   ```
   [root@localhost ~]# sudo -u oam gwcli
   **************************************************************************
    Usage:
    gwcli
    gwcli  ["cmd"]
    For example:
    gwcli
    gwcli  "show gateway"
    The CLI supports only characters in the ASCII format, and the command output supports both characters in the ASCII and UTF-8 formats.
   **************************************************************************
   gwcli:/>
   ```
   
   
4. 执行**stop gateway** 命令，停止正在运行的网关。
   
   ```
   gwcli:/>stop gateway
   files sync is completed. elaps time is 0 min
   Gateway 1 is stopped.
   ```
   
   
5. 执行**delete gateway** 命令，删除网关。
   
   ```
   gwcli:/>delete gateway
   DANGER: Delete gateway will delete all data in cache and delete all NFS server metadata.
   Have you read danger alert message carefully?(y/n) y
   Are you sure you want to perform the operation?(y/n) y
   Command executed successfully.
   ```
   
   
6. 执行**exit** 命令，退出命令行模式。
   
   ```
   gwcli:/>exit
   ```
   ![](https://support.huaweicloud.com/csg_faq/public_sys-resources/note_3.0-zh-cn.png)
   先执行exit命令，退出gwcli命令行模式，再执行卸载命令。
   
   
7. 执行以下命令，卸载网关软件。 
   ```
   sh appctl.sh uninstall
   ```
   回显如下信息，网关软件卸载成功。
   ```
   # sh appctl.sh uninstall
   uninstall filegateway begin
   environment clear is over
   stop om success
   remove remain files start
   uninstall filegateway success
   uninstall filegateway successfully
   ```
   
   
 
