본문 바로가기

OS & network/solaris

otn.oracle.com 에 기고한 기술문서가 퍼블리싱 되었습니다.

지난번에 오라클 (otn.oracle.com : 오라클 테크놀러지 네트워크 )와 오라클 공식블로그에 제가 기고한 글이 5월 1일 퍼블리싱 되었습니다.


짧은 영어실력에 콩글리쉬로 인한 수정, 변경 작업이 좀 많았지만, 어찌되었던 솔라리스 기술 문서를 오라클 커뮤니티에 공식적으로 퍼블리싱 한 것만으로 부족하지만 기쁨을 느낍니다.


이번 퍼블리싱 이후 조금더 왕성하게 영문으로 퍼블리싱 해서 국내 기술능력을 세계로 전파(?) 하는 ...노력을 해 볼 생각입니다.


해당 문서는 원래 초안을 한글로 만들고 영어를 일일히 바꾸는 작업을 했는데 , 정작 한글 자료가 없네요..ㅠㅠ

조만간 한글버전도 만들어서 블로그와 커뮤니티에 배포 토록 하겠습니다.



http://www.oracle.com/technetwork/articles/servers-storage-admin/sol-howto-webstorage-s111-1940332.html


https://blogs.oracle.com/OTNGarage/entry/how_to_build_a_cloud






본문은 아래와 같습니다.


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

by Suk Kim

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


Published April 2013

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.

If you'd like to download software, participate in forums, and get access to other technical how-to goodies in addition to content like this, become an OTN member. No spam!

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.

  1. 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.

    Figure 1

    Figure 1. Oracle VM VirtualBox

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

    Figure 2

    Figure 2. Adding a Disk

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

    Figure 3

    Figure 3. After More Disks Are Added

  4. Start Oracle Solaris using the Start icon in Oracle VM VirtualBox.
  5. 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.)
  6. 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: c7t2d0c7t3d0, andc7t4d0. 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
    

    Listing 1

Install the Apache and PHP Packages

  1. 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
    
  2. Download AjaXplorer from sourceforge.net using the wget command:

    root@solaris:~# wget  http://sourceforge.net/projects/ajaxplorer/files/ajaxplorer/stable-channel/4.2.3/ajaxplorer-core-4.2.3.tar.gz
    
  3. 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.

  4. 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
    
  5. 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.

  6. 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
    

    Listing 2

    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.

  7. 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

  1. 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
    
  2. 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.

    Notepost_max_size must always be greater than or equal to upload_max_filesize.

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

    root@solaris:~# svcadm restart http:apache22
    
  4. 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

  1. 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.

    Figure 4

    Figure 4. Security Warning

    Figure 5

    Figure 5. Connecting to AjaXplorer

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

    Figure 6

    Figure 6. Checking and Changing File Size Limits

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

    Figure 7

    Figure 7. Using the Web Storage from a Browser

  4. 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.

    Figure 8
    Figure 8. AjaXplorer for iOS
    Figure 9
    Figure 9. Server Settings
    Figure 10
    Figure 10. Created Server
    Figure 11
    Figure 11. Server Connection
    Figure 12
    Figure 12. File Access
     
  5. 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.

    Figure 13
    Figure 13. Connected Screen on Mobile Web Browser
    Figure 14
    Figure 14. Login Screen on Mobile Web Browser
    Figure 15
    Figure 15.Access to Files on Mobile Web Browser
     

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.

See Also

About the Author

Suk Kim is an Oracle Ace Director for Oracle Solaris in South Korea. He is also chairman of the Korea Oracle Solaris User Network, manager of Oracle Solaris TechNet, manager of the Solaris School community, an adjunct professor at Ansan University, and a senior system and security consultant at NoBreak Co., LTD.

Revision 1.0, 04/25/2013