4
- var title='Getting Started'
5
- var page='getting-started'
12
<p>This tutorial will show you how to get started with Juju, including installing, configuring and bootstrapping a new Juju environment.
13
Before you start you will need:</p>
15
<li> An Ubuntu server or desktop to install the Juju software on.</li>
16
<li> An environment which can provide a new server with an Ubuntu cloud operating system image on-demand. This includes services such as Amazon EC2 , HP Cloud or RackSpace. For testing purposes, you can also configure a local environment.</li>
17
<li> It's also required that the environment provides a permanent storage facility such as Amazon S3. For the moment, though, the only environment supported is EC2, OpenStack, and LXC containers.</li>
18
<li> An SSH key-pair. If you have not already set one up, you can generate an appropriate keypair with:</li>
19
<pre>ssh-keygen -t rsa -b 2048</pre>
23
<section id="install">
24
<h1 >Installation</h1>
27
To install Juju, you simply need to grab the latest juju-core package:</p>
29
<pre>sudo apt-get update
30
sudo apt-get install juju-core</pre>
32
<p>Juju is provided automatically as a backport in Ubuntu Server. Backports are usually enabled by default, but if you've turned them off <a href="http://askubuntu.com/a/285474/235">here's how you can enable them</a>. If apt complains that it cannot find the packages you might need to use the PPA:</p>
34
<pre><code>sudo add-apt-repository ppa:juju/devel
35
sudo apt-get update && sudo apt-get install juju-core
37
<p>Regular updates will be made to the backported packages, unless you want to follow along with Juju development we recommend users to not use the PPA.</p>
39
<p>You can switch between the default (0.7) version and 1.10 versions by using the following:</p>
41
<pre><code>sudo update-alternatives --set juju /usr/lib/juju-0.7/bin/juju</code></pre>
43
<p>or to the new 1.10.0 release using:</p>
45
<pre><code>sudo update-alternatives --set juju /usr/lib/juju-1.10.0/bin/juju</code></pre>
50
<p>Now the Juju software is installed, it needs to be configured to use your particular cloud provider. This is done by generating and editing a file, "environments.yaml", which will live in your ~/.juju/ directory. You can generate the environments file manually, but Juju also includes a boilerplate configuration option that will flesh out most of the file for you and minimise the amount of work (and potential errors).</p>
51
<p>To generate an initial config file, you simply need to run:</p>
52
<pre><code>juju generate-config -w</code></pre>
54
<p>The -w switch causes the file to be written to your ~/.juju directory if an environments.yaml file does not already exist. It will also create the ~./juju directory if that does not exist.</p>
55
<p>This file will contain sample profiles for different types of cloud services, but you will need to edit the files to provide specific information for your cloud provider. Sections are created for Amazon (AWS) services, HPCloud and a generic OpenStack instance. For more specifics on what needs to be changed, see the relevant sections below.</p>
57
<li><a href="config-aws.html">Configuring for Amazon AWS</a></li>
58
<li><a href="config-hpcloud.html">Configuring for HP Cloud</a></li>
59
<li><a href="config-openstack.html">Configuring for OpenStack</a></li>
64
<h1>Testing your setup</h1>
66
<p>Once you have installed and configured Juju, it is probably a good idea to take it for a bit of a test drive and check that everything is working as expected. Because Juju makes it really easy to deploy services, this is actually quick and straightforward.</p>
69
<iframe class="youtube-player" type="text/html" width="400" height="300" src="http://www.youtube.com/embed/0AT6qKyam9I" frameborder="0">
73
<p> The first thing to do is set up a bootstrap environment. This is an instance in the cloud that Juju will use to deploy and control other services with. It will be created according to the configuration you have provided, and your SSH key will automatically be uploaded so that Juju can communicate securely with the bootstrap instance. </p>
75
<pre>juju bootstrap </pre>
77
<p class="note"><strong>Note:</strong> If you have multiple environments configured, you can choose which one to address with a particular command by adding the -e switch followed by the environment name, E.g. "-e hpcloud".</p>
79
<p>You may have to wait a few moments for this command to return, as it needs to perform various tasks and contact your cloud provider. </p>
80
<p>Assuming it returns successfully (otherwise see <a href="#errors">common error messages and what to do about them</a>), we can now deploy some services and explore the basic operations of Juju.</p>
81
<p>To start with, we will deploy Wordpress, by running this command:</p>
82
<pre>juju deploy wordpress</pre>
83
<p>Now juju will fetch the Wordpress charm and use it, through the bootstrap instance to request and deploy whatever resources it needs to set up this service.</p>
84
<p>Wordpress needs a database though, so we will also deploy one of those:</p>
85
<pre>juju deploy mysql</pre>
86
<p>Once again, juju will do whatever is necessary to deploy this service for you, and it may take some time for the command to return.</p>
87
<p class="note"><strong>Note:</strong> If you want to get more information on what is actually happening, or to help resolve problems, you can add the -v switch to the juju command to get verbose output.</p>
88
<p>Although we have deployed Wordpress and a MySQL database, they are not linked together in any way yet. To do this we should run:</p>
90
<pre>juju add-relation wordpress mysql</pre>
92
<p>This command uses information provided by the relevant charms to associate these services with each other in whatever way makes sense. There is much more to be said about linking services together which <a href="#add-relation">is covered in the juju command documentation</a>, but for the moment, we just need to know that it will link these services together.</p>
93
<p>In order to make our Wordpress public, we now need to expose this service:<p>
94
<pre>juju expose wordpress</pre>
95
<p>This service will now be configured to respond to web requests, so visitors can see it. But where exactly is it? If we run the juju status command, we will be able to see what services are running, and where they are located.<p>
96
<pre>juju status</pre>
97
<p>The output from this command should look something like this:</p>
102
agent-state: started
103
agent-version: 1.10.0
104
dns-name: ec2-50-16-167-135.compute-1.amazonaws.com
105
instance-id: i-781bf614
106
series: precise
108
agent-state: started
109
agent-version: 1.10.0
110
dns-name: ec2-23-22-225-54.compute-1.amazonaws.com
111
instance-id: i-9e8927f6
112
series: precise
114
agent-state: started
115
agent-version: 1.10.0
116
dns-name: ec2-54-224-220-210.compute-1.amazonaws.com
117
instance-id: i-5c440436
118
series: precise
121
charm: cs:precise/mysql-18
122
exposed: false
123
relations:
124
db:
125
- wordpress
126
units:
127
mysql/0:
128
agent-state: started
129
agent-version: 1.10.0
130
machine: "1"
131
public-address: ec2-23-22-225-54.compute-1.amazonaws.com
132
wordpress:
133
charm: cs:precise/wordpress-12
134
exposed: true
135
relations:
136
db:
137
- mysql
138
loadbalancer:
139
- wordpress
140
units:
141
wordpress/0:
142
agent-state: started
143
agent-version: 1.10.0
144
machine: "2"
145
public-address: ec2-54-224-220-210.compute-1.amazonaws.com
147
<p>There is quite a lot of information here. the first section, titled <strong>machines:</strong>, details all the instances which are currently running. For each you will see the version of Juju they are running, their hostname, instance id and the series or version of Ubuntu they are running.</p>
148
<p>After that, the sections list the services which are currently deployed. The information here differs slightly according to the service and how it is configured. It will however, always list the charm that was used to deploy the service, whether it is exposed or not, its address and whatever relationships exist.</p>
149
<p>From this status readout, we can see that wordpress is exposed and ready. If we simply copy the address into a web browser, we should be able to see it running</p>
150
<img src="./media/getting_started-wordpress.png" alt="Image showing wordpress in a web browser" >
151
<p>Congratulations, you have just deployed a service with Juju!</p>
152
<p>Now you are ready to deploy whatever service you really want from the 100s available at the <a href="http://jujucharms.com">Juju Charm Store.</a></p>
153
<p>To remove all current deployments and clear up everything in your cloud, you can run the command:</p>
154
<pre><code>juju destroy-environment </code></pre>
155
<p>This will remove everything, including the bootstrap node.</p>
156
<p>To learn more about charms, including configuring options and managing running systems, you should continue to <a href="./charms.html">read the charm documentation.</a></p>