Saturday, May 17, 2014

IQ 3:- how to modify the service in Solaris ? ----> svccfg ex:-# svccfg -s dns/client setprop config/nameserver = 10.0.0.1


Configuring SMF Services

The following tasks show how to configure SMF services. In particular, how to modify service properties and other configuration information for a service or a service instance.

How to Modify an SMF Service Property

This procedure shows how to modify the property that identifies the user that can start a service.
  1. Become an administrator or assume a role that includes the Service Management rights profile.
  2. Change the value that is assigned to the start/user property.
    First, give the FMRI to identify the appropriate service. Next, assign the UID that will start the service.
    # svccfg -s FMRI
    svc:/service: setprop start/user = astring: newlogin
  3. Refresh the service.
    # svcadm refresh FMRI

How to Modify a Service That Is Configured by a File

The following procedure shows how to change the configuration of a service that is not managed by the inetd service.
  1. Become an administrator or assume a role that includes the Service Management rights profile.
  2. Make changes to the configuration files, as needed.
    Many of the services have one or more configuration files that are used to define the startup or other configuration information. These files can be changed while the service is running. The contents of the files is only checked when the service is started.
  3. Restart the service.
    # svcadm restart FMRI
Example 7-12 Adding a New NTP Server
To add a new NTP server to support your NTP clients, add a new entry for the server to the /etc/inet/ntp.conf file. Next, restart the NTP service. This example shows you what thentp.conf file could look like, as well as how to restart the service.

# cat /etc/inet/ntp.conf
   .
   .
server ntpserver1.example.com
server ntpserver2.example.com
# svcadm restart svc:/network/ntp:default

he SMF Command Line

There are several commands administrators can use from the command line to administer services and make configuration changes to the system. Table 1 provides a quick summary of the different command line options that are available.
Table 1. Summary of SMF Commands
CommandDescription
svcadmManage the state of service instances
svcsProvide information about services, including their status
svcpropGet information about service configuration properties
svccfgImport, export, and modify service configuration
Before we go into detail about how to modify changes in the SMF repository, let's quickly look at the command svcprop and how we can use it to list property groups and properties of a given service or service instance. Listing 7 shows it being used with thesvc:/network/dns/client:default instance.
# svcprop dns/client:default
general/complete astring
general/enabled boolean true
general/action_authorization astring solaris.smf.manage.name-service.dns.client
general/entity_stability astring Unstable
general/single_instance boolean true
general/value_authorization astring solaris.smf.manage.name-service.dns.client
config/value_authorization astring solaris.smf.value.name-service.dns.client
config/nameserver net_address 192.168.0.1
sysconfig/group astring naming_services
milestoneconfig_network_dns_client/entities fmri svc:/milestone/config
milestoneconfig_network_dns_client/external boolean true
milestoneconfig_network_dns_client/grouping astring optional_all
milestoneconfig_network_dns_client/restart_on astring none
milestoneconfig_network_dns_client/type astring service
location_dns-client/entities fmri svc:/network/location:default
...
restarter/state_timestamp time 1339662573.051463000
restarter_actions/auxiliary_tty boolean false
restarter_actions/auxiliary_fmri astring svc:/network/location:default
general_ovr/enabled boolean true
Listing 7. Listing Property Groups and Properties
In Listing 7, we are using svcprop without any other options, and we get a composed view by default—one that includes properties from both the parent service and the service instance. If we just wanted to look at the instance properties, we can use the -C option, as shown in Listing 8.
# svcprop -C dns/client:default
general/complete astring
general/enabled boolean true
restarter/logfile astring /var/svc/log/network-dns-client:default.log
restarter/start_pid count 572
restarter/start_method_timestamp time 1339662573.041262000
restarter/start_method_waitstatus integer 0
restarter/transient_contract count
restarter/auxiliary_state astring dependencies_satisfied
restarter/next_state astring none
restarter/state astring online
restarter/state_timestamp time 1339662573.051463000
restarter_actions/auxiliary_tty boolean false
restarter_actions/auxiliary_fmri astring svc:/network/location:default
general_ovr/enabled boolean true
Listing 8. Listing Only Instance Properties
If we wanted to focus on a particular property, we can use the -p option to specify the property group and property. In this case, we're going to find the config/nameserver property on the service rather than on the service instance. This property is used as a replacement to the legacy /etc/resolv.conf file in previous versions of Oracle Solaris, though the value is mirrored to that file for compatibility with applications that might be parsing it.
# svcprop -p config/nameserver dns/client
192.168.0.1
Now that we've seen how to query properties, let's take a look at another command, svccfg, that we can use to set properties. svccfgprovides a number of different ways to set properties: directly on the command line, through an interactive text-based interface, or through a text editor. Let's keep with our svc:/network/dns/client example and see how easy it is to set the name server configuration.
# svccfg -s dns/client setprop config/nameserver = 10.0.0.1
# svccfg -s dns/client listprop config/nameserver
config/nameserver net_address 10.0.0.1
Changes made to an existing service in the respository typically do not take effect until the service instance has been refreshed.
# svcprop -p config/nameserver dns/client
192.168.0.1
# svcadm refresh dns/client:default
# svcprop -p config/nameserver dns/client
10.0.0.1
Equally, we could have used the interactive interface to make these changes. Let's change the value of config/nameserver back to what it was originally, 192.168.0.1, as shown in Listing 9.
# svccfg
svc:> select dns/client
svc:/network/dns/client> listprop config/nameserver
config/nameserver net_address 10.0.0.1
svc:/network/dns/client> describe config/nameserver
config/nameserver net_address 10.0.0.1
    The value used to construct the "nameserver" directive in resolv.conf(4)
