Set up Aerospike/docker:
Set up EC2-Instances. I used i3.4xlarge. You need the following inbound rules on the Security Group:
- TCP 3000 - 3004 (Aerospike heartbeat, gossip etc)
- TCP 2377 (Docker Swarm cluster management, Raft)
- TCP/UDP 7946 (Docker Swarm control plane, gossip service discovery)
- UDP 4789 (Docker Swarm overlay network traffic)
- ESP (50) (Docker Swarm overlay network encryption, select "Custom Protocol" and type in 50)
See:
https://docs.docker.com/engine/swarm/swarm-tutorial/#open-protocols-and-ports-between-the-hosts
https://www.aerospike.com/docs/operations/configure/network/
https://gist.github.com/BretFisher/7233b7ecf14bc49eb47715bbeb2a2769
I have this set up under the "aerospike" security group
sudo mkfs.ext4 /dev/nvme0n1
sudo mkfs.ext4 /dev/nvme1n1
sudo mkdir /mnt0
sudo mkdir /mnt1
sudo mount -t ext4 /dev/nvme0n1 /mnt0
sudo mount -t ext4 /dev/nvme1n1 /mnt1
sudo yum install docker -y
sudo usermod -aG docker ec2-user
sudo su - ec2-user # apply changes
sudo service docker start
sudo vim /etc/sysconfig/docker # increase file limits. I do OPTIONS="--default-ulimit nofile=102400:409600"
sudo service docker restart
docker swarm init --advertise-addr `hostname -i`
ON ALL NON-MASTER NODES. It should tell you the $TOKEN and $MASTER_IP when you initialized the swarm.
docker swarm join --token $TOKEN $MASTER_IP:2377
docker node ls
git clone https://github.com/cozos/aerospike-docker-swarm.git
cd aerospike-docker-swarm
docker stack deploy -c aerospike.yml aerospike
docker run --net aerospike_aerospikenetwork aerospike/aerospike-tools asadm -h aerospikedb -e info
docker exec -it `docker ps -q --filter "name=aerospike_aerospikedb"` aql
insert into test.foo (PK, foo) values ('123','my string')
select * from test.foo
https://github.com/cozos/aerospike-docker-swarm/blob/master/README.md https://www.aerospike.com/docs/deploy_guides/docker/ https://www.aerospike.com/docs/deploy_guides/docker/orchestrate/ https://www.aerospike.com/docs/deploy_guides/docker/recommendations/
in profiles/pom.xml:
<dependency>
<groupId>com.aerospike</groupId>
<artifactId>aerospike-client</artifactId>
<version>4.1.11</version>
</dependency>
package profiles.lib;
import com.aerospike.client.AerospikeClient;
import com.aerospike.client.Bin;
import com.aerospike.client.Key;
import com.aerospike.client.Record;
public class AerospikeWriter {
public static String AEROSPIKE_HOST = "172.18.225.153";
public static void main(String [] args) {
AerospikeClient client = new AerospikeClient(AEROSPIKE_HOST, 3000);
Key key = new Key("test", "foo", "putgetkey");
Bin bin1 = new Bin("foo", "falala");
// // Write a record
client.put(null, key, bin1);
// Read a record
Record record = client.get(null, key);
System.out.println(record);
client.close();
}
}