How to Build a Web-Based Storage Solution Using Oracle Solaris 11.1

http://techsupportpk.blogspot.com/2013/06/how-to-build-web-based-storage-solution.html

How to build a cloud storage service similar to Dropbox using Oracle Solaris 11.1 and AjaXplorer.


Oracle Solaris 11 is a cloud operating system that is very powerful. Using Oracle Solaris 11, you will be able to provide various services. For example, it is possible to create storage that can be utilized by AjaXplorer, which provides Web-based access to files.

This article describes a PHP-based open source solution that uses AjaXplorer, Oracle Solaris 11.1, and Apache Web server (although other Web servers can be used) to build a cloud-based storage service that is similar to Dropbox.


Of course, you can also build the storage in the same way using AjaXplorer with other operating systems, such as Microsoft Windows, Mac OS X, and Linux. However, when using Oracle Solaris 11.1, you will be able to configure the storage in a more powerful and secure way by taking advantage of ZFS.

After you implement the solution described in this article, you will be able to use any Web browser to access the Web-based storage. In addition, you can use apps on Android and Apple iOS smartphones and tablets to access the storage.

Prerequisites

You can use Oracle VM VirtualBox to install Oracle Solaris 11.1 on a system. Or, if you already have Oracle Solaris 11.1 installed on a system, you can use that.
The following are the system requirements for Oracle VM VirtualBox:
  • At least 2 GB of memory (1 GB of memory is recommended to be assigned in Oracle VM VirtualBox)
  • At least 20 GB free disk space for Oracle VM VirtualBox and its image
Note: If instead of installing Oracle VM Virtual Box, you use a system that already has Oracle Solaris 11.1 installed, that system should have at least 1 GB of memory (2 GB is recommended). The approach described in this article uses Oracle VM VirtualBox to install Oracle Solaris 11.1.

Install Oracle Solaris and Configure ZFS Storage

Perform the following steps.
  • Using Oracle VM VirtualBox (shown in Figure 1), install Oracle Solaris 11.1 on your system.


Note: If you do not have Oracle VM VirtualBox installed, you can download it here and then refer to the Oracle VM VirtualBox User Manual for installation information. You can also download the Oracle Solaris 11.1 VM for Oracle VM VirtualBox image—a preinstalled virtual machine that provides a convenient way to evaluate Oracle Solaris 11 from inside Oracle VM VirtualBox—by referring to this article.


  • Add a disk to be used in the configuration ZFS, as shown in Figure 2.

  • Add three more disks. When you are done, Oracle VM VirtualBox Manager will look similar to Figure 3.

  • Start Oracle Solaris using the Start icon in Oracle VM VirtualBox.
  • After logging in, change to the root user by using the su command. (From Oracle Solaris 11, you cannot log in directly as root; you must log in as a regular user first.)
  • Use the commands shown in Listing 1 to configure the ZFS storage and configure a RAIDZ volume. 
The commands in Listing 1 create a ZFS pool named data_pool as a RAIDZ volume using three disks: c7t2d0, c7t3d0, and c7t4d0. Then the docs ZFS file system is created under data_pool.
root@solaris:~# format
Searching for disks...done


AVAILABLE DISK SELECTIONS:
       0. c7t0d0 <ATA-VBOX HARDDISK-1.0-16.00GB>
          /pci@0,0/pci8086,2829@d/disk@0,0
       1. c7t2d0 <ATA-VBOX HARDDISK-1.0-2.00GB>
          /pci@0,0/pci8086,2829@d/disk@2,0
       2. c7t3d0 <ATA-VBOX HARDDISK-1.0-2.00GB>
          /pci@0,0/pci8086,2829@d/disk@3,0
       3. c7t4d0 <ATA-VBOX HARDDISK-1.0-2.00GB>
          /pci@0,0/pci8086,2829@d/disk@4,0
Specify disk (enter its number): ^D

root@solaris:~# zpool create data_pool raidz c7t2d0 c7t3d0 c7t4d0
root@solaris:~# zfs create data_pool/docs 
 

Install the Apache and PHP Packages

  • To install the PHP Server and Apache Web Server packages (which come with Oracle Solaris 11), run the following commands:
 
root@solaris:~# pkg install pkg:/web/server/apache-22
root@solaris:~# pkg install pkg:/web/php-53
root@solaris:~# pkg install pkg:/web/server/apache-22/module/apache-php53 
 
 
root@solaris:~# wget  http://sourceforge.net/projects/ajaxplorer/files/ajaxplorer/stable-channel/4.2.3/ajaxplorer-core-4.2.3.tar.gz
 
  • Unpack the downloaded file using the following command.
root@solaris:~# tar xvfz /ajaxplorer-core-4.2.3.tar.gz
 
AjaXplorer is installed in the default location of the Apache server, which is /var/apache2/2.2/htdocs.

  • In order to construct Web storage under the htdocs directory, we proceed as follows. First, create a webhard subdirectory:

root@solaris:~# mkdir /var/apache2/2.2/htdocs/webhard

Next, change the mount point from /var/apache2/2.2/htdocs/webhard to data_pool/docs, which is Web-based storage:


