Connecting to server when running vagrant on macOS


#1

I want to give a try, it, looked at:

but not clear to me.

sudo service aerospike start

start the server on the vagrant machine : it works. On which port does it listen? How to make it communicate with applications I am running on my laptop outside vagrant ?

tried to modify vagrant configuration file to forward the ports:

http://tech.osteel.me/posts/2015/01/25/how-to-use-vagrant-for-local-web-development.html

config.vm.network :forwarded_port, guest: 80, host: 2000 #forward port 80 to port 2000 on my local network

but did not work.

I run:

curl 127.0.0.1:3000 #in my vagrant machine
curl: (56) Recv failure: Connection reset by peer

I run:

curl localhost:2000 # in terminal of local machine
curl: (56) Recv failure: Connection reset by peer

curl localhost:3000 # in terminal of local machine
curl: (7) Failed connect to localhost:3000; Connection refused

curl 127.0.0.1:2000 # in terminal of local machine
curl: (52) Empty reply from server

curl 127.0.0.1:3000 # in terminal of local machine
curl: (7) Failed connect to 127.0.0.1:3000; Connection refused

Could you please help with step to step instructions? I never used vagrant, I just would like to test AS on mac - would be amazing If I could testing with no need of virtual machines.


#2

Here is what I did on a new Mac OSX to get Aerospike server up and running.

1 - Install Vagrant https://www.vagrantup.com/downloads.html MacOSX -> vagrant.1.91.1.dmg Open .dmg, click on Vagrant.pkg and install via the popup window it opens.

Open a terminal shell. Check if vagrant is installed.

$ which vagrant /usr/local/bin/vagrant

2 - Download and install oracle virtualbox. https://www.virtualbox.org/wiki/Downloads VirtualBox 5.1.12-11.dmg is downloaded when you click on OS X hosts hyperlink. Open .dmg and double click on VirtualBox.pkg. Follow the installation instructions in the popup window.
You can run the VirtualBox application from Applications folder.

3 - Create working directory and Download Aerospike image.

cd ~ mkdir aerospike-vm cd aerospike-vm/ $ vagrant init aerospike/centos-6.5 A Vagrantfile has been placed in this directory. You are now ready to vagrant up your first virtual environment! Please read the comments in the Vagrantfile as well as documentation on vagrantup.com for more information on using Vagrant. $vagrant up (Uses VirtualBox as the default box provider. Check startup messages to see which port on Mac is being forwarded to port 3000 that aerospike is listening on.) Actual output on my mac: Bringing machine ‘default’ up with ‘virtualbox’ provider… ==> default: Box ‘aerospike/centos-6.5’ could not be found. Attempting to find and install… default: Box Provider: virtualbox default: Box Version: >= 0 ==> default: Loading metadata for box 'aerospike/centos-6.5’ default: URL: https://atlas.hashicorp.com/aerospike/centos-6.5 ==> default: Adding box ‘aerospike/centos-6.5’ (v3.10.1.1) for provider: virtualbox default: Downloading: https://atlas.hashicorp.com/aerospike/boxes/centos-6.5/versions/3.10.1.1/providers/virtualbox.box ==> default: Successfully added box ‘aerospike/centos-6.5’ (v3.10.1.1) for ‘virtualbox’! ==> default: Importing base box ‘aerospike/centos-6.5’… ==> default: Matching MAC address for NAT networking… ==> default: Checking if box ‘aerospike/centos-6.5’ is up to date… ==> default: Setting the name of the VM: aerospike-vm_default_1483493148894_93128 ==> default: Clearing any previously set network interfaces… ==> default: Found default DHCP server from initial VirtualBox install. Cleaning it up… ==> default: Preparing network interfaces based on configuration… default: Adapter 1: nat default: Adapter 2: hostonly ==> default: Forwarding ports… default: 3000 (guest) => 3000 (host) (adapter 1) default: 8081 (guest) => 8081 (host) (adapter 1) default: 22 (guest) => 2222 (host) (adapter 1) ==> default: Running ‘pre-boot’ VM customizations… ==> default: Booting VM… ==> default: Waiting for machine to boot. This may take a few minutes… default: SSH address: 127.0.0.1:2222 default: SSH username: vagrant default: SSH auth method: private key default: Warning: Remote connection disconnect. Retrying… ==> default: Machine booted and ready! ==> default: Checking for guest additions in VM… default: The guest additions on this VM do not match the installed version of default: VirtualBox! In most cases this is fine, but in rare cases it can default: prevent things such as shared folders from working properly. If you see default: shared folder errors, please make sure the guest additions within the default: virtual machine match the version of VirtualBox you have installed on default: your host and reload your VM. default: default: Guest Additions Version: 5.0.20 default: VirtualBox Version: 5.1 ==> default: Configuring and enabling network interfaces… ==> default: Mounting shared folders…