svc:/network/dns/client> setprop config/nameserver = 192.168.0.1
svc:/network/dns/client> listprop config/nameserver
config/nameserver net_address 192.168.0.1
svc:/network/dns/client> select default
svc:/network/dns/client:default> refresh
svc:/network/dns/client:default> exit
Listing 9. Using the Interactive Interface
svccfg supports a number of other useful commands, such as listpg to list property groups on a given service, editprop to open up a text editor to more easily allow configuration of multiple properties at the same time, and extract to allow administrators to easily capture service customizations as an XML file that can be applied on other systems. We will cover more of these in another article.

Monitoring the State of Services

One of the new features added to SMF in Oracle Solaris 11 is the ability to monitor the state of services and get notified if they change, either through e-mail or SNMP traps. Notifications can be quickly set to check if any SMF services go into maintenance mode or if a particular service goes online, for example. As a quick example, let's set an e-mail notification to be sent anytime an SMF service goes into maintenance mode, as shown in Listing 10.
# svccfg setnotify -g maintenance mailto:admin@mycompany.com
# svccfg listnotify -g
    Event: to-maintenance (source: svc:/system/svc/global:default)
        Notification Type: smtp
            Active: true
            to: admin@mycompany.com

    Event: from-maintenance (source: svc:/system/svc/global:default)
        Notification Type: smtp
            Active: true
            to: admin@mycompany.com
Listing 10. Example of Setting a Notification
By default, SMF will use an existing simple e-mail template to fill in the values of any SMF service that has gone into or out of themaintenance state; however, this can be modified easily by setting a parameter, msg_template, in the mailto: address, as follows:
# svccfg setnotify -g maintenance "'mailto:admin@mycompany.com?msg_template=/usr/local/share/new-smf-email-template'"
We can also monitor individual services. In this case, let's monitor the svc:/network/http:apache22 Apache Web server default instance for any changes away from its current online state:
# svcs http:apache22
STATE          STIME    FMRI
online         Jun_14   svc:/network/http:apache22
# svccfg -s http:apache22 setnotify from-online mailto:admin@mycompany.com
# svccfg -s http:apache22 listnotify
    Event: from-online (source: svc:/network/http:apache22)
        Notification Type: smtp
            Active: true
            to: admin@mycompany.com

Troubleshooting

Now that we have covered some of the basics of administration with SMF, let's quickly take a look at some of the things we can do to troubleshoot what might be wrong with a service. To quickly get an idea of what services are not running due to errors, we can use the -xv options to svcs, as shown in Listing 11.
# svcs -xv
svc:/system/identity:node (system identity (nodename))
 State: disabled since June 22, 2012 08:11:14 PM NZST
Reason: Disabled by an administrator.
   See: http://sun.com/msg/SMF-8000-05
   See: man -M /usr/share/man -s 4 nodename
   See: /var/svc/log/system-identity:node.log
Impact: 5 dependent services are not running:
        svc:/network/rpc/bind:default
        svc:/network/rpc/gss:default
        svc:/system/filesystem/autofs:default
        svc:/network/rpc/smserver:default
        svc:/network/nfs/mapid:default

No comments:

Post a Comment