Docker fence

简介:
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 or
                                        identification 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)

NAME
       fence_docker - Fence agent for Docker

DESCRIPTION
       fence_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  TLS
       authentication 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 stdin
       when 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.io

PARAMETERS

       -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-only
              Forces agent to use IPv6 addresses only

       -a, --ip=[ip]
              IP Address or Hostname This parameter is always required.

       -4, --inet4-only
              Forces agent to use IPv4 addresses only

       -m, --method=[method]
              Method to fence (onoff|cycle) (Default Value: onoff)

       -z, --ssl
              SSL connection

       -o, --action=[action]
              Fencing Action (Default Value: reboot)

       --tlskey
              Path to client key (PEM format) for TLS authentication. Required if --ssl option is used.

       --tlscacert
              Path to CA certificate (PEM format) for TLS authentication. Required if --ssl option is used.

       --tlscert
              Path to client certificate (PEM format) for TLS authentication. Required if --ssl option is used.

       -v, --verbose
              Verbose mode

       -D, --debug-file=[debugfile]
              Write debug information to given file

       -V, --version
              Display version information and exit

       -h, --help
              Display 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)

ACTIONS

       on     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. Returns
              N/A otherwise.

       monitor
              Check the health of fence device

       metadata
              Display the XML metadata describing this resource.

STDIN PARAMETERS

       ipport 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_only
              Forces agent to use IPv6 addresses only

       ipaddr IP Address or Hostname This parameter is always required.
       inet4_only
              Forces agent to use IPv4 addresses only

       method Method to fence (onoff|cycle) (Default Value: onoff)

       ssl    SSL connection

       action Fencing Action (Default Value: reboot)

       tlskey Path to client key (PEM format) for TLS authentication. Required if --ssl option is used.

       tlscacert
              Path to CA certificate (PEM format) for TLS authentication. Required if --ssl option is used.

       tlscert
              Path to client certificate (PEM format) for TLS authentication. Required if --ssl option is used.

       verbose
              Verbose mode

       debug  Write debug information to given file

       version
              Display version information and exit

       help   Display help and exit

       separator
              Separator for CSV created by operation list (Default Value: ,)

       power_wait
              Wait X seconds after issuing ON/OFF (Default Value: 0)

       power_timeout
              Test X seconds for status change after ON/OFF (Default Value: 20)

       delay  Wait X seconds before fencing is started (Default Value: 0)
       login_timeout
              Wait X seconds for cmd prompt after login (Default Value: 5)

       shell_timeout
              Wait X seconds for cmd prompt after issuing command (Default Value: 3)

       retry_on
              Count of attempts to retry power on (Default Value: 1)

fence_docker (Fence Agent)        2009-10-20                    FENCE_AGENT(8)


[参考] 
目录
相关文章
|
7月前
|
存储 负载均衡 网络协议
|
Linux Shell Docker
|
Unix Docker 容器
Is the docker daemon running?
Is the docker daemon running?
2884 0
|
网络协议 应用服务中间件 Shell
21-Docker-常用命令详解-docker run
21-Docker-常用命令详解-docker run
|
Linux Docker 容器
19-Docker-常用命令详解-docker exec
19-Docker-常用命令详解-docker exec
|
2月前
|
Ubuntu Shell Linux
docker command
【10月更文挑战第31天】
31 6
|
JSON 网络协议 网络安全
|
Docker 容器
27-Docker-常用命令详解-docker tag
27-Docker-常用命令详解-docker tag
|
Ubuntu 数据安全/隐私保护 Docker
docker 安装 Keeplived
安装和配置Keeplived的步骤如下: 首先,确保你的系统已经安装了Docker。如果没有安装,可以按照官方文档进行安装。 创建一个名为Dockerfile的文件,并将以下代码复制进去: FROM ubuntu:latest; RUN apt-get update && apt-get install -y keepalived; CMD /usr/sbin/keepalived -n -l。本Dockerfile使用Ubuntu作为基础镜像,并安装了Keepalived软件包。CMD命令用于指定容器启动时执行的命令。 在终端中进入Dockerfile所在的目录,并执行以下命令来构建Doc
200 0
|
Docker 容器
20-Docker-常用命令详解-docker attach
20-Docker-常用命令详解-docker attach