To find the ip address of the server do (in a terminal on your mac):

$vagrant ssh -c “ip addr”|grep 'global eth1’ inet 172.28.128.3/24 brd 172.28.128.255 scope global eth1 Connection to 127.0.0.1 closed.

Now I can see the AMC dashboard on my browser in the Mac at: http://172.28.128.3:8081

I see an Aerospike server running with 2GB RAM and 5GB disk.

However, if you want to be inside the VM to do client side development, you can do:

$vagrant ssh

This will take you in the vm where you can install various clients and develop.

If you want your client to be on the Mac, then you will have to install client libraries on Mac and then connect to Aerospike Server on the vm.

Here is the prompt after I type vagrant ssh:

[vagrant@localhost ~] pwd /home/vagrant [vagrant@localhost ~] ls ClientInstall [vagrant@localhost ~] ls ClientInstall/ as_c_install.sh as_java_install.sh as_nodejs_install.sh as_python_install.sh [vagrant@localhost ~]

Now you can do whatever modifications you want to the server and install and develop in the clients. When done,

$logout of the ssh and then do $vagrant halt


No aerospike.conf file in OSX
#3

Hi thank you for detailed answer.

I am using vagrant hashicorp/precise64 - I tried with centos but had an error.

I then installed: wget -O aerospike.tgz 'http://aerospike.com/download/server/latest/artifact/ubuntu12

    vagrant up
    [..]
        default: 80 => 2000 (adapter 1)
        default: 22 => 2222 (adapter 1)
    ==> default: Booting VM...
    ==> default: Waiting for machine to boot. This may take a few minutes...
        default: SSH address: 127.0.0.1:2222
        default: SSH username: vagrant
        default: SSH auth method: private key
    ==> default: Machine booted and ready!
 
    vagrant ssh -c "ip addr"|grep 'global eth1'
    Connection to 127.0.0.1 closed.

So tried VM as client side development.

vagrant ssh

and have on home folder:

aerospike-server-community-3.10.1.1-ubuntu12.04 aerospike.tgz postinstall.sh

I don’t have a ClientInstall folder.

I tried ./postinstall.sh but interrupted because was giving errors since I did not have permissions. I tried as root but then postintall.sh was missing (maybe self-removed?)

Retried sudo ./asinstall

