deploy mediawiki using fiware lab facilities · deploy mediawiki using fiware lab facilities josé...
TRANSCRIPT
Deploy Mediawiki using Fiware Lab facilities
José Ignacio Carretero Guarde
R&D Engineer at Telefonica I+D. In charge of Spain FIWARE Lab Node
Mediawiki and FIWARE Lab APIs (Openstack)
2
3
What Mediawiki has to do with FIWARE Lab (I)
Nothing?
4
...But it could be good vehicle to show some things about FIWARE Lab IaaS reference Implementation GE.
What Mediawiki has to do with FIWARE Lab (II)
5
● Why Wikimedia? – If it has nothing to do with FIWARE.● It has a backend Database (Mysql)● It has a Frontend Web Server (Apache)● I Allows me to show some tools: IaaS GE.
● I Know how it Works, So I can automate it.● Images and files are stored in Apache (…/wiki/images)● Data in the database is stored in /var/lib/mysql
Installing an Applicacion: Mediawiki
6
● https://catalogue.fiware.org/enablers/iaas-ge-fiware-reference-implementation/documentation
● “We are using OpenStack Vanilla release for the IaaS GE.”
● Openstack APIs work:● Compute APIs● Block Storage APIs● Image Service● Object Storage
● There are CLIs writen in Python...
IaaS GE – FIWARE Reference Implementation
7
# Assuming Python 2.7, pip and virtualenv installed
virtualenv osdemo
source osdemo/bin/activate
pip install pythonopenstackclient
pip install pythonswiftclient
How to locally install the CLIs
A First Approach to the Installation Process
8
9
Installing an Applicacion: Mediawiki (I)
10
● Virtual Machines – Instances● Instances are managed by Nova.
● We need a few things before deploying an instance● A Keypair
● In order to be Able to SSH our instances● Security Groups/Rules
● Because OpenStack acts like a closed Firewall for every instance.
Create a first VM
11
# Creating the keypair
nova keypairadd summitkp | tee summitkp && chmod 400 summitkp
# Creating the security group and rules
nova secgroupcreate openthings opens_some_ports
nova secgroupaddrule openthings tcp 22 22 0/0
nova secgroupaddrule openthings tcp 80 80 0/0
nova secgroupaddrule openthings icmp 1 1 0/0
# Creating the security group and rules (What I did!):
nova secgroupcreate allopen open_everything
nova secgroupaddrule allopen tcp 1 65535 0/0
nova secgroupaddrule allopen ucp 1 65535 0/0nova secgroupaddrule allopen icmp 1 1 0/0
Nova: Key Pairs and Security Groups
12
● Boot our first instance with some parameters● (At least) One network ID to allow networking● Flavor – The size of the Instance● Our Security Group – our firewall configuration.● A Keypair – To SSH our instance ● The base image – I’ll use an Ubuntu in the demos.
● Assign a floating IP to some of our instances● A Floating IP is needed to SSH our instances. We might not be
able to SSH private IPs● 1 Floating IP is allowed per User.
Create a first VM (ii)
13
# Find the network ID
NETUUID=$(openstack network list | awk '/ nodeintnet01 / {print $2}')
# Boot Virtual Machinenova boot nic netid=$NETUUID image base_ubuntu_14.04 \ keyname summitkp \ securitygroups allopen \ flavor m1.small mydatabase
# Creating a floating IP:
PUBLIC_EXT_NET=publicextnet01
openstack floating ip create $PUBLIC_EXT_NET
# Associate the IP to our instance:
nova list floating ip create $PUBLIC_EXT_NET
openstack floating list
nova floatingipassociate mydatabase 130.206.112.0
Nova: Boot and add a floating IP
14
# Get console URL
nova getvncconsole mydatabase novnc
# Creating the security group and rules
nova consolelog mydatabase
Nova: Consoles
15
● Compute is thought to Compute● When Instances die, Ephemeral disks die
● Persistent Disk – Block Storage● Cinder manages Persistent Disks● The disks, once created can be attached to instances● Instances must format (once) and mount the disks before use● Persistent disk will survive Instances.
● A way to Keep data apart from computation.
Cinder: Ephemeral Vs Persistent disks
16
# Create a Persistent disk
openstack volume create size 1 myvolume
openstack volume list
VOLUMEID=$(openstack volume list | awk '/ myvolume / {print $2}')
# Attaching the volume to the instance
nova volumeattach mydatabase $VOLUMEID
# Or attaching at boot time…nova boot nic netid=$NETUUID image base_ubuntu_14.04 \ keyname summitkp \ securitygroups allopen \ blockdevicemapping vdb=$VOLUMEID flavor m1.small mydatabase
Cinder: Persistent Disk Creation
Automate!!!
17
18
● Increase Productivity● Automated processes reduce defects● Reduce Human Errors● Processes are run effortlessly● Processes are more flexible => Changes are easier● Increase satisfaction● … You can write many other things here
● … And here.
Automate: Why?
19
Automate: Using GUI (Cloud Portal)
(maybe... )Too many clicks
(maybe)...Too error prone
(almost)...Impossible automation
Easy to use
20
● Tools to automate● Puppet/Chef
● An Agent is required in the instance● Ansible
● Many features, even some for OpenStack● Some OpenStack Tools
● Heat / Murano● Ad Hoc Scripts
● This time it was my option, so I can show some CLI commands
Automate: How?
21
Installing an Applicacion: Mediawiki (II)
/var/www/html/wiki/images /var/lib/mysql
apache-vol kmysql-vol
22
● Create the Persistent Disk (if it doesn’t exists)● Boot the VM attaching the Persistent Disk and injecting a Script● The Script
● Formats the Persistent Disk and mounts it (using /etc/fstab) ● /var/lib/mysql
● Installs MySQL-Server software● Creates Database and user for the Wiki.
One Installation Process: Database
23
● Create the Persistent Disk (if it doesn’t exists)● Boot the VM attaching the Persistent Disk and injecting a Script● The Script
● Formats the Persistent Disk ● Installs Apache, php5, libs, etc● Downloads Wikimedia and untars it /var/www/html● Downloads SyntaxHighlight_plugin and untars it.● Mounts the disk (/var/www/html/wiki/images)
● Creates a FloatingIP and associates it to the instance
One Installation Process: Apache
24
# Or attaching at boot time…nova boot nic netid=$NETUUID image base_ubuntu_14.04 \ keyname summitkp \ securitygroups allopen \ blockdevicemapping vdb=$VOLUMEID userdata oneScript flavor m1.small mydatabase
The new boot command for Nova
25
The Mediawiki Wizard
26
● Mediawiki installation can’t be automated… but● I can automate LocalSettings.php configuration● The Script
● Gets the Public IP of our apache● Sets the Logo, Extensions of Documents which can be uploaded● Configures SyntaxHighlight extension● Uploads LocalSettings.php and logo.jpg
Can’t automate everything... but almost
Some other tools: Images and Object Storage
27
28
● I can take Snapshots of my instances● So I can boot a preconfigured Instance● Glance - The image service is used to create Snapshots
● I’ve taken an Snapshot of my Database Instance ● The process takes some time...● It is a complicated process that involves many subprocesses
Snapshots from instances
29
# Create an Snapshot from an Instancenova imagecreate krtmysql krtmysqlsnp
# List imagesopenstack image list
# Delete imagesopenstack image delete $IMAGE_ID
Image Commands
30
● It stores static Objects● We can retrieve the objects in the future● Swift is the reference implementation of FIWARE’s Object
Storage GE● https://catalogue.fiware.org/enablers/object-storage-ge-fiware
-implementation● Objects are Stored in containers
● I’ve uploaded my Preconfigured Mediawiki in a .tgz file to Object Store
● Let’s use this in next Mediawiki installations (as a demo)
Object Storage
31
# Create a new Containerswift post summit
# Upload an object to the Containerswift upload summit wiki.tgz
# List Containers, list objects from a containerswift listswift list summit
# Retrieve an object from a containerswift download summit wiki.tgz
Swift Commands
32
# Retrieve an object from a container… In some scripts.token=($(openstack token issue | \ awk '/ id / || / project_id / {print $4}'))TOKEN=${token[0]}TENANT_ID=${token[1]}URL=http://130.206.112.3:8080/v1…# Use the token, and the tenant.swift osauthtoken $TOKEN osstorageurl=$URL/AUTH_$TENANT_ID download summit wiki.tgz
Swift Commands (to automate)
https://github.com/jicarretero/SummitMalaga2016
33
Thank you!
http://fiware.orgFollow @FIWARE on Twitter