Ensure that your system is up to date and fully patched
Debian & Ubuntu
sudo apt update -y && sudo apt upgrade -y
CentOS & Amazon Linux
sudo yum update && sudo yum upgrade -y
Install what we can from the default repository:
Debian & Ubuntu
sudo apt -y install git build-essential net-tools vim apt-transport-https ca-certificates curl wget gnupg2 software-properties-common ntp screen postgresql
CentOS
sudo yum -y install git gcc gcc-c++ make openssl-devel net-tools vim ca-certificates curl wget gnupg2 ntp screen postgresql-server postgresql-contrib yum-utils
Amazon Linux
sudo yum -y install git gcc gcc-c++ make openssl-devel net-tools vim ca-certificates curl wget gnupg2 ntp screen postgresql96-server yum-utils
Start the ntp service
Debian & Ubuntu
sudo /etc/init.d/ntp start
sudo systemctl enable ntp
CentOS
sudo systemctl start ntpd
sudo update-rc.d ntpd enable
Amazon Linux
sudo /etc/init.d/ntpd start
sudo chkconfig ntpd on
Debian
curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg | sudo apt-key add -
sudo add-apt-repository -y "deb [arch=amd64] https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") $(lsb_release -cs) stable"
sudo apt -y update
sudo apt -y install docker-ce
Ubuntu (17.04+, Artful doesn't have its own release yet, Zesty works fine)
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu zesty stable"
sudo apt -y update
sudo apt -y install docker-ce
CentOS
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum -y install docker-ce
sudo systemctl start docker
Amazon Linux
sudo yum -y install docker
sudo /etc/init.d/docker start
sudo chkconfig docker on
Allow use of Docker commands without sudo (Not on Amazon Linux)
sudo gpasswd -a $USER docker
su $USER
(Optional) Start using screen
screen
Download and install Go:
curl -O https://storage.googleapis.com/golang/go1.9.2.linux-amd64.tar.gz
tar -xvf go1.9.2.linux-amd64.tar.gz
sudo mv go /usr/local
Set the Go paths:
echo "export PATH=$PATH:/usr/local/go/bin" >> ~/.profile
source ~/.profile
git clone https://github.com/ethereum/go-ethereum.git && cd go-ethereum
make geth
./build/bin/geth --rpc --rpcaddr 172.17.0.1 --syncmode "light"
Running geth with the --fast
option will also work instead of --syncmode "light"
, but you can't do both
Send it to the background with Ctrl+Z or create a new screen with Ctrl+A, C
Replace 9.6 with your version number. You can find this with "ls /etc/postgresql"
cd /etc/postgresql/9.6/main/
If you're setting up the node with different IPs, change them here
sudo sh -c "echo \"listen_addresses = '172.17.0.1'\" >> postgresql.conf"
sudo sh -c "echo \"host all all 172.17.0.0/16 trust\" >> pg_hba.conf"
Start PostgreSQL
sudo /etc/init.d/postgresql restart
sudo update-rc.d postgresql enable
Init the database
sudo postgresql-setup initdb
If you're setting up the node with different IPs, change them here
sudo su postgres
cd /var/lib/pgsql/data
sh -c "echo \"listen_addresses = '172.17.0.1'\" >> postgresql.conf"
sh -c "echo \"host all all 172.17.0.0/16 trust\" >> pg_hba.conf"
exit
Start PostgreSQL
sudo systemctl start postgresql
sudo systemctl enable postgresql
Init the database
sudo service postgresql initdb
If you're setting up the node with different IPs, change them here
sudo su postgres
cd /var/lib/pgsql9/data
sh -c "echo \"listen_addresses = '172.17.0.1'\" >> postgresql.conf"
sh -c "echo \"host all all 172.17.0.0/16 trust\" >> pg_hba.conf"
exit
Start PostgreSQL
sudo /etc/init.d/postgresql restart
sudo chkconfig docker on
cd
docker pull smartcontract/chainlink
touch .env
You can also use POSTGRES_USER and POSTGRES_PASSWORD environment variables in the .env file if you set up a different user in PostgreSQL
echo "DATABASE_URL=postgresql://postgres@172.17.0.1:5432/nayru_development?encoding=utf8&pool=5&timeout=5000" >> .env
echo "ETHEREUM_URL=http://172.17.0.1:8545" >> .env
echo "ETHEREUM_EXPLORER_URL=https://etherscan.io" >> .env
Before running the next line, please change the password to something that you prefer
echo "PRIVATE_KEY_PASSWORD=passwordchangeme" >> .env
Run this to initialize the database:
docker run -it --env-file=.env smartcontract/chainlink rake oracle:initialize
It will ask if you're ready to print coordinator credentials to the screen. You need to actually type "Y" for it to print out the coordinators. Copy them into a text file.
And finally run this to actually start the node:
docker run -t --env-file=.env smartcontract/chainlink
Assignment creations use port 5100 by default, you could also specify a port using -p ####:####
in the command above to expose another port.
Test connection (should be up to date with current Ethereum block):
docker run -it --env-file=.env smartcontract/chainlink rails runner "puts Ethereum::Client.new.current_block_height"
If you want to stop the ChainLink node, you need to kill the entire docker container.
First, get a list of running docker containers with:
docker ps
Look for the line where "image" is set to smartcontract/smartoracle
.
Copy the container id and use it in the following command: (e.g. docker kill 23e27b5e63fb
)
docker kill CONTAINER_ID