Script_startup_shutdown


 
Thread Tools Search this Thread
Operating Systems Solaris Script_startup_shutdown
# 1  
Old 03-06-2012
Script_startup_shutdown

Hi all,
I am new to solaris and using solaris10u10.I have an issue with zpool with Multipathing software installed on it. The issue is after reboot zpool goes to UNAVAIL state and the temporary solution we are using is export the pool before reboot and import after reboot. I was planning to write a script that would excecute 'zpool import -a' command upon system coming up. Similarly can we write script that will excecute 'zpool export -a' before system shutsdown?? Please suggest me any guide which i can follow to do the above.

Thanks in advance for help.
# 2  
Old 03-06-2012
/etc/rc2.d:

Put a file in this directory, owned by root, called K99stopzpool. The K99 part is important.
Place the stop command you want in there.

/etc/rc2.d

Do the samething for a "start" script: S99startzpool. Put your start up command in there.

This is a quick hack. Be sure to remove it later on. And read up on booting, starting and stopping your system in one of the sysadmin guides for Soalris.
# 3  
Old 03-06-2012
As you are using Solaris 10, a better solution would be to take advantage of SMF services. Here's a sample manifest for your case. You need to customize it to add dependencies (optional, but you should do it):

Code:
$ cat myzpool.xml
<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<service_bundle type="manifest" name="myzpool">

    <service name="site/myzpool" type="service" version="1">

        
        <instance name="default" enabled="false">
            

            <method_context>
                <method_credential user="root" group="sys"/>
            </method_context>

            <exec_method type="method" name="start" exec="/usr/sbin/zpool import -a" timeout_seconds="60"/>

            <exec_method type="method" name="stop" exec="/usr/sbin/zpool export -a" timeout_seconds="60"/>

            <property_group name="startd" type="framework">                                
                <propval name="duration" type="astring" value="transient"/>
                <propval name="ignore_error" type="astring" value="core,signal"/>
            </property_group>

            <property_group name="application" type="application">
                
            </property_group>

        </instance>
        
        
        
        <stability value="Evolving"/>

        <template>
            <common_name>
                <loctext xml:lang="C">
                   myzpool 
                </loctext>
            </common_name>
        </template>

    </service>

</service_bundle>

Verify the xml file:
Code:
svccfg validate myzpool.xml

Import the configuration in SMF database:
Code:
svccfg import myzpool.xml

Enable the service:
Code:
svcadm enable myzpool

Please be advised that this is just a sample manifest which I made from scratch and can contain errors. As I did not have time to test it, please make sure you test it properly before implementing in a production environment.

Also I would suggest that you read the below PDF from Oracle on how to make custom manifests for SMF services:
http://developers.sun.com/solaris/do...est-053110.pdf
# 4  
Old 03-07-2012
@admin_xor : Hi thanks for reply, Is the stop command mandatory for smf? As mentioned 'zpool export -a' command was what i wanted to put there. But there ia no -a option for export. So the only way left out is deleting the /etc/zfs/zpool.cache. Can i add rm /etc/zfs/zpool.cache in that xml file for stop command?? ie.,<exec_method type="method" name="stop" exec="/usr/sbin/rm /etc/zfs/zpool.cache ??
# 5  
Old 03-07-2012
Sure, you can put virtually any command in that section (stop command is not mandatory, but keep in mind that SMF will have no handle while trying to shutdown the service). That command will be executed while doing an "svcadm disable" or while shutting down/rebooting the system. But, I would encourage you to make a shell script and implement start and stop method in the script. Later you can call the script with "start" or "stop" argument from the manifest, just as shown in the PDF.

I am not really confident about the consequences of removing zpool.cache. Why don't you try "zpool export pool_name"?

Last edited by admin_xor; 03-07-2012 at 05:55 PM..
# 6  
Old 03-08-2012
@admin_xor: We cant keep track of what all pools customer is using. So it is not possible to write such a script. But i guess setting zpool cachefile=none, is noting but deleting the same. I see that after set cachefile=none <poolz> and ls -al /etc/zfs/zpool.cache says no such file or directory.
# 7  
Old 03-08-2012
"zpool set cachefile=none <pools>" prevents cache file to be created for the pools in the first place. If you have tested the setup and everythings is working fine, then it must be OK. Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question