4.2. SSH Containers
Abstract
Fabric allows you to install containers in a local network using SSH. Fabric installs the container from scratch and configures the container to join the Fabric cluster automatically.
Overview
An SSH container is just a Fabric container that is running on a remote host on your local network, where that host is accessible through the SSH protocol. This section describes some basic administration tasks for these SSH containers.
Prerequisites
The requirements for creating an SSH container on a remote host are:
- Linux or UNIX operating system,
- SSHD running on the target host and:
- A valid account credentials, or
- Configured public key authentication
- Java 1.6 installed.
- Curl installed.
- GNU tar installed.
- Telnet installed.
Creating an SSH container
Fabric provides the
fabric:container-create-ssh
console command, for creating SSH containers.
Given the host,
myhost
(accessible from the local network) with the SSH user account, myuser
, and the password, mypassword
, your could create an SSH container on myhost
, using the following console command:
fabric:container-create-ssh --host myhost --user myuser --password mypassword myremotecontainername
If the
myuser
user on myhost
has configured public key authentication for SSH, you can skip the password option:
fabric:container-create-ssh --host myhost --user myuser myremotecontainername
Where the preceding command uses the key located in
~/.ssh/id_rsa
for authentication. If you need to use a different key, you can specify the key location explicitly with the --private-key
option:
fabric:container-create-ssh --host myhost --user myuser --private-key ~/.ssh/fabric_pk myremotecontainername
The last command also supports the
--pass-phrase
option, in case your key requires a pass phrase.
Creating a Fabric server using SSH
Sometimes you do not have an existing fabric and you want to create one on a remote host. The starting point for any fabric is a Fabric server instance, which can act as a seed for the rest of the fabric. So, to enable you to create a new fabric on a remote host, the
fabric:container-create-ssh
supports the --ensemble-server
option, which can be invoked to create a container which is a Fabric server. For example, the following container-create-ssh
command creates a new fabric consisting of one Fabric server on the myhost
host:
fabric:container-create-ssh --host myhost --user myuser --ensemble-server myremotecontainername fabric:join myhost:2181
The
fabric:join
command joins the current container to the new fabric. This has the advantage that it is much easier to administer the new fabric using a container that is joined to the fabric, because the local container then gains access to the connection data stored in the Fabric registry.
Note
The argument to
fabric:join
is the ZooKeeper server port, Host:Port
. The port number in this example, 2181
, is the standard ZooKeeper port number in Fabric.
Note
After you enter the
fabric:join
command, you will be prompted to enter the ZooKeeper password for the fabric.
Managing remote SSH containers
Using JBoss Fuse console commands, you can stop, restart or delete (that is, uninstall) a remote container, as follows:
To stop an SSH container:
fabric:container-stop myremotecontainername
To restart an SSH container:
fabric:container-start myremotecontainername
To uninstall an SSH container:
fabric:container-delete myremotecontainername
Note that these commands are available only for containers created directly using the current fabric. They are not available for containers that were joined to the cluster manually.
References
For more details about the SSH container console commands, see the JBoss Fuse Console Reference.