• No results found

Practices for Lesson 7: Managing Services and

In document D72965GC10_ag Solaris11 Adnace LAB (Page 147-152)

Service Properties

Chapter 7

Oracle Internal & Or

Practices for Lesson 7

Practices Overview

In these practices, you are given a plan for configuring, restoring, and maintaining the Oracle Solaris 11 services and getting acquainted with various service profiles.

According to the predeployment plan, the time has come for you to evaluate the Service Management Facility (SMF) services. You have been tasked with working with multiple scenarios to test the SMF functionality. In support of your business applications, in certain cases, you may have to create, troubleshoot, and modify the services and the service profiles. The key areas explored in the practices are:

• Configuring SMF services

• Restoring and recovering a service • Working with service profiles

Let’s check our progress. You just completed the zones lesson and now we are working with Services.

Oracle Solaris 11 Predeployment Checklist

Managing the Image Packaging System (IPS) and Packages

Installing Oracle Solaris 11 on Multiple Hosts

Managing the Business Application Data

Configuring Network and Traffic Failover

Configuring Zones and the Virtual Network

Managing Services and Service Properties

Configuring Privileges and Role-Based Access Control

Securing System Resources Using Oracle Solaris Auditing

Managing Processes and Priorities

Evaluating System Resources

Monitoring and Troubleshooting System Failures

Oracle Internal & Or

Practice 7-1: Configuring SMF Services

Overview

As part of the predeployment testing plan, you are given the task of creating a simple service that can also assist you in modifying a service. You will call this new service crmsvc, which would be designed to monitor the CRM processes. In addition, you will also modify environment variables and properties of actively running services. For example, you will determine any memory leaks caused by the running programs and turning on the TCP trace. In this practice, you will work with SMF services in the following areas:

• Creating and exporting a service

• Modifying a service

• Changing an environment variable for a service

• Changing a property for a service controlled by inetd

Task 1: Creating and Exporting a Service

1. Double-click the Sol11-Desktop icon to launch the Sol11-Desktop virtual machine. 2. Log in to the virtual machine Sol11-Desktop as the user oracle. Use the password

oracle1.

3. Right-click the desktop background and open a terminal window.

4. In the terminal window, run the su - command to assume administrator privileges. oracle@s11-desktop:~$ su -

Password:

root@s11-desktop:~#

5. Create a new user by the name of sstudent. Confirm the user creation. root@s11-desktop:~# useradd -u 2001 -g 10 –d \

/export/home/sstudent -m -s /bin/bash -c "sstudent" sstudent

root@s11-desktop:~# tail /etc/passwd noaccess:x:60002:60002:No Access User:/:

nobody4:x:65534:65534:SunOS 4.x NFS Anonymous Access User:/: aiuser:x:60003:60001:AI User:/: pkg5srv:x:97:97:pkg(5) server UID:/: ftp:x:21:21:FTPD Reserved UID:/: oracle:x:60004:10:Oracle:/home/oracle:/usr/bin/bash … … … sstudent:x:2001:10:sstudent:/home/sstudent:/bin/bash

You are creating the user sstudent so you can create a new service as a non- administrative user. Since you must have the appropriate privileges, you will perform some steps as an administrative user.

Note: Create this user only if it is not already there.

Oracle Internal & Or

6. Create the smf directory in your home directory. Create a file called monitor.crm with the following contents.

root@s11-desktop:~# su - sstudent

Oracle Corporation SunOS 5.11 snv_173 August 2011

sstudent@s11-desktop:~$ pwd /home/sstudent

sstudent@s11-desktop:~$ mkdir smf sstudent@s11-desktop:~$ ls

local.cshrc local.login local.profile smf sstudent@s11-desktop:~$ cd smf

sstudent@s11-desktop:~/smf$ vi monitor.crm sstudent@s11-desktop:~/smf$ cat monitor.crm #!/bin/sh

echo "crm monitoring service" > /export/home/sstudent/smf/crmrep

sstudent@s11-desktop:~/smf$ chmod 774 monitor.crm

After creating the script, you need to grant the execute permission on the script so it can be executed.

7. Exit the sstudent user account to return to the administrative user to configure the service. Use the svccfg command to copy an existing service to serve as a template.

root@s11-desktop:~/smf$ exit root@s11-desktop:~# svccfg export system/utmp > \ /var/svc/manifest/site/crmsvc.xml

Instead of starting the manifest file from scratch, you will have this template to work with.

8. Edit the crmsvc.xml file to match the contents displayed.

root@s11-desktop:~# vi /var/svc/manifest/site/crmsvc.xml root@s11-desktop:~# more /var/svc/manifest/site/crmsvc.xml <?xml version='1.0' encoding='UTF-8' ?>

<!DOCTYPE service_bundle SYSTEM

'/usr/share/lib/xml/dtd/service_bundle.dtd.1'> <service_bundle type='manifest' name='crmsvc'>

<service name='site/crmsvc' type='service' version='1'> <create_default_instance enabled='false'/>

<single_instance/>

<exec_method name='start' type='method' exec='/export/home/sstudent/smf/monitor.crm’ timeout_seconds='60'>

</exec_method>

<exec_method name='stop' type='method' exec=':true' timeout_seconds='60'>

</exec_method>

Oracle Internal & Or

<property_group name='startd' type='framework'>

<propval name='duration' type='astring'

value='transient'/> </property_group> </service>

</service_bundle>

After editing, the manifest for your test service should look like this. Review the contents for any XML tags missing, and any typing errors. Notice that exec_method matches up with your program.

9. Validate the manifest file by using the svccfg validate command.

root@s11-desktop:~# svccfg validate /var/svc/manifest/site/crmsvc.xml

Unless there are any spelling mistakes, the validate command should run fine. 10. Using the svcadm restart command, make the manifest available to SMF.

root@s11-desktop:~# svcadm restart system/manifest-import

Since the service you created is in an SMF standard manifest directory, we can just restart the manifest service. This will import the newly created service. You don’t have to import the service individually. This is the recommended practice.

11. Display the service using the svcs command. If it is disabled, enable it by using the svcadm command.

root@s11-desktop:~# svcs crmsvc

disabled 13:14:07 svc:/site/crmsvc:default root@s11-desktop:~# svcadm enable /site/crmsvc root@s11-desktop:~# svcs crmsvc

online 13:43:36 svc:/site/crmsvc:default

Is your service enabled and online? Yes.

12. Let’s verify that the command echo was executed using the new service. root@s11-desktop:~# cat /export/home/sstudent/smf/crmrep crm monitoring service

The action you had specified in the monitor.crm got executed by bringing up the service resulting in echoing the above string to the crmrep file. This is how you can execute a program as a service.

Oracle Internal & Or

Task 2: Modifying Service Configuration

Overview

The following tasks will introduce the various types of service modifications, for example, the service environment variables, network service properties and process to service conversion. In this practice, you will work with SMF services in the following areas:

• Change an environment variable for a service • Change a property of a service controlled by inetd

In document D72965GC10_ag Solaris11 Adnace LAB (Page 147-152)