Monday Feb 09, 2009

Alternate ways of getting pecl extensions to work in OpenSolaris

Earlier, I wrote this blog on how to use PECL extensions within OpenSolaris. Now, there will be some scenario where in a simple pecl install <extension name> might not work because of how the script might have been written or what external dependencies like it depends etc.

For example, if you wanted to get mailparse PECL extension working within opensolaris, you would obviously try the following command first

pfexec /usr/php/bin/pecl install mailparse


and would probably be scratching your head when you run into the below error ...

bash-3.2# /usr/php/bin/pecl install mailparse
downloading mailparse-2.1.4.tar ...                                                                                                                                                                                                         
Starting to download mailparse-2.1.4.tar (Unknown size)
........................................done: 188,416 bytes                                                                                                                                                                                 
9 source files, building
running: phpize                                                                                                                                                                                                                             
Configuring for:
PHP Api Version:         20041225                                                                                                                                                                                                           
Zend Module Api No:      20060613
Zend Extension Api No:   220060519                                                                                                                                                                                                          
building in /var/tmp/pear-build-defaultuser/mailparse-2.1.4
...

checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers. 

What the above error means that while PECL framework trying to build the mailparse extension , it is looking for a tool known as 're2c' (which is internally used by PHP). Unfortunately, this tool has not yet made its ways into OpenSolaris yet. I am pretty sure, this tool will soon make its way into OpenSolaris repository as well..

Okay, in these scenario, here is another quickie to get things going for you...

  • Within your OpenSolaris machine, manually download mailparse extension from PECL repository
  • run /usr/php/bin/phpize , followed by configure and build command.

[sriramn@sriramn]'~'>gunzip -c mailparse-1.1.4.tar.gz | tar xvfp -
[sriramn@sriramn]'~'> cd mailparse-1.1.4
[sriramn@sriramn]'~'>/usr/php/bin/phpize
[sriramn@sriramn]'~'>./configure --with-php-config=/usr/php/bin/php-config && gmake && gmake install


Now, mailparse extension should be available under /var/php/5.2/modules directory. If you would like to include any mailparse specific extension, you will need to define them within /etc/php/5.2/php.ini

Af course, for Apache/PHP module to load these new extensions, you will need to restart Apache/PHP server by doing some thing like.. I am sure, you know this already :-)

svcadm restart http:apache22

Using PEAR/PECL extensions within OpenSolaris

I ran into couple of questions by OpenSolaris users (unfortunately posted at various different places) wondering as to how to use PHP extensions either PEAR or PECL based extensions within OpenSolaris. In OpenSolaris, say to download and install - say any PECL extension, one would do some thing like

 

sriramn@sriramn:$ pfexec /usr/php/bin/pecl install <extension name>

The downloaded and installed extensions will be available at /var/php/5.2/modules location. 

Note: If any PECL extension depends on any third party library to be available on the system, please make sure that those libraries first exist on OpenSolaris by searching OpenSolaris pkg database

Similarly, if you would like to the most popular XML Parser PEAR extension within your application, you could simply run the following command..

sriramn@sriramn:$ pfexec /usr/php/bin/pear install XML_Parser

Lessons learnt with OpenSolaris 2008.11

Couple of weeks back, for some weird reason my desktop (running on OpenSolaris 2008.11) failed to boot successfully.  After some digging into the boot log files, it turned out that hald daemon does not want to start and this failed service is causing other dependent services to fail as well. I was charging my Palm Treo cell phone through USB within my OpenSolaris 2008.11 based workstation before it happened. Not sure, if it had anything to do with it. Once I recover my system, I will need to try it again to see if that is what kept the system from booting up successfully..

Since, this is my primary workstation, I decided to quickly restore my workstation using some of the tools provided by OpenSolaris 2008.11. Hope, some one wanting to recover their installation finds this useful.