root@solaris:~# zfs set mountpoint=/var/apache2/2.2/htdocs/webhard data_pool/docs

Or, if you don't want to change the mount point, you can achieve the same result by modifying the configuration of the Apache server.
As shown in Listing 2, you can enable deduplication for the ZFS file system, which is supported by the Oracle Solaris 11, and you can enable the compression feature, which allows efficient use of storage.
Deduplication and compression can be turned on or off during operation. Encryption, which was not used here, can be enabled only when you create a volume. Once a volume has been encrypted, the encryption setting cannot be changed.

root@solaris:~# zfs get all data_pool/docs | grep compress
data_pool/docs  compression           off                    local
data_pool/docs  compressratio         1.00x               

root@solaris:~# zfs get all data_pool/docs | grep dedup
data_pool/docs  dedup                 off                    local

root@solaris:~# zfs set compression=on data_pool/docs
root@solaris:~# zfs set dedup=on data_pool/docs

root@solaris:~# zfs get all data_pool/docs | grep dedup
data_pool/docs  dedup                 on                     local
root@solaris:~# zfs get all data_pool/docs | grep compress
data_pool/docs  compression           on                     local
data_pool/docs  compressratio         1.00x
 
Now, if the same file is copied, there is no change to the block due to deduplication saving space. Additional space is saved due to compression.
  • Run the following commands to set permissions to allow access to the directory:
root@solaris:~# chown -R webservd:webservd /var/apache2/2.2/htdocs
root@solaris:~# chmod -R 777 /var/apache2/2.2/htdocs/webhard

Configure Security

To set up HTTPS (SSL) communications, copy the ssl.conf file to create a key and certificate. After the copying and configuration tasks are complete, restart the Web service.

root@solaris:~# cp /etc/apache2/2.2/sample-config.d/ssl.conf /etc/apache2/2.2/conf.d
root@solaris:~# openssl genrsa -out server.key 2048
root@solaris:~# openssl req -new -key server.key -out server.csr
root@solaris:~# openssl x509 -req -days 3650 -in server.csr -signkey server.key -out server.crt
root@solaris:~# cp server.* /etc/apache2/2.2
root@solaris:~# svcadm restart http:apache22 

Note that due to limitations of the 32-bit PHP module, the file upload size is limited to 2 gigabytes. The upload limit is larger for a 64-bit module; unfortunately, only a 32-bit PHP module is available for Oracle Solaris for x86 platforms.
root@solaris:~# php -r 'echo PHP_INT_MAX;'
2147483647
  • 32 bit: 2147483647 (= 2G)
  • 64 bit: 9223372036854775807 (= 8388608T)
So, adjust the following values in /etc/php/5.3/php.ini:
  1. Set memory_limit to 128M.
  2. Set post_max_size to 2G.
  3. Set upload_max_filesize to 2G.
Note: post_max_size must always be greater than or equal to upload_max_filesize.

  • When you are finished making changes, restart the service.

root@solaris:~# svcadm restart http:apache22

I installed and configured the mod_secruity Apache module for security. If desired, you can install and configure it using the following commands.

root@solaris:~# pkg install web/server/apache-22/module/apache-security
root@solaris:~# cp /etc/apache2/2.2/sample-config.d/security2.conf /etc/apache2/2.2/conf.d

Connect to the Client

For a normal PC using a Web browser, the client connection and diagnostic messages are displayed first. Then, as shown in Figure 4, a security warning is displayed stating that the initial user ID and password are both admin. The password can be changed after the initial login.



In order to check and set the file size limit, select Settings and then select Global Configurations, Core Configs, Common 'uploader' plugins options, and Limitations. You can then see and change the file size, as shown in Figure 6.



  • As shown in Figure 7, using a Web browser, you can use the Web storage.

As shown in the Figure 8 through Figure 12, you can use the storage in the same way using an Android-based smartphone or an iPhone.
   
  

A native application, which costs US$0.99, is available for accessing AjaXplorer through an iPhone or iPad.
As shown in Figure 13 through Figure 15, even without using that app, you can use a mobile Web browser to access the storage.



Check ZFS Compression and Deduplication

File uploads and downloads are done brilliantly.
Use zpool list to verify that the deduplication and compression functions are working:
 
root@solaris:~# zpool list
NAME        SIZE  ALLOC   FREE  CAP  DEDUP  HEALTH  ALTROOT
data_pool  5.94G  28.2M  5.91G   0%  2.97x  ONLINE  -
rpool      15.6G  4.01G  11.6G  25%  1.00x  ONLINE  -
root@solaris:~# zfs list
NAME                        USED  AVAIL  REFER  MOUNTPOINT
data_pool                  20.0M  3.87G  36.0K  /data_pool
data_pool/docs             19.6M  3.87G  19.6M  /var/apache2/2.2/htdocs/webhard

If a file is duplicated, the value shown under the DEDUP column in the output of the zpool list command will be greater than 1.00x. In this example, the value is 2.97x, which means the file is compressed.
Also, zfs list shows information about the file systems.



Powered by Blogger.