docker的fence是通过docker服务端的api来关闭container的.
目前fence docker还没有加到epel库中, 所以在centos或rhel中使用, 需要从src编译.
wget https://kojipkgs.fedoraproject.org//packages/fence-agents/4.0.11/1.fc20/src/fence-agents-4.0.11-1.fc20.src.rpm
rpm -ivh fence-agents-4.0.11-1.fc20.src.rpm
[root@150 soft_bak]# cd ~/rpmbuild/SOURCES/
[root@150 SOURCES]# ll
total 2904
-rw-rw-r--. 1 root root  605312 Aug 27 22:04 fence-agents-4.0.11.tar.xz
[root@150 SOURCES]# tar -xvf fence-agents-4.0.11.tar.xz
[root@150 SOURCES]# cd fence-agents-4.0.11
# yum install -y libtool
# ./configure ; make ; make install[root@150 fence-agents-4.0.11]# cd fence/agents/docker/
[root@150 docker]# ll
total 68
-r-x------ 1 root root  4608 Sep 29 15:12 fence_docker
-rw-r--r-- 1 root root  4774 Sep 29 15:12 fence_docker.8
-rw-rw-r-- 1 1000 1000  4517 Aug  6 15:35 fence_docker.py
-rw-r--r-- 1 root root 19126 Sep 29 15:12 Makefile
-rw-rw-r-- 1 1000 1000   354 Aug  6 15:35 Makefile.am
-rw-r--r-- 1 root root 18002 Sep 29 15:12 Makefile.in

还依赖fence common, 所以暂时不能使用. 可以了解一下先 :

[root@150 docker]# ./fence_docker --help
Usage:fence_docker [options]
Options:-a, --ip=[ip]                  IP address or hostname of fencing device-n, --plug=[id]                Physical plug number on device, UUID oridentification of machine-m, --method=[method]          Method to fence (onoff|cycle) (Default: onoff)-z, --ssl                      Use ssl connection-u, --ipport=[port]            TCP/UDP port to use(default 80, 443 if --ssl option is used)-4, --inet4-only               Forces agent to use IPv4 addresses only-6, --inet6-only               Forces agent to use IPv6 addresses only-o, --action=[action]          Action: status, reboot (default), off or on--tlscert                      Path to client certificate for TLS authentication--tlskey                       Path to client key for TLS authentication--tlscacert                    Path to CA certificate for TLS authentication-v, --verbose                  Verbose mode-D, --debug-file=[debugfile]   Debugging to output file-V, --version                  Output version information and exit-h, --help                     Display this help and exit-C, --separator=[char]         Separator for CSV created by 'list' operation--power-timeout=[seconds]      Test X seconds for status change after ON/OFF--shell-timeout=[seconds]      Wait X seconds for cmd prompt after issuing command--login-timeout=[seconds]      Wait X seconds for cmd prompt after login--power-wait=[seconds]         Wait X seconds after issuing ON/OFF--delay=[seconds]              Wait X seconds before fencing is started--retry-on=[attempts]          Count of attempts to retry power on

帮助文档 :

