2019-01-10 10:10:10 +00:00
|
|
|
Deploying a node to a server
|
|
|
|
============================
|
2017-07-21 11:33:31 +00:00
|
|
|
|
2017-11-29 17:07:13 +00:00
|
|
|
.. contents::
|
|
|
|
|
|
|
|
.. note:: These instructions are intended for people who want to deploy a Corda node to a server,
|
|
|
|
whether they have developed and tested a CorDapp following the instructions in :doc:`generating-a-node`
|
|
|
|
or are deploying a third-party CorDapp.
|
|
|
|
|
2019-11-20 14:39:29 +00:00
|
|
|
.. note:: When deploying multiple nodes in parallel the package tool (Capsule) that Corda uses can encounter
|
|
|
|
issues retrieving dependencies. This is due to each node trying to download the dependencies in a common
|
|
|
|
location. In these cases it is recommended to set the environment variable ``CAPSULE_CACHE_DIR`` which
|
|
|
|
will allow the Capsule to maintain a separate cache for each node. This is used in the example descriptions
|
|
|
|
below. See the `Capsule documentation <http://www.capsule.io>`_ for more details.
|
|
|
|
|
2017-12-04 14:32:47 +00:00
|
|
|
Linux: Installing and running Corda as a system service
|
|
|
|
-------------------------------------------------------
|
2019-09-26 09:20:49 +00:00
|
|
|
We recommend creating system services to run a node and the optional test webserver. This provides logging and service
|
2017-11-29 17:07:13 +00:00
|
|
|
handling, and ensures the Corda service is run at boot.
|
|
|
|
|
|
|
|
**Prerequisites**:
|
|
|
|
|
2019-01-10 10:10:10 +00:00
|
|
|
* A supported Java distribution. The supported versions are listed in :doc:`getting-set-up`
|
2017-11-29 17:07:13 +00:00
|
|
|
|
2018-06-13 16:03:07 +00:00
|
|
|
1. As root/sys admin user - add a system user which will be used to run Corda:
|
2017-11-29 17:07:13 +00:00
|
|
|
|
|
|
|
``sudo adduser --system --no-create-home --group corda``
|
|
|
|
|
2018-06-13 16:03:07 +00:00
|
|
|
|
2017-11-29 17:07:13 +00:00
|
|
|
2. Create a directory called ``/opt/corda`` and change its ownership to the user you want to use to run Corda:
|
|
|
|
|
|
|
|
``mkdir /opt/corda; chown corda:corda /opt/corda``
|
|
|
|
|
|
|
|
3. Download the `Corda jar <https://r3.bintray.com/corda/net/corda/corda/>`_
|
2019-03-25 12:20:26 +00:00
|
|
|
(under ``/|corda_version|/corda-|corda_version|.jar``) and place it in ``/opt/corda``
|
2017-11-29 17:07:13 +00:00
|
|
|
|
2017-12-04 14:32:47 +00:00
|
|
|
4. (Optional) Download the `Corda webserver jar <http://r3.bintray.com/corda/net/corda/corda-webserver/>`_
|
2019-03-25 12:20:26 +00:00
|
|
|
(under ``/|corda_version|/corda-|corda_version|.jar``) and place it in ``/opt/corda``
|
2017-12-04 14:32:47 +00:00
|
|
|
|
2018-02-19 14:22:20 +00:00
|
|
|
5. Create a directory called ``cordapps`` in ``/opt/corda`` and save your CorDapp jar file to it. Alternatively, download one of
|
|
|
|
our `sample CorDapps <https://www.corda.net/samples/>`_ to the ``cordapps`` directory
|
2017-11-29 17:07:13 +00:00
|
|
|
|
2019-04-11 13:43:47 +00:00
|
|
|
6. Save the below as ``/opt/corda/node.conf``. See :doc:`corda-configuration-file` for a description of these options:
|
|
|
|
|
|
|
|
.. code-block:: none
|
2017-11-29 17:07:13 +00:00
|
|
|
|
2019-01-08 13:49:29 +00:00
|
|
|
p2pAddress = "example.com:10002"
|
2018-11-09 08:04:38 +00:00
|
|
|
rpcSettings {
|
|
|
|
address: "example.com:10003"
|
|
|
|
adminAddress: "example.com:10004"
|
|
|
|
}
|
2019-01-08 13:49:29 +00:00
|
|
|
h2port = 11000
|
|
|
|
emailAddress = "you@example.com"
|
|
|
|
myLegalName = "O=Bank of Breakfast Tea, L=London, C=GB"
|
|
|
|
keyStorePassword = "cordacadevpass"
|
|
|
|
trustStorePassword = "trustpass"
|
|
|
|
devMode = false
|
|
|
|
rpcUsers= [
|
2017-11-29 17:07:13 +00:00
|
|
|
{
|
|
|
|
user=corda
|
|
|
|
password=portal_password
|
|
|
|
permissions=[
|
|
|
|
ALL
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
2018-12-17 16:43:22 +00:00
|
|
|
custom { jvmArgs = [ '-Xmx2048m', '-XX:+UseG1GC' ] }
|
2017-11-29 17:07:13 +00:00
|
|
|
|
2017-12-04 14:32:47 +00:00
|
|
|
7. Make the following changes to ``/opt/corda/node.conf``:
|
2017-11-29 17:07:13 +00:00
|
|
|
|
2018-11-09 08:04:38 +00:00
|
|
|
* Change the ``p2pAddress``, ``rpcSettings.address`` and ``rpcSettings.adminAddress`` values to match
|
|
|
|
your server's hostname or external IP address. These are the addresses other nodes or RPC interfaces will use to
|
|
|
|
communicate with your node.
|
|
|
|
* Change the ports if necessary, for example if you are running multiple nodes on one server (see below).
|
2017-11-29 17:07:13 +00:00
|
|
|
* Enter an email address which will be used as an administrative contact during the registration process. This is
|
2018-11-09 08:04:38 +00:00
|
|
|
only visible to the permissioning service.
|
2019-01-08 14:09:55 +00:00
|
|
|
* Enter your node's desired legal name (see :ref:`node-naming` for more details).
|
2019-01-10 10:10:10 +00:00
|
|
|
* If required, add RPC users
|
2017-11-29 17:07:13 +00:00
|
|
|
|
2017-12-04 14:32:47 +00:00
|
|
|
.. note:: Ubuntu 16.04 and most current Linux distributions use SystemD, so if you are running one of these
|
|
|
|
distributions follow the steps marked **SystemD**.
|
|
|
|
If you are running Ubuntu 14.04, follow the instructions for **Upstart**.
|
|
|
|
|
|
|
|
8. **SystemD**: Create a ``corda.service`` file based on the example below and save it in the ``/etc/systemd/system/``
|
|
|
|
directory
|
2017-11-29 17:07:13 +00:00
|
|
|
|
|
|
|
.. code-block:: shell
|
|
|
|
|
|
|
|
[Unit]
|
|
|
|
Description=Corda Node - Bank of Breakfast Tea
|
|
|
|
Requires=network.target
|
|
|
|
|
|
|
|
[Service]
|
|
|
|
Type=simple
|
|
|
|
User=corda
|
|
|
|
WorkingDirectory=/opt/corda
|
2018-12-17 16:43:22 +00:00
|
|
|
ExecStart=/usr/bin/java -jar /opt/corda/corda.jar
|
2017-11-29 17:07:13 +00:00
|
|
|
Restart=on-failure
|
2019-11-20 14:39:29 +00:00
|
|
|
Environment="CAPSULE_CACHE_DIR=./capsule"
|
2017-11-29 17:07:13 +00:00
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=multi-user.target
|
|
|
|
|
2017-12-04 14:32:47 +00:00
|
|
|
8. **Upstart**: Create a ``corda.conf`` file based on the example below and save it in the ``/etc/init/`` directory
|
|
|
|
|
|
|
|
.. code-block:: shell
|
|
|
|
|
|
|
|
description "Corda Node - Bank of Breakfast Tea"
|
|
|
|
|
|
|
|
start on runlevel [2345]
|
|
|
|
stop on runlevel [!2345]
|
|
|
|
|
|
|
|
respawn
|
|
|
|
setuid corda
|
|
|
|
chdir /opt/corda
|
2018-12-17 16:43:22 +00:00
|
|
|
exec java -jar /opt/corda/corda.jar
|
2017-12-04 14:32:47 +00:00
|
|
|
|
|
|
|
9. Make the following changes to ``corda.service`` or ``corda.conf``:
|
2017-11-29 17:07:13 +00:00
|
|
|
|
|
|
|
* Make sure the service description is informative - particularly if you plan to run multiple nodes.
|
2017-12-04 14:32:47 +00:00
|
|
|
* Change the username to the user account you want to use to run Corda. **We recommend that this user account is
|
|
|
|
not root**
|
|
|
|
* **SystemD**: Make sure the ``corda.service`` file is owned by root with the correct permissions:
|
|
|
|
|
2017-11-29 17:07:13 +00:00
|
|
|
* ``sudo chown root:root /etc/systemd/system/corda.service``
|
|
|
|
* ``sudo chmod 644 /etc/systemd/system/corda.service``
|
|
|
|
|
2017-12-04 14:32:47 +00:00
|
|
|
* **Upstart**: Make sure the ``corda.conf`` file is owned by root with the correct permissions:
|
|
|
|
|
|
|
|
* ``sudo chown root:root /etc/init/corda.conf``
|
|
|
|
* ``sudo chmod 644 /etc/init/corda.conf``
|
|
|
|
|
2019-09-26 09:20:49 +00:00
|
|
|
.. note:: The Corda test webserver provides a simple interface for interacting with your installed CorDapps in a browser.
|
2017-11-29 17:07:13 +00:00
|
|
|
Running the webserver is optional.
|
|
|
|
|
2017-12-04 14:32:47 +00:00
|
|
|
10. **SystemD**: Create a ``corda-webserver.service`` file based on the example below and save it in the ``/etc/systemd/system/``
|
|
|
|
directory
|
2017-11-29 17:07:13 +00:00
|
|
|
|
|
|
|
.. code-block:: shell
|
|
|
|
|
|
|
|
[Unit]
|
|
|
|
Description=Webserver for Corda Node - Bank of Breakfast Tea
|
|
|
|
Requires=network.target
|
|
|
|
|
|
|
|
[Service]
|
|
|
|
Type=simple
|
2017-12-04 14:32:47 +00:00
|
|
|
User=corda
|
2017-11-29 17:07:13 +00:00
|
|
|
WorkingDirectory=/opt/corda
|
|
|
|
ExecStart=/usr/bin/java -jar /opt/corda/corda-webserver.jar
|
|
|
|
Restart=on-failure
|
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=multi-user.target
|
|
|
|
|
2017-12-04 14:32:47 +00:00
|
|
|
10. **Upstart**: Create a ``corda-webserver.conf`` file based on the example below and save it in the ``/etc/init/``
|
|
|
|
directory
|
|
|
|
|
|
|
|
.. code-block:: shell
|
|
|
|
|
|
|
|
description "Webserver for Corda Node - Bank of Breakfast Tea"
|
|
|
|
|
|
|
|
start on runlevel [2345]
|
|
|
|
stop on runlevel [!2345]
|
2017-11-29 17:07:13 +00:00
|
|
|
|
2017-12-04 14:32:47 +00:00
|
|
|
respawn
|
|
|
|
setuid corda
|
|
|
|
chdir /opt/corda
|
|
|
|
exec java -jar /opt/corda/corda-webserver.jar
|
|
|
|
|
|
|
|
11. Provision the required certificates to your node. Contact the network permissioning service or see
|
|
|
|
:doc:`permissioning`
|
|
|
|
|
|
|
|
12. **SystemD**: You can now start a node and its webserver and set the services to start on boot by running the
|
|
|
|
following ``systemctl`` commands:
|
2017-11-29 17:07:13 +00:00
|
|
|
|
|
|
|
* ``sudo systemctl daemon-reload``
|
2017-11-30 10:06:37 +00:00
|
|
|
* ``sudo systemctl enable --now corda``
|
|
|
|
* ``sudo systemctl enable --now corda-webserver``
|
2017-11-29 17:07:13 +00:00
|
|
|
|
2017-12-04 14:32:47 +00:00
|
|
|
12. **Upstart**: You can now start a node and its webserver by running the following commands:
|
|
|
|
|
|
|
|
* ``sudo start corda``
|
|
|
|
* ``sudo start corda-webserver``
|
|
|
|
|
|
|
|
The Upstart configuration files created above tell Upstart to start the Corda services on boot so there is no need to explicitly enable them.
|
|
|
|
|
2017-11-29 17:07:13 +00:00
|
|
|
You can run multiple nodes by creating multiple directories and Corda services, modifying the ``node.conf`` and
|
2017-12-04 14:32:47 +00:00
|
|
|
SystemD or Upstart configuration files so they are unique.
|
2017-11-29 17:07:13 +00:00
|
|
|
|
|
|
|
Windows: Installing and running Corda as a Windows service
|
|
|
|
----------------------------------------------------------
|
|
|
|
We recommend running Corda as a Windows service. This provides service handling, ensures the Corda service is run
|
|
|
|
at boot, and means the Corda service stays running with no users connected to the server.
|
|
|
|
|
|
|
|
**Prerequisites**:
|
|
|
|
|
2019-01-10 10:10:10 +00:00
|
|
|
* A supported Java distribution. The supported versions are listed in :doc:`getting-set-up`
|
2017-11-29 17:07:13 +00:00
|
|
|
|
2019-03-25 12:20:26 +00:00
|
|
|
1. Create a Corda directory and download the Corda jar. Here's an
|
2019-04-11 13:43:47 +00:00
|
|
|
example using PowerShell:
|
|
|
|
|
|
|
|
.. code-block:: shell
|
2017-11-29 17:07:13 +00:00
|
|
|
|
|
|
|
mkdir C:\Corda
|
2019-03-25 12:20:26 +00:00
|
|
|
wget http://jcenter.bintray.com/net/corda/corda/|corda_version|/corda-|corda_version|.jar -OutFile C:\Corda\corda.jar
|
2017-11-29 17:07:13 +00:00
|
|
|
|
2018-02-22 14:15:25 +00:00
|
|
|
2. Create a directory called ``cordapps`` in ``C:\Corda\`` and save your CorDapp jar file to it. Alternatively,
|
2018-02-19 14:22:20 +00:00
|
|
|
download one of our `sample CorDapps <https://www.corda.net/samples/>`_ to the ``cordapps`` directory
|
2017-11-29 17:07:13 +00:00
|
|
|
|
2019-04-11 13:43:47 +00:00
|
|
|
3. Save the below as ``C:\Corda\node.conf``. See :doc:`corda-configuration-file` for a description of these options:
|
|
|
|
|
|
|
|
.. code-block:: none
|
2017-11-29 17:07:13 +00:00
|
|
|
|
2019-01-08 13:49:29 +00:00
|
|
|
p2pAddress = "example.com:10002"
|
2018-11-09 08:04:38 +00:00
|
|
|
rpcSettings {
|
2019-01-08 13:49:29 +00:00
|
|
|
address = "example.com:10003"
|
|
|
|
adminAddress = "example.com:10004"
|
2018-11-09 08:04:38 +00:00
|
|
|
}
|
2019-01-08 13:49:29 +00:00
|
|
|
h2port = 11000
|
|
|
|
emailAddress = "you@example.com"
|
|
|
|
myLegalName = "O=Bank of Breakfast Tea, L=London, C=GB"
|
|
|
|
keyStorePassword = "cordacadevpass"
|
|
|
|
trustStorePassword = "trustpass"
|
|
|
|
devMode = false
|
2019-01-08 14:09:55 +00:00
|
|
|
rpcSettings {
|
|
|
|
useSsl = false
|
|
|
|
standAloneBroker = false
|
|
|
|
address = "example.com:10003"
|
|
|
|
adminAddress = "example.com:10004"
|
|
|
|
}
|
|
|
|
custom { jvmArgs = [ '-Xmx2048m', '-XX:+UseG1GC' ] }
|
2017-11-29 17:07:13 +00:00
|
|
|
|
|
|
|
4. Make the following changes to ``C:\Corda\node.conf``:
|
|
|
|
|
2018-11-09 08:04:38 +00:00
|
|
|
* Change the ``p2pAddress``, ``rpcSettings.address`` and ``rpcSettings.adminAddress`` values to match
|
|
|
|
your server's hostname or external IP address. These are the addresses other nodes or RPC interfaces will use to
|
|
|
|
communicate with your node.
|
|
|
|
* Change the ports if necessary, for example if you are running multiple nodes on one server (see below).
|
2017-11-29 17:07:13 +00:00
|
|
|
* Enter an email address which will be used as an administrative contact during the registration process. This is
|
2018-11-09 08:04:38 +00:00
|
|
|
only visible to the permissioning service.
|
2019-01-08 14:09:55 +00:00
|
|
|
* Enter your node's desired legal name (see :ref:`node-naming` for more details).
|
2019-01-10 10:10:10 +00:00
|
|
|
* If required, add RPC users
|
2017-11-29 17:07:13 +00:00
|
|
|
|
|
|
|
5. Copy the required Java keystores to the node. See :doc:`permissioning`
|
2017-07-21 11:33:31 +00:00
|
|
|
|
2019-05-29 15:02:25 +00:00
|
|
|
6. Download the `NSSM service manager <https://nssm.cc/>`_
|
2017-07-21 11:33:31 +00:00
|
|
|
|
2017-11-29 17:07:13 +00:00
|
|
|
7. Unzip ``nssm-2.24\win64\nssm.exe`` to ``C:\Corda``
|
2017-07-21 11:33:31 +00:00
|
|
|
|
2017-11-29 17:07:13 +00:00
|
|
|
8. Save the following as ``C:\Corda\nssm.bat``:
|
2017-10-03 16:32:11 +00:00
|
|
|
|
2017-11-29 17:07:13 +00:00
|
|
|
.. code-block:: batch
|
2017-10-03 16:32:11 +00:00
|
|
|
|
2019-11-20 14:39:29 +00:00
|
|
|
nssm install cordanode1 java.exe
|
|
|
|
nssm set cordanode1 AppParameters "-jar corda.jar"
|
2017-11-29 17:07:13 +00:00
|
|
|
nssm set cordanode1 AppDirectory C:\Corda
|
|
|
|
nssm set cordanode1 AppStdout C:\Corda\service.log
|
|
|
|
nssm set cordanode1 AppStderr C:\Corda\service.log
|
2019-11-20 14:39:29 +00:00
|
|
|
nssm set cordanode1 AppEnvironmentExtra CAPSULE_CACHE_DIR=./capsule
|
2017-11-29 17:07:13 +00:00
|
|
|
nssm set cordanode1 Description Corda Node - Bank of Breakfast Tea
|
2017-11-30 10:06:37 +00:00
|
|
|
nssm set cordanode1 Start SERVICE_AUTO_START
|
2017-11-29 17:07:13 +00:00
|
|
|
sc start cordanode1
|
2017-10-03 16:32:11 +00:00
|
|
|
|
2017-11-29 17:07:13 +00:00
|
|
|
9. Modify the batch file:
|
2017-07-21 11:33:31 +00:00
|
|
|
|
2019-11-20 14:39:29 +00:00
|
|
|
* If you are installing multiple nodes, use a different service name (``cordanode1``), and modify
|
|
|
|
`AppDirectory`, `AppStdout` and `AppStderr` for each node accordingly
|
2017-11-29 17:07:13 +00:00
|
|
|
* Set an informative description
|
2017-07-21 11:33:31 +00:00
|
|
|
|
2018-02-26 09:21:27 +00:00
|
|
|
10. Provision the required certificates to your node. Contact the network permissioning service or see
|
|
|
|
:doc:`permissioning`
|
|
|
|
|
|
|
|
11. Run the batch file by clicking on it or from a command prompt
|
2017-07-21 11:33:31 +00:00
|
|
|
|
2018-02-26 09:21:27 +00:00
|
|
|
12. Run ``services.msc`` and verify that a service called ``cordanode1`` is present and running
|
2017-07-21 11:33:31 +00:00
|
|
|
|
2018-02-26 09:21:27 +00:00
|
|
|
13. Run ``netstat -ano`` and check for the ports you configured in ``node.conf``
|
2017-07-21 11:33:31 +00:00
|
|
|
|
2018-02-26 09:21:27 +00:00
|
|
|
* You may need to open the ports on the Windows firewall
|
2017-10-10 14:45:42 +00:00
|
|
|
|
2017-11-29 17:07:13 +00:00
|
|
|
Testing your installation
|
|
|
|
-------------------------
|
|
|
|
You can verify Corda is running by connecting to your RPC port from another host, e.g.:
|
2017-07-21 11:33:31 +00:00
|
|
|
|
2017-11-29 17:07:13 +00:00
|
|
|
``telnet your-hostname.example.com 10002``
|
2017-07-21 11:33:31 +00:00
|
|
|
|
2017-11-29 17:07:13 +00:00
|
|
|
If you receive the message "Escape character is ^]", Corda is running and accessible. Press Ctrl-] and Ctrl-D to exit
|
2018-02-19 14:22:20 +00:00
|
|
|
telnet.
|