System/Installation/Cloud
J/JHS cloud server features
- ready for you from any hardware anywhere
- always available
- fixed IP address
- less than $10/month!
- easy to control costs and cancel
- you could be on your JHS server today
J/JHS hosted by Amazon Web Services (AWS)
AWS provides cloud computing, offering virtual machines that range from tiny to enormous.
A t2.micro (1 core, 1 GiB ram, 8 GiB storage) with fixed IP that runs all the time will cost less than $10/month. This could be easily upgraded, for example, to a t4g.medium (2 cores, 4 GiB ram, 16 GiB storage) for $25/mo.
Costs significantly reduced with some inconvenience (managed instance start/hibernate/terminate).
Your first year on t2.micro with a new account is free!
The following steps are for AWS but can be adjusted for any similar cloud service.
Terminology
- AWS console is a browser app where you manage your AWS resources.
- Pages are complex and are easier on a larger screen.
- There can be a response lag and the console is not always updated.
- If you don't see what you expect, press a refresh button (circular arrow), and be patient.
- Instance is a cloud virtual machine.
- Unix client is where you run unix commands to install and run software on your instance.
- J with the latest JHS update is required on this machine.
- See section Windows client on how to run unix client commands on a Windows host.
- J client is a browser on any machine that accesses the J/JHS instance with the URL and logon-key.
Notation
->url - browse url !EC2 - start at AWS EC2 dashboard * - open section - click right-pointing triangle to get expansion %abc%... - fill in abc text box and press enter >abc - click button/link/checkbox/radiobutton >>abc>def - click abc dropdown and select item #... - comment $... - unix terminal command PATH-AWS - path-to-your-aws folder (adjust as appropriate) ~/j9.4/addons/ide/jhs/aws (if you installed in your home folder) /mnt/c/users/your-user-name/j9.4/addons/ide/jhs/aws (WSL under Windows) J-install-folder/addons/ide/jhs/aws (if you installed somewhere else) PATH-PEM - path-to-your-downloads-folder (adjust as appropriate) ~/Downloads /mnt/c/users/your-user-name/Downloads (WSL under Windows)
Create AWS account
->aws.amazon.com >Sign in to the Console (upper right) >Create a new AWS account #follow steps to get your root account and password
Sign in and go to EC2 dashboard
->aws.amazon.com >Sign in to the Console %Root user email address%... %Password%... %Search%ec2 dashboard
Create things an instance requires
An instance requires 4 things (created once only or for changes).
Key pair - unix client ssh security credentials
!EC2 >Key pairs (in Resources) >Create key pair (upper right) %name%jhs1-kp (must be jhs1-kp) >RSA >.pem >Create key pair (lower right) # jhs1-kp.pem file is downloaded to Downloads folder # use following commands to move downloaded jhs1-kp.pem to .ssh folder and set access: $ mkdir ~/.ssh $ cp PATH-PEM/jhs1-kp.pem ~/.ssh/. $ chmod 600 ~/.ssh/jhs1-kp.pem
VPC - Virtual Private Cloud (logically isolated virtual network)
!EC2 # Account attributes - right hand pane # if a vpc is listed, you have a default vpc and can move to next section >Default VPC (this opens a new browser page) # DO NOT click Create VPC (this is a complicated path) >>Virtual private cloud>Your VPCs (left pane) >>Actions>Create default VPC >Create default VPC %Search%ec2 dashboard
Security group - firewall info
!EC2 >Security groups (in Resources) >Create Security group (upper right) %Security group name%jhs1-sg %Description%ssh 22 jhs 65101 >Add rule (in Inbound rules) >>Type>>SSH (forces port 22) >>Source>Anywhere-IPv4 >Add rule >>Type>Custom TCP %Port range%65101 (this is the JHS/nodejs server port) >>Source>Anywhere-IPv4 >Create security group (lower right)
Elastic IP (EIP) - fixed IP address
# an EIP is a convenience that makes it easier to use the instance !EC2 >Elastic IPs (in Resources) >Allocate Elastic IP address (upper right) >Amazon's pool of IPv4 addresses >Allocate (lower right) #click in the Name column of the new line (contains -) %Name%jhs1-ip # copy Allocated IPv4 address (e.g. 54.88.234.170) to clipboard - this is your EIP # make note of the EIP address as you will need it later $ cd PATH-AWS $ ./aws-sh set paste-eip-here # writes eip to ~/.ssh/jhs_aws_ip.txt
Launch an instance
!EC2 >>Launch instance>Launch instance %Name%jhs1 *Application and OS Images (Amazon Machine Image) >Amazon Linux aws (under Quick Start) *Instance type >>Instance type>t2.micro *Key pair (login) >>Key pair name>jhs1-kp *Network settings >Select existing security group >>Common security groups>jhs1-sg *Configure storage 8 GiB gp3 *Advanced details >>Shutdown behavior>Terminate >Launch Instance (lower right)
!EC2 >Instances >refresh until jhs1 instance state is Running
!EC2 >Elastic IPs >jhs1-ip >>Actions>Associate Elastic IP address >>Instance>jhs1 >Associate (lower right)
Install software and start JHS in the instance
$ cd PATH-AWS $ ./aws-sh clr # required for new instance - avoid known host error $ ./aws-sh bld j9.x # build system $ ./aws-sh server logon-key # Are you sure you want to continue connecting (yes/no/[fingerprint])? yes # There will be a flurry of output, ending with: starting JHS and nodejs... browse to: https://EIP:65101/jijx logon-key: logon-key
Connect J client to the instance
Connect a J client by entering https://EIP:65101/jijx in a browser address bar.
If you are using the default unsigned security certificate, the browser warns that the connection is insecure. You can't be sure who it is as it is unsigned! If you continue, communication with the server is encrypted and is secure. To avoid these warnings: provide signed certificate and key.
Enter logon-key to access JHS.
Example session:
i.5 0 1 2 3 4 dir'' man'create_swap' NB. 1G ram without swap file is very limited create_swap_jaws_'1G' NB. create 1G swap file install_python_jaws_'' NB. python and pandas for Jd install_git_jaws_'' NB. git might be useful load'jd' jdrt'pandas' jdrt'pandas_load' ... NB. copy files between your client and server jijx page>menu>jfile>jcopy ... Esc then q (or red close button) to return to logon screen
You can terminate the instance from a session as well as from the AWS console.
man'shutdown' shutdown_jaws_'now' NB. terminates instance
Extra info
Billing dashboard
Stay on top of your costs and avoid surprises!
!EC2 %Search%aws billing dashboard
Terminate instance
!EC2 >Instances >instance *Instance state>Terminate instance
Release elastic ip
You pay for an elastic ip that is not used!
!EC2 >Elastic IPs >jhs1-ip *Actions>Release Elastic IP addresses
HTTPS certificate and key
The server needs an https certificate and key to allow secure encrypted communication between the browser and the server. The default set up uses a default unsigned certificate that allows encrypted communication but requires you to accept that it is unsigned. This is fine for casual use, but for more serious use you will want to get a signed certificate and key.
# install signed certificate and key $ ./aws-sh https path-to-folder-with-cert-and-key-files
Launch templates
If you are repeatedly doing the same steps to launch an instance, consider creating a launch template.
Windows client
This document, and unix bash shell script aws-sh assume you use a unix client to manage your aws instances.
You could translate the aws-sh script to run in windows terminal, but it is probably easier is to use tools that let you run enough linux on windows to get the job done.
If not already set up to run unix commands, there are a few options.
You could install https://gitforwindows.org. This is easy, light weight, and has all you need.
If already familiar with Cygwin or MinGW, they will do.
You could install WSL2 (window subsystem for linux 2). This is the biggest install but gives you a real linux system that is easy to use from your windows machine with a shared file system.
'Git for Windows', Cygwin, and MinGW share the windows .ssh folder. WSL2 has its own .ssh folder.
WSL paths to windows folders start with: /mnt/c/users/your-user-name/