[root@150 docker]# man ./fence_docker.8
FENCE_AGENT(8)                                                  FENCE_AGENT(8)NAMEfence_docker - Fence agent for DockerDESCRIPTIONfence_docker  is I/O fencing agent which can be used with the Docker Engine containers. You can use this fence-agent without any authentication, or you can use TLS authentication (use --ssl  option,  more  info  about  TLSauthentication in docker: http://docs.docker.com/examples/https/).fence_docker  accepts  options on the command line as well as from stdin. Fenced sends parameters through stdinwhen it execs the agent. fence_docker can be run by itself with command line options.  This is useful for test-ing and for turning outlets on or off from scripts.Vendor URL: www.docker.ioPARAMETERS-u, --ipport=[port]TCP/UDP port to use for connection with device (Default Value: 80)-n, --plug=[id]Physical plug number, name of virtual machine or UUID This parameter is always required.-6, --inet6-onlyForces agent to use IPv6 addresses only-a, --ip=[ip]IP Address or Hostname This parameter is always required.-4, --inet4-onlyForces agent to use IPv4 addresses only-m, --method=[method]Method to fence (onoff|cycle) (Default Value: onoff)-z, --sslSSL connection-o, --action=[action]Fencing Action (Default Value: reboot)--tlskeyPath to client key (PEM format) for TLS authentication. Required if --ssl option is used.--tlscacertPath to CA certificate (PEM format) for TLS authentication. Required if --ssl option is used.--tlscertPath to client certificate (PEM format) for TLS authentication. Required if --ssl option is used.-v, --verboseVerbose mode-D, --debug-file=[debugfile]Write debug information to given file-V, --versionDisplay version information and exit-h, --helpDisplay help and exit-C, --separator=[char]Separator for CSV created by operation list (Default Value: ,)--power-wait=[seconds]Wait X seconds after issuing ON/OFF (Default Value: 0)--power-timeout=[seconds]Test X seconds for status change after ON/OFF (Default Value: 20)--delay=[seconds]Wait X seconds before fencing is started (Default Value: 0)--login-timeout=[seconds]Wait X seconds for cmd prompt after login (Default Value: 5)--shell-timeout=[seconds]Wait X seconds for cmd prompt after issuing command (Default Value: 3)--retry-on=[attempts]Count of attempts to retry power on (Default Value: 1)ACTIONSon     Power on machine.off    Power off machine.reboot Reboot machine.status This returns the status of the plug/virtual machine.list   List available plugs with aliases/virtual machines if there is support for more then one device. ReturnsN/A otherwise.monitorCheck the health of fence devicemetadataDisplay the XML metadata describing this resource.STDIN PARAMETERSipport TCP/UDP port to use for connection with device (Default Value: 80)port   Physical plug number, name of virtual machine or UUID This parameter is always required.inet6_onlyForces agent to use IPv6 addresses onlyipaddr IP Address or Hostname This parameter is always required.inet4_onlyForces agent to use IPv4 addresses onlymethod Method to fence (onoff|cycle) (Default Value: onoff)ssl    SSL connectionaction Fencing Action (Default Value: reboot)tlskey Path to client key (PEM format) for TLS authentication. Required if --ssl option is used.tlscacertPath to CA certificate (PEM format) for TLS authentication. Required if --ssl option is used.tlscertPath to client certificate (PEM format) for TLS authentication. Required if --ssl option is used.verboseVerbose modedebug  Write debug information to given fileversionDisplay version information and exithelp   Display help and exitseparatorSeparator for CSV created by operation list (Default Value: ,)power_waitWait X seconds after issuing ON/OFF (Default Value: 0)power_timeoutTest X seconds for status change after ON/OFF (Default Value: 20)delay  Wait X seconds before fencing is started (Default Value: 0)login_timeoutWait X seconds for cmd prompt after login (Default Value: 5)shell_timeoutWait X seconds for cmd prompt after issuing command (Default Value: 3)retry_onCount of attempts to retry power on (Default Value: 1)fence_docker (Fence Agent)        2009-10-20                    FENCE_AGENT(8)

[参考]

1. https://apps.fedoraproject.org/packages/fence-agents

Docker fence相关推荐

  1. /var/lib/docker/overlay2/xxxxx no such file or directory docker文件删除引发的问题

    记一次误删引发的服务雪崩 K8s node节点磁盘报警,报警后我找到服务中占用磁盘最多的地方,在overlay2目录下,对下面的文件进行了删除   删除后,有状态服务先出现了问题,服务无法启动.停止. ...

  2. 本地打包Docker镜像上传至阿里云远程仓库(一站式脚本)

    打包镜像上传至远程仓库: 1. 本地项目为 mytest-project 2. 仓库为阿里云镜像仓库 registry.cn-beijing.aliyuncs.com/test/mytest-proj ...

  3. docker报错:driver failed programming external connectivity on endpoint, iptables:No chain by that name

    docker 报错: Error response from daemon: Cannot restart container hello: driver failed programming ext ...

  4. Docker容器的备份与恢复,Docker镜像的备份与恢复

    1. 备份容器 首先,为了备份Docker中的容器,我们会想看看我们想要备份的容器列表.要达成该目的,我们需要在我们运行着Docker引擎,并已创建了容器的Linux机器中运行 docker ps 命 ...

  5. docker安装kafka消息队列

    1. 启动zookeeper容器(Zookeeper用于崩溃检测,实现Topic发现,和维护Topic的生产和消费状态) docker run -d --name zookeeper -p 2181: ...

  6. 设置普通用户执行docker命令,执行docker命令无需输入密码或者切换root用户

    每次执行docker命令都要输入密码或者切换root用户,非常不方便,尤其是在shell脚本中就更麻烦了,一起来解决这个问题: 1. 创建名为docker的组,如果之前已经有该组就会提示已存在: su ...

  7. docker :open /var/lib/docker/tmp/GetImageBlob318829910: no such file or directory异常解决

    千万不要直接去重装docker,不要删除镜像,不要手动创建目录和文件,只需要这样就好了!

  8. 将jar包部署在docker上,将jar包打成镜像,使用docker部署jar包

    假设你已经准备好以下东西,即可进行服务部署 一台安装好docker的linux服务器(安装docker见安装docker) 准备好的jar包 接下来开始吧! 将jar包上传至服务器(建好文件夹存放以方 ...

  9. 使用rancher对Docker容器服务升级

    这是笔者以前使用到的一个docker管理工具--rancher 升级服务的步骤 记录一下,说不定有人需要或者以后能用上呢? 1.打包好后上传服务器,编写Dockerfile FROM jdk8apli ...

最新文章

  1. 《评人工智能如何走向新阶段》后记(再续8)
  2. java ftp 关闭连接_java - 使用Java Apache FTPClient进行FTP TLS获取“握手时远程主机关闭连接”[重复] - 堆栈内存溢出...
  3. 简单的脚本控制面试题
  4. Swift3.0P1 语法指南——枚举
  5. XSpreadsheet-在线表格插件
  6. 【Android】Android--Dialog
  7. 批量下载CSS中的图片
  8. 理解物理 CPU 与逻辑 CPU
  9. bigDecimal学习笔记_隋小白
  10. 花青素近红外荧光染料Cyanine5 hydrazide,Cy5 hydrazide,1427705-31-4深蓝色粉末状
  11. 内存管理参数zone_reclaim_mode分析
  12. 会声会影2023中文旗舰版新增功能讲解及下载更新教程
  13. 您可能不知道WooCommerce可以做的10件事
  14. 每个程序员都应该知道的福利
  15. 前端 环形统计_10款jQuery实现的环形百分比图表插件
  16. 高中生可以学习编程吗?
  17. 当B站“不再二次元”,破圈易,盈利难!
  18. html css动画自动旋转,html – 使这个CSS3动画旋转只旋转一次
  19. Google Glass 初体验
  20. 20145312 《信息安全系统设计基础》期中总结

热门文章

  1. python——画一个笑脸
  2. Python基础——for/while循环
  3. Intellij IDEA 快捷键整理
  4. codevs 1227 方格取数 2
  5. python学习笔记:easygui的简单示例
  6. QTableView和QTableWidget翻页功能实现
  7. STL: set相关算法
  8. 【.NET程序性能分析】使用VS自带的工具分析.NET程序的性能
  9. 网站基于文本搜索的实现
  10. [导入]利用PIL生成水印图片或文字