Giving errors:

    [..]    
    After this operation, 43.3 MB of additional disk space will be used.
        Err http://us.archive.ubuntu.com/ubuntu/ precise-updates/main libexpat1 amd64 2.0.1-7.2ubuntu1.1
          404  Not Found [IP: 91.189.91.23 80]
        Err http://us.archive.ubuntu.com/ubuntu/ precise-updates/main python2.7 amd64 2.7.3-0ubuntu3.1
          404  Not Found [IP: 91.189.91.23 80]
        Err http://us.archive.ubuntu.com/ubuntu/ precise-updates/main python2.7-minimal amd64 2.7.3-0ubuntu3.1
          404  Not Found [IP: 91.189.91.23 80]
        Err http://us.archive.ubuntu.com/ubuntu/ precise-updates/main libpython2.7 amd64 2.7.3-0ubuntu3.1
          404  Not Found [IP: 91.189.91.23 80]
        Err http://us.archive.ubuntu.com/ubuntu/ precise-updates/main python2.7-dev amd64 2.7.3-0ubuntu3.1
          404  Not Found [IP: 91.189.91.23 80]
        Err http://security.ubuntu.com/ubuntu/ precise-security/main libexpat1 amd64 2.0.1-7.2ubuntu1.1
          404  Not Found [IP: 91.189.91.23 80]
        Err http://security.ubuntu.com/ubuntu/ precise-security/main libexpat1-dev amd64 2.0.1-7.2ubuntu1.1
          404  Not Found [IP: 91.189.91.23 80]
        Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/e/expat/libexpat1_2.0.1-7.2ubuntu1.1_amd64.deb  404  Not Found [IP: 91.189.91.23 80]
        Failed to fetch http://us.archive.ubuntu.com/ubuntu/pool/main/p/python2.7/python2.7_2.7.3-0ubuntu3.1_amd64.deb  404  Not Found [IP: 91.189.91.23 80]
        Failed to fetch http://us.archive.ubuntu.com/ubuntu/pool/main/p/python2.7/python2.7-minimal_2.7.3-0ubuntu3.1_amd64.deb  404  Not Found [IP: 91.189.91.23 80]
        Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/e/expat/libexpat1-dev_2.0.1-7.2ubuntu1.1_amd64.deb  404  Not Found [IP: 91.189.91.23 80]
        Failed to fetch http://us.archive.ubuntu.com/ubuntu/pool/main/p/python2.7/libpython2.7_2.7.3-0ubuntu3.1_amd64.deb  404  Not Found [IP: 91.189.91.23 80]
        Failed to fetch http://us.archive.ubuntu.com/ubuntu/pool/main/p/python2.7/python2.7-dev_2.7.3-0ubuntu3.1_amd64.deb  404  Not Found [IP: 91.189.91.23 80]
[...]

  Downloading py-bcrypt-0.4.tar.gz
Installing collected packages: py-bcrypt
  Running setup.py install for py-bcrypt ... error
    Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-69f_aG/py-bcrypt/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-YmMMlU-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-2.7
    creating build/lib.linux-x86_64-2.7/bcrypt
    copying bcrypt/__init__.py -> build/lib.linux-x86_64-2.7/bcrypt
    running build_ext
    building 'bcrypt._bcrypt' extension
    creating build/temp.linux-x86_64-2.7
    creating build/temp.linux-x86_64-2.7/bcrypt
    gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c bcrypt/bcrypt.c -o build/temp.linux-x86_64-2.7/bcrypt/bcrypt.o
    gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c bcrypt/bcrypt_pbkdf.c -o build/temp.linux-x86_64-2.7/bcrypt/bcrypt_pbkdf.o
    gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c bcrypt/bcrypt_python.c -o build/temp.linux-x86_64-2.7/bcrypt/bcrypt_python.o
    bcrypt/bcrypt_python.c:18:20: fatal error: Python.h: No such file or directory
    compilation terminated.
    error: command 'gcc' failed with exit status 1

However, it seems working - despite errors :confused: :

    sudo service aerospike start
    kernel.shmall too low, setting to 4G pages = 16TB
    kernel.shmall = 4294967296
    kernel.shmmax too low, setting to 1GB
    kernel.shmmax = 1073741824
    Increasing read socket buffer limit (/proc/sys/net/core/rmem_max): 229376 -> 15728640
    Increasing write socket buffer limit (/proc/sys/net/core/wmem_max): 229376 -> 5242880
* Starting aerospike

But still can’t figure out which port it listened to to add data from my local environment (outside vagrant, from another terminal - should it listen to localhost:2000 right? )