One of the advantage(s) of OpenSolaris 2008.11 is that it uses the power of ZFS intrinsically to provide us with the ability to take a snapshot and rollback to the previous , if necessary. For example, OpenSolaris Boot Environment Manager (beadm(1M)Image Package Manager tool - pkg(1M) - instantly takes a ZFS snapshot of your boot environment and installation files after every successful operation. This allows us  to roll back to the snap shot if we screw some thing up and want to restore to previous state.

Now, in my case, I booted my system in single user mode and checked out the list of snapshots available for my boot environment by running the following command:

sriramn@sriramn:~$ pfexec beadm list -s

(-s informs beadm command to provide the list of snapshots)

(I was doing all this in single user mode. So, I haven't written down the output here.. )

Now, in my case, I was not able to use those snapshot(s) because I had upgraded my zpool to run on newer version of kernel. If I hand't upgraded my zpool , I could have simply done some thing like 

sriramn@sriramn:~$ pfexec beadm create -e opensolaris@install opensolaris-1

sriramn@sriramn:~$ pfexec beadm activate opensolaris-1

sriramn@sriramn:~$ pfexec init 6

Well, in any case, this is what I had to do to recover my system

  • Use OpenSolaris 2008.11 LiveCD to boot up my system. Unforuntately, OpenSolaris LiveCD based installer does not allow one to do reinstallation.So, I had to backup my home directory (using zfs send along with zfs receive ) before proceeding to install.
  • Opened a command line terminal window to back up my home directory to an external hard disk by doing some thing like

  • sriramn@sriramn:~$ pfexec zpool import -f rpool (this is where my corrupted opensolaris installation along with my home directory exists)

    sriramn@sriramn:~$ pfexec zfs list

    (above command should list all the dataset that is available in the pool. You could use this information to determine which one to be backed up). 

           NAME                               USED  AVAIL  REFER  MOUNTPOINT
           rpool/export                         69.9G   144G    19K  /export
           rpool/export/home                    69.9G   144G  2.22G  /export/home
           rpool/export/home/sriramn            67.7G   144G  66.6G  /export/home/sriramn

    sriramn@sriramn:~$ pfexec zfs snapshot rpool/export/home/sriramn@jan09

    sriramn@sriramn:~$ pfexec zfs send rpool/export/home/sriramn@jan09 | gzip > /mnt/backupfile.gz

  • Finally, I had to start a new installation by clicking on 'Install Now' icon. Once the system came up successfully, I simply recovered my old data by running the following command

<my external had disk is mounted as /mnt where I have saved a ZFS stream of my home directory to /mnt>
sriramn@sriramn:~$ gunzip -c /mnt/backupfile.gz | pfexec /usr/sbin/zfs recv rpool/export/home/sriramn@jan09


Thought, I would capture some of the lessons that I have learnt during this recovery experience...
  • Think twice before running 'zpool update' on your OpenSolaris 200[8-9].xx based desktop.  Why ?
    • Within OpenSolaris, invoking zpool upgrade command ensures that your disk pool is instantly converted to run on newer version of ZFS there by supporting the newer features of ZFS. However, older version of OpenSolaris kernel will not be able to read your data any more. 
    • If you would like to know what is in each version of ZFS, you could simply run the following command from the command line
      • pfexec /usr/sbin/zpool upgrade -v
    • For example, with OpenSolaris 2008.11 (build 101b), released version of ZFS is version 13 and with the latest released Nevada build 106, ZFS version is 14 !. Now, let us say, if you update your system to run on Nevada build 106, and then you explicitly invoked zpool upgrade , now you will not be able to use your OpenSolaris 2008.11 LiveCD and access your home directory !
  • Take regular snapshot of your file system as well as boot environment because unlike other platforms, snapshots on ZFS doesn't cost that much in space and the benefits are huge.. OpenSolaris installer automatically create a '@install' snapshot of the boot environment as well as the files created as part of an installation. This is very cool. This would allow us to revert back to this snapshot any time some thing gets messed up.
About

Sharing what little I know

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today