Vespa quick start using VirtualBox and Vagrant
This guide describes how to install and run Vespa on a single machine using Virtualbox and Vagrant. Also try the Docker guide.
Clone sample-apps repository
$ git clone https://github.com/vespa-engine/sample-apps.git
Start CentOS VM using Vagrant and Virtualbox
Navigate into the cloned repository and start the CentOS VM using Vagrant. This may take a couple of minutes.
Installing the Vagrant VirtualBox guest plugin is required to mount the sample application directory inside the VM.
Docker note: if you have completed the Docker guide, please stop the running Vespa container before proceeding. Otherwise you will receive conflicts due to the same port being forwarded from the host.
$ cd sample-apps $ vagrant plugin install vagrant-vbguest $ vagrant upSee the Vagrantfile in the sample-apps directory for exact configuration of the CentOS based VM.
SSH into the VM
$ vagrant ssh
Start the Vespa configuration server
$ sudo service vespa-configserver start
Ensure the configuration server is active:
Wait for a 200 OK response from:
$ curl -s --head http://localhost:19071/ApplicationStatus
Deploy a sample application:The sample apps are located at /vespa-sample-apps inside the VM.
$ cd /vespa-sample-apps/album-recommendation-selfhosted $ vespa-deploy prepare src/main/application && vespa-deploy activate
$ sudo service vespa start
Ensure the application is active:
Wait for a 200 OK response from:
$ curl -s --head http://localhost:8080/ApplicationStatus
$ curl -s -H "Content-Type:application/json" --data-binary @/vespa-sample-apps/album-recommendation-selfhosted/src/test/resources/A-Head-Full-of-Dreams.json \ http://localhost:8080/document/v1/mynamespace/music/docid/1 $ curl -s -H "Content-Type:application/json" --data-binary @/vespa-sample-apps/album-recommendation-selfhosted/src/test/resources/Love-Is-Here-To-Stay.json \ http://localhost:8080/document/v1/mynamespace/music/docid/2 $ curl -s -H "Content-Type:application/json" --data-binary @/vespa-sample-apps/album-recommendation-selfhosted/src/test/resources/Hardwired...To-Self-Destruct.json \ http://localhost:8080/document/v1/mynamespace/music/docid/3
Make a query:
$ curl "http://localhost:8080/search/?ranking=rank_albums&yql=select%20%2A%20from%20sources%20%2A%20where%20sddocname%20contains%20%22music%22%3B&ranking.features.query(user_profile)=%7B%7Bcat%3Apop%7D%3A0.8%2C%7Bcat%3Arock%7D%3A0.2%2C%7Bcat%3Ajazz%7D%3A0.1%7D"
Run a document get request :
$ curl -s http://localhost:8080/document/v1/mynamespace/music/docid/2
Once you're done with the VM you can choose how to dispose of it. First exit the Vagrant SSH session
If you want to continue working on the VM later, suspend it:
$ vagrant suspend
Then continue later by navigating to the sample-apps directory and launching the VM again with vagrant up
If you want to remove the VM and its resources from your system, destroy it:
$ vagrant destroy
- This application is fully functional and production ready, but you may want to add more nodes for redundancy.
- Try the Blog search and recommendation tutorial to learn more about using Vespa
- See Vespa Applications on adding your own Java components to your Vespa application.
- Vespa APIs is useful to understand how to interface with Vespa
- Explore the sample applications
- How to secure a Vespa installation
- To run on AWS, see the AWS EC2 multinode quick start and AWS ECS multinode quick start
- To run on Docker Swarm, see basic-search-on-docker-swarm.