Installing Alfresco Community 5.0.a With MySQL on Ubuntu Server 14.04 LTS. Sample with AWS EC2 and Tip With Content Stored on Amazon S3

Alfresco On AWS

Alfresco On AWS

At the top of almost every Linux distribution, the Debian-based Ubuntu surpasses all other Linux server distributions – from its simple installation to its excellent hardware discovery to its world-class commercial support.
Amazon Web Services is indisputably the largest cloud service provider.
MySQL is the world’s most popular open source database.
Alfresco is the world’s leading open-source alternative for document management and collaboration.

The purpose of this tutorial is to see how to set up an Enterprise Content Management system using these ‘world class tools’. The best way for Alfresco to interact with Amazon S3 is to use Alfresco S3 Connector, however this tool is available only for Alfresco Enterprise Edition. Since this tutorial is based on Alfresco Community, we will use a workaround.
Also there are several Alfresco AMIs in AWS Community AMIs, you can choose one of them if you want to make things simply, however they generally don’t have the latest version.

In an upcoming tutorial, we will see how to use Alfresco Enterprise Edition with Amazon RDS (PostGreSQL), Amazon EC2 (CentOS instance) and Amazon S3 (Alfresco S3 Connector).

For more information about Amazon Web Service and Alfresco, have a look at:

1. Parameters used in this tutorial

  • Linux Distribution and version: Ubuntu Server 14.04
  • Database: MySQL
  • Database Name: alfresco
  • Database username: alfrescouser
  • S3 Bucket name: myalfrescodata

2. Configure your Ubuntu Server, and create an Amazon S3 Bucket

For this tutorial I used an AMI in North Virginia Region (ubuntu-trusty-14.04-amd64-server-20140926 – AMI ID: ami-0070c468), and launched a t2.medium instance (4 GB memory). In security group associated with the intance I opened required Ports: SSH (22), FTP (21), Tomcat Server (8080), Tomcat SSL (8443) and LibreOffice (8100).

Create an Amazon S3 Bucket

For performance and cost reasons, it’s better to create the bucket in the same region as your EC2 instance, indeed you have a low latency and transferring data from an EC2 instance to a S3 Bucket in the same AWS Region is free of cost. You can create your S3 Bucket using AWS S3 Console or AWS CLI (Command Line Interface). By default AWS CLI is installed only on Amazon Linux AMIs. To install AWS CLI run:
$ sudo apt-get install awscli
Configure AWS CLI
$ aws configure
AWS Access Key ID [None]: MyAWSAccessKeyIdHere
AWS Secret Access Key [None]: MyAWSSecretKeyHere
Default region name [None]: us-east-1
Default output format [None]:

Create the Bucket:
$ aws s3 mb s3://myalfrescodata --region us-east-1
make_bucket: s3://myalfrescodata/

3. Install Alfresco Community 5.0.a with MySQL

Install and configure MySQL Server

$ sudo apt-get install mysql-server
$ mysql -u root -p
$ CREATE DATABASE alfresco DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
$ CREATE USER 'alfrescouser'@'localhost' IDENTIFIED BY 'alfrescouserPassword';
$ GRANT ALL ON alfresco.* TO 'alfrescouser'@'localhost' IDENTIFIED BY 'alfrescouserPassword' WITH GRANT OPTION;

Download Alfresco Community 5.0.a

$ wget http://dl.alfresco.com/release/community/5.0.a-build-00023/alfresco-community-5.0.a-installer-linux-x64.bin
$ sudo +x alfresco-community-5.0.a-installer-linux-x64.bin

By default Alfresco uses PostGreSQL as database, in order to use MySQL database, download its connector for Java and unzip the file (the last version is 5.1.33):
$ wget http://ftp.kaist.ac.kr/mysql/Downloads/Connector-J/mysql-connector-java-5.1.33.zip
$ sudo apt-get install unzip
$ sudo unzip mysql-connector-java-5.1.33.zip

Install Alfresco Community 5.0.a

$ sudo ./alfresco-community-5.0.a-installer-linux-x64.bin
Find below my settings:

—————————————————————
Installation Type

[1] Easy – Installs servers with the default configuration
[2] Advanced – Configures server ports and service properties.: Also choose optional components to install.
Please choose an option [1] : 2

—————————————————————
Select the components you want to install; clear the components you do not want
to install. Click Next when you are ready to continue.

Java [Y/n] :Y
PostgreSQL [Y/n] :N
Alfresco : Y (Cannot be edited)
SharePoint [Y/n] :Y
Web Quick Start [y/N] :Y
Google Docs Integration [Y/n] :Y
LibreOffice [Y/n] :Y
Is the selection above correct? [Y/n]:Y

—————————————————————
Installation folder

Please choose a folder to install Alfresco Community
Select a folder [/opt/alfresco-5.0.a]: /opt/alfresco

Have a look at JDBC URL and Driver here.

JDBC URL: [jdbc:postgresql://localhost/alfresco]: jdbc:mysql://localhost/alfresco?useUnicode=yes&characterEncoding=UTF-8
JDBC Driver: [org.postgresql.Driver]: org.gjt.mm.mysql.Driver
Database name: [alfresco]:alfresco
Username: []: alfrescouser
Password: :
Verify: :

—————————————————————
Tomcat Port Configuration
Please enter the Tomcat configuration parameters you wish to use.
Web Server domain: [127.0.0.1]: xx.xx.xx.xx
Tomcat Server Port: [8080]:
Tomcat Shutdown Port: [8005]:
Tomcat SSL Port [8443]:
Tomcat AJP Port: [8009]:

—————————————————————
Alfresco FTP Port
Please choose a port number to use for the integrated Alfresco FTP server.
Port: [21]:

—————————————————————
Alfresco RMI Port
Please choose a port number for Alfresco to use to execute remote commands.
Port: [50500]:

—————————————————————
Admin Password
Please give a password to use for the Alfresco administrator account.
Admin Password: :
Repeat Password: :

—————————————————————
Install as a service
You can optionally register Alfresco Community as a service. This way it will
automatically be started every time the machine is started.
Install Alfresco Community as a service? [Y/n]:Y

—————————————————————
LibreOffice Server Port
Please enter the port that the LibreOffice Server will listen to by default.
LibreOffice Server Port [8100]:

—————————————————————
Setup is now ready to begin installing Alfresco Community on your computer.
Do you want to continue? [Y/n]: Y

Once the install process started, copy MySQL Connector for Java in /opt/alfresco/tomcat/lib in a new SSH windows.


$ cp mysql-connector-java-5.1.33/mysql-connector-java-5.1.33-bin.jar /opt/alfresco/tomcat/lib

—————————————————————
Please wait while Setup installs Alfresco Community on your computer.

Installing
0% ______________ 50% ______________ 100%
#######################################

—————————————————————
Setup has finished installing Alfresco Community on your computer.

It is almost everything… at the end of the installation MySQL database is empty, the first launch of Alfresco takes some time, it creates DB tables and default data (http://MyPublicIPAddress:8080/share). These data are stored on EC2 EBS Volume, now we will see how to migrate these data in our Amazon S3 bucket.

4. Move ‘alf_data’ from EBS to S3

There is an Alfresco connector that provides a mechanism to store content in Amazon S3, however this connector is only available for Alfresco Enterprise users. If you are using the Community edition and would like to store your data only in Amazon S3, the only way to process at the moment is to mount the bucket as filesystem on your server.

Amazon does not recommend mounting an S3 bucket as a filesystem.

Mounting Amazon S3 Bucket as filesystem on our server

Install, Configure, and test s3fs-fuse

$ sudo apt-get update
$ sudo apt-get install build-essential gcc libfuse-dev fuse libcurl4-openssl-dev libxml2-dev mime-support build-essential libcurl4-openssl-dev
$ wget http://s3fs.googlecode.com/files/s3fs-1.63.tar.gz
$ sudo tar -xvzf s3fs-1.63.tar.gz
$ cd s3fs-1.63/
$ sudo ./configure --prefix=/usr
$ sudo make
$ sudo make install
$ sudo nano vi /etc/passwd-s3fs

Fill this file as follows: MyAWSAccessKeyId:MyAWSSecretKey
$ sudo chmod 600 /etc/passwd-s3fs
Create a directory to mount S3 bucket
$ sudo mkdir /mnt/myalfrescodata
Mount the s3 bucket
$ sudo s3fs myalfrescodata /mnt/myalfrescodata
Check if the S3 bucket is mounted
$ sudo df -h
You will note 256T of size, this is normal…
To mount automatically at boot, at this line to your /etc/fstab
$ nano /etc/fstab
s3fs#myalfrescodata /mnt/myalfrescodata fuse allow_other,_netdev,nosuid,nodev,url=https://s3.amazonaws.com 0 0

Move “alf_data” from EBS to S3

Stop Alfresco server
$ service alfresco stop
Copy “alf_data” to “/mnt/myalfrescodata”
$ sudo cp -R /opt/alfresco/alf_data/ /mnt/myalfrescodata
Change “dir.root” from “/opt/alfresco/alf_data” to “/mnt/myalfrescodata” in Alfresco global properties
$ sudo nano /opt/alfresco/tomcat/shared/classes/alfresco-global.properties
Start Alfresco Server
$ service alfresco start

That is ALL. Your Alfresco data are stored in your Amazon S3 Bucket.

For some tips in configuring Alfresco (CIFS, CPU, previews, etc.) have a look at this blog post.