Changes between Version 86 and Version 87 of InstallationGuidelines/Amazon


Ignore:
Timestamp:
10/22/14 10:22:04 (10 years ago)
Author:
Fran Boon
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • TabularUnified InstallationGuidelines/Amazon

    v86 v87  
    77Users who are using the free tier: Remember - after 750 hours, your trial will end and the credit card on file will be charged based on the rates shown in EC2. You can prevent these charges by closing the AWS account from the [https://portal.aws.amazon.com/gp/aws/manageYourAccount/ AWS account management page].
    88
    9 
    109== 1. Create AWS Account ==
    11 
    12 If you haven't already, create an Amazon AWS account through [http://aws.amazon.com/free/?sc_channel=PS&sc_campaign=AWS_Free_Tier_2013&sc_category=aws_cloud_computing&sc_publisher=Google&sc_medium=Brand_Core_AWS_E&sc_content=31496064882&sc_detail=Amazon%20-%20aws&sc_matchtype=e&trk=AWS_Free_Tier_2013/ their site].[[BR]]
    13 After creating your account, head to the [https://console.aws.amazon.com/console/home?#/ management console] and set up an instance of EC2. Instructions to do this can be found in the [http://aws.amazon.com/documentation/ec2/ Amazon EC2 Documentation].
    14 
    15 === Regions & Zones ===
     10If you haven't already, create an Amazon AWS account through [http://aws.amazon.com/free/ their site].
     11
     12== 2. Create Instance ==
     13=== Step 1: Log in to the Management Console ===
     14* https://console.aws.amazon.com
     15
     16=== Step 2: Select a Region ===
    1617Amazon supports multiple Regions in order to provide a service closest to your users.
    17 * Namespaces of Instances, Volumnes & Snapshots are unique only within a Region.
     18* Namespaces of Instances, Volumes & Snapshots are unique only within a Region.
    1819* Within each Region, there are a couple of Availability Zones to allow spreading the risk across different facilities.
    1920* Volumes are located within a specific Availability Zone
    2021* Bandwidth transfers are free within an Availability Zone
    2122
    22 == 1. Create Instance ==
    23 
    24 === Step 1: Choose an Amazon Machine Image (AMI) ===
    25 * Recommend using the AWS Marketplace Debian 64-bit image (as this has a sufficiently large HDD to start with)
     23=== Step 3: Launch a new Instance ===
     24
     25=== Step 4: Choose an Amazon Machine Image (AMI) ===
     26* Recommend using the AWS Marketplace Debian 64-bit image (as this has a sufficiently large HDD to start with & is EBS-backed, so has persistent storage even whilst powered down)
    2627* In time we may provide pre-built "Sahana Eden" AMIs (some old unmaintained ones may be available in some regions)
    2728* The normal production 'small' instance can only run 32-bit.
    2829* Larger production instances can only run 64-bit, so can't have the exact same image used.
    2930
    30 === Step 2: Choose an Instance Type ===
     31=== Step 5: Choose an Instance Type ===
    3132* The free starter 'micro' instance is flexible as it can run both 32-bit & 64-bit Operating Systems.
    3233
    33 === Step 3: Configure Instance Details ===
     34=== Step 5: Configure Instance Details ===
    3435Default settings are fine
    3536
    36 === Step 4: Add Storage ===
    37 Instance Persistence:
    38 * EBS-backed instances have persistent storage even whilst powered down, which is very useful.
    39  * For DB I/O performance increase can stripe multiple EBS
    40   * monitoring data available to see if this is the issue
    41 
    42 === Step 5: Tag Instance ===
    43 Default settings are fine
    44 
    45 === Step 6: Configure Security Group ===
    46 You will need to set the following Inbound Rules:
    47 * SSH | TCP | 22
    48 * HTTP | TCP |80
    49 Restricting the source will add further security
    50 
    51 You can either create a '''new''' security group or Select an '''existing''' security group. With the existing security group, you may have to set the inbound rules via the EC2 dashboard:  NETWORK & SECURITY > Security Groups
    52 
    53 
    54 
    55 == 2. Associate Elastic IP ==
     37=== Step 6: Create !KeyPair ===
     38Ensure that you keep the generated private key safe...save as {{{private.pem}}}
     39
     40=== Step 7: Associate Elastic IP ===
    5641Each time you start an instance up, it will be assigned a new IP ('Public DNS') although this can be overcome using an Elastic IP:
    5742
     
    60453. Associate Address. Set the instance to your new instance
    6146
    62 * Remember to set up Reverse DNS for your Elastic IP to be able to send emails reliably:
    63  * https://aws-portal.amazon.com/gp/aws/html-forms-controller/contactus/ec2-email-limit-rdns-request
    64 * If you have a free EC2 instance, be sure to release your Elastic IP if you shut down your instance.
    65   IPv4 addresses are a "scarce resource" so Amazon will charge you for wasting one if you keep it assigned
    66   to your instance while you are not using it.
    67 
    68 == 3. Download SSH Keys ==
    69 This can provide an early stumbling block.
    70 * Each instance created needs to start with a unique SSH keypair
    71 * When setting up an instance, be sure to safely download the private key.
    72 * In order to get the public key (needed by SecureCRT for instance) then you need to login using CLI & retrieve it (username 'admin' for the AWS !MarketPlace Debian, username 'root' for some other Images):
     47Remember to set up Reverse DNS for your Elastic IP to be able to send emails reliably:
     48* https://aws-portal.amazon.com/gp/aws/html-forms-controller/contactus/ec2-email-limit-rdns-request
     49
     50NB If you have a free EC2 instance, be sure to release your Elastic IP if you shut down your instance. IPv4 addresses are a "scarce resource" so Amazon will charge you for wasting one if you keep it assigned to your instance while you are not using it.
     51
     52=== Step 8: Configure Security Group ===
     53NETWORK & SECURITY > Security Groups
     54
     55You will need to set the following Inbound Rules:
     56* HTTP | TCP |80
     57* SSH | TCP | 22
     58Restricting the source will add further security, but obviously also restricts your ability to administer
     59
     60=== Step 9: Gain SSH access ===
     61In order to get the public key (needed by SecureCRT for instance) then you need to login using CLI & retrieve it (username 'admin' for the AWS !MarketPlace Debian, username 'root' for some other Images):
    7362{{{
    7463ssh -l admin -i private.pem <hostname>
     
    7665
    7766}}}
     67
     68On Windows, you can use Cygwin to get a CLI SSH client.
     69
    7870SecureCRT needs the private key storing as <filename> & the public as <filename.pub> (all on one line)
    7971
    80 SSH will also need to be enabled in your Firewall policy (restrict the IP source, if possible)
    81 
    82 === Recovering From a Lost Keypair ===
     72==== Recovering From a Lost Keypair ====
    8373If you lose your keypair then you need to:
    8474* Create a new keypair in the AWS console & download the generated private key
     
    9484Thanks to: http://itkbcentral.blogspot.co.uk/2011/07/replace-lost-key-pair-existing-aws-ec2.html
    9585
    96 == 4. Optimize Instance ==
    97 === Add Swapfile (Optional) ===
    98 You can add swap from a swap file in order to improve performance (especially on a Micro instance):
     86=== Step 10: Add Swapfile ===
     87You should add swap from a swap file in order to improve performance (especially on a Micro instance):
    9988{{{
    10089sudo su -
     
    111100}}}
    112101
    113 === Add Swap partition (Optional) ===
     102== 3. Install Sahana ==
     103* Copy the installation and configuration scripts into the launched instance (assuming [wiki:InstallationGuidelines/Linux/Server/CherokeePostgreSQL Cherokee & PostgreSQL]):
     104{{{
     105wget http://eden.sahanafoundation.org/raw-attachment/wiki/InstallationGuidelines/Linux/Server/CherokeePostgreSQL/install-eden-cherokee-postgis.sh
     106chmod a+x install-eden-cherokee-postgis.sh
     107wget http://eden.sahanafoundation.org/raw-attachment/wiki/InstallationGuidelines/Linux/Server/CherokeePostgreSQL/configure-eden-cherokee-postgis.sh
     108chmod a+x configure-eden-cherokee-postgis.sh
     109
     110}}}
     111
     112* Run the install-eden-cherokee-postgis.sh script. [Note: This step takes about 10min - grab a coffee]
     113{{{
     114sudo su -
     115./install-eden-cherokee-postgis.sh
     116
     117}}}
     118
     119If you wish to update your site from an alternate github repo this can be done using:
     120* ConfigurationGuidelines#SwitchtoanalternateGitHubrepo
     121
     122== 4. Configure Sahana ==
     123Run configure-eden-cherokee-postgis.sh to configure the instance:
     124{{{
     125sudo su -
     126./configure-eden-cherokee-postgis.sh
     127
     128}}}
     129
     130* Add your FQDN to {{{/etc/hosts}}} to ensure emails are accepted by all remote mailers:
     131{{{
     132vim /etc/hosts
     133127.0.0.1 host.domain host localhost
     134
     135/etc/init.d/exim4 restart
     136}}}
     137
     138See [UserGuidelines/Admin/Configuration Admin Guide] - especially read how to set the sender & approver emails
     139
     140== 5. Add a Test site (Optional) ==
     141This script requires at least 4Gb on the main disk
     142
     143{{{
     144sudo su -
     145wget http://eden.sahanafoundation.org/raw-attachment/wiki/InstallationGuidelines/Linux/Server/CherokeePostgreSQL/add_test_site.sh
     146chmod a+x add_test_site.sh
     147./add_test_site.sh
     148
     149}}}
     150
     151NB This script has an issue & the file /etc/cherokee/cherokee.conf needs to be manually edited to fix the lines wrapping for Source 1 (fix welcomed!)
     152
     153== 6. Add a Demo site (Optional) ==
     154This script requires at least 6Gb on the main disk.
     155
     156This script assumes that a Test site has already been installed
     157
     158{{{
     159sudo su -
     160wget http://eden.sahanafoundation.org/raw-attachment/wiki/InstallationGuidelines/Linux/Server/CherokeePostgreSQL/add_demo_site.sh
     161chmod a+x add_demo_site.sh
     162./add_demo_site.sh
     163
     164}}}
     165
     166NB This script has an issue & the file /etc/cherokee/cherokee.conf needs to be manually edited to fix the lines wrapping for Source 1 (fix welcomed!)
     167
     168== Optional Instance Adjustments ==
     169=== Add Swap partition ===
    114170You can add a swap partition in order to improve performance further:
    115171* Create Volume in AWS Console (e.g. 4Gb)
     
    127183
    128184}}}
    129 === Add Storage (Optional) ===
     185
     186=== Grow the Diskspace ===
     187The initial disk space on some images is just 1GB. If you have this, then this should be grown to 4Gb (don't just size the volume to 4Gb to start with as the image only uses 1Gb of it!)
     188* this is still within the 10Gb free tier.
     189* 4Gb is needed for Prod & Test instances. If you just need a test then 3Gb is sufficient.
     190
     191=== Add Storage ===
    130192If you need an additional disk for Storage then configure a volume in the AWS console, attach as /dev/sdb1, then in Linux:
    131193{{{
     
    143205mount /data
    144206}}}
    145 == 5. Install Sahana ==
    146 * Copy the installation and configuration scripts into the launched instance (assuming [wiki:InstallationGuidelines/Linux/Server/CherokeePostgreSQL Cherokee & PostgreSQL]):
    147 {{{
    148 wget http://eden.sahanafoundation.org/raw-attachment/wiki/InstallationGuidelines/Linux/Server/CherokeePostgreSQL/install-eden-cherokee-postgis.sh
    149 chmod a+x install-eden-cherokee-postgis.sh
    150 wget http://eden.sahanafoundation.org/raw-attachment/wiki/InstallationGuidelines/Linux/Server/CherokeePostgreSQL/configure-eden-cherokee-postgis.sh
    151 chmod a+x configure-eden-cherokee-postgis.sh
    152 
    153 }}}
    154 
    155 * Run the install-eden-cherokee-postgis.sh script. [Note: This step takes about 10min - grab a coffee]
    156 {{{
    157 sudo su -
    158 ./install-eden-cherokee-postgis.sh
    159 
    160 }}}
    161 
    162 If you wish to update your site from an alternate github repo this can be done using:
    163 * ConfigurationGuidelines#SwitchtoanalternateGitHubrepo
    164 == 6. Configure Sahana ==
    165 Run configure-eden-cherokee-postgis.sh to configure the instance:
    166 {{{
    167 sudo su -
    168 ./configure-eden-cherokee-postgis.sh
    169 
    170 }}}
    171 
    172 * Add your FQDN to /etc/hosts to ensure emails are accepted by all remote mailers:
    173 {{{
    174 vim /etc/hosts
    175 127.0.0.1 host.domain host localhost
    176 
    177 /etc/init.d/exim4 restart
    178 }}}
    179 
    180 [UserGuidelines/Admin/Configuration Admin Guide] - especially read how to set the sender & approver emails
    181 
    182 == 7. Add a Test site (Optional) ==
    183 This script requires at least 4Gb on the main disk
    184 
    185 {{{
    186 sudo su -
    187 wget http://eden.sahanafoundation.org/raw-attachment/wiki/InstallationGuidelines/Linux/Server/CherokeePostgreSQL/add_test_site.sh
    188 chmod a+x add_test_site.sh
    189 ./add_test_site.sh
    190 
    191 }}}
    192 
    193 NB This script has an issue & the file /etc/cherokee/cherokee.conf needs to be manually edited to fix the lines wrapping for Source 1 (fix welcomed!)
    194 
    195 
    196 == 8. Add a Demo site (Optional) ==
    197 This script requires at least 6Gb on the main disk.
    198 
    199 This script assumes that a Test site has already been installed
    200 
    201 {{{
    202 sudo su -
    203 wget http://eden.sahanafoundation.org/raw-attachment/wiki/InstallationGuidelines/Linux/Server/CherokeePostgreSQL/add_demo_site.sh
    204 chmod a+x add_demo_site.sh
    205 ./add_demo_site.sh
    206 
    207 }}}
    208 
    209 NB This script has an issue & the file /etc/cherokee/cherokee.conf needs to be manually edited to fix the lines wrapping for Source 1 (fix welcomed!)
    210 
    211 
    212 == 9. Grow the Diskspace (Optional) ==
    213 The initial disk space on some images is just 1GB. If you have this, then this should be grown to 4Gb (don't just size the volume to 4Gb to start with as the image only uses 1Gb of it!)
    214 * this is still within the 10Gb free tier.
    215 * 4Gb is needed for Prod & Test instances. If you just need a test then 3Gb is sufficient.
     207
     208=== Disk Striping (Optional) ===
     209For DB I/O performance increase can stripe multiple EBS
     210* monitoring data is available to see if this is the issue
     211
     212== Installing Deployment Coapp on EC2 ==
     213See: InstallationGuidelines/Amazon/Setup
    216214
    217215== CLI Tools ==
     
    306304
    307305== Building AMIs for easier deployment ==
    308 If your region doesn't yet have a Sahana AMI in, then it is easy to create one which allows easier deployment of future instances for both you & others. The only cost to you is a small amount of time to publish it & then using up your 1Gb Snapshot allowance within the free tier.
    309 
    310 * Install the instance as-above
    311 * Don't run the configure script
    312 * Shutdown the EBS instance.
    313 {{{
    314 shutdown -h now
    315 
    316 }}}
    317 
    318 * Go to your aws console for the current region at [https://console.aws.amazon.com/ec2/home | EC2 Console]
    319 
    320 * Select the debian instance you just prepared in the "Instances"
    321 
    322 * Select " Create Image (EBS AMI) " in the "Instance Actions" drop down.
    323 
    324 [[Image(http://eden.sahanafoundation.org/raw-attachment/wiki/InstallationGuidelines/Amazon/create-image.png, 75%)]]
    325 
    326 * Choose an Image name - Lets say - "Sahana Eden" and fill in a description.
    327 
    328 [[Image(http://eden.sahanafoundation.org/raw-attachment/wiki/InstallationGuidelines/Amazon/create-image-config.png, 75%)]]
    329 
    330 * Click "Create this Image"
    331 
    332 * Go to the "AMIS" menu and select "Owned by me" and "All Platforms" in the Viewing dropdown.
    333 
    334 [[Image(http://eden.sahanafoundation.org/raw-attachment/wiki/InstallationGuidelines/Amazon/ami-built.png, 75%)]]
    335 
    336 * Wait for about 5 minutes and hit refresh for the AMI you just built to appear.
    337 
    338 * Select the AMI and click the Permissions button - Select public, to make the image public.
    339 
    340 [[Image(http://eden.sahanafoundation.org/raw-attachment/wiki/InstallationGuidelines/Amazon/ami-permissions.2.png, 75%)]]
    341 
    342 Keep Templates as EBS Volumes as this is cheaper than Snapshots
     306See: InstallationGuidelines/Amazon/AMI
    343307
    344308== Troubleshooting ==
    345 To troubleshoot any errors in installation of EC2 visit its [http://aws.amazon.com/documentation/ec2/ documentation]. If you encounter problems installing eden on the EC2 instance, you can contact us via [http://webchat.freenode.net/?channels=sahana-eden&uio=d4/ IRC] or the [https://groups.google.com/forum/#!forum/sahana-eden/ mailing list].
    346 
    347 == Installing Deployment Coapp on EC2 ==
    348 
    349 * Once you've registered for Amazon's Web Services, login to the [https://console.aws.amazon.com/ec2/v2/home EC2 Management Console]. You'll be greeted with the EC2 dashboard as in the picture below
    350 
    351 [[Image(http://eden.sahanafoundation.org/raw-attachment/wiki/InstallationGuidelines/Amazon/Dashboard.png, 75%)]]
    352 
    353 * Next, click on Launch Instance. This new instance will act as a master node for future deployments. We'll use Debian as the OS but other distributions may be supported in the future. In the "Select your Amazon Machine Image" pane, select "AWS Marketplace" from the left sidebar. Scroll down, click on "Operating Systems" and select "Debian GNU/Linux"
    354 
    355 [[Image(http://eden.sahanafoundation.org/raw-attachment/wiki/InstallationGuidelines/Amazon/SelectAMI.png, 75%)]]
    356 
    357 * In the next step, select the instance depending on your requirements.
    358 
    359 * Next, in the Configure Instance pane, expand the Advanced Details tab and enter the contents of https://github.com/gnarula/eden_playbook/blob/master/user-data.sh in the User-Data field.
    360 [[Image(http://eden.sahanafoundation.org/raw-attachment/wiki/InstallationGuidelines/Amazon/UserData.png, 75%)]]
    361 
    362 * Create a new security group with a rule for SSH and HTTP as shown in the screenshot below.
    363 
    364 [[Image(http://eden.sahanafoundation.org/raw-attachment/wiki/InstallationGuidelines/Amazon/SecurityGroup.png, 75%)]]
    365 
    366 * Finally, review the configuration and launch the instance. You'll be prompted to select an existing key pair or generate a new one. In case you're a new user or you don't have access to your key, generate a new keypair, save it and proceed.
    367 
    368 That's it! The instance will have Deployment Coapp Installed and may be used to install Eden on that instance or any other remote servers. Do note that the installation takes some time (~5 minutes) even after the EC2 Web UI states the instance as "Running". The Coapp may be accessed by browsing to http://instance-public-ip/ or http://<public-dns>
    369 
    370 Logs for the process may be found by sshing into the newly created instance with your key and viewing /var/log/user-data.log and /var/log/syslog
    371 
    372 
    373 == Next ==
    374 [wiki:UserGuidelines/Admin Administration Guide]
     309To troubleshoot any errors in installation of EC2 visit its [http://aws.amazon.com/documentation/ec2/ documentation]. If you encounter problems installing eden on the EC2 instance, you can contact us via [wiki:Chat IRC] or the [Wiki:MailingList mailing list].
     310