Implementing a Simple SMF Service: Lessons Learned OSDevCon09, - - PowerPoint PPT Presentation

implementing a simple smf service lessons learned
SMART_READER_LITE
LIVE PREVIEW

Implementing a Simple SMF Service: Lessons Learned OSDevCon09, - - PowerPoint PPT Presentation

Implementing a Simple SMF Service: Lessons Learned OSDevCon09, October 30th, 2009 Constantin Gonzalez Principal Field Technologist Sun Microsystems Germany Goals Make ZFS pool hygiene a 1-click experience Implement a simple SMF


slide-1
SLIDE 1

Implementing a Simple SMF Service: Lessons Learned

OSDevCon09, October 30th, 2009

Constantin Gonzalez Principal Field Technologist Sun Microsystems Germany

slide-2
SLIDE 2

Goals

Make „ZFS pool hygiene“ a 1-click experience

Implement a simple SMF service that periodically scrubs pools.

Learn about SMF and other Solaris features:

ksh93, ZFS, SMF, RBAC, IPKG, Visual Panels.

Motivate more users to use SMF more often Have some fun, too!

slide-3
SLIDE 3

Application Application ZFS Mirror ZFS Mirror ZFS Mirror

ZFS Self Healing

  • You only can repair errors that you see.
  • zpool scrub <pool> checks all blocks systematically.
  • Recommendation: Scrub all your pools periodically.
  • Even if you don't use mirroring or RAID-Z.

Application

Repair broken half Fetch good data from mirror Detect broken data

slide-4
SLIDE 4

Can this be done automatically?

slide-5
SLIDE 5

A Simple Idea

Periodic cron(1M) job per pool Fetch time of last scrub >1 period ago? zpool scrub pool End Start

slide-6
SLIDE 6

There's Already Something Similar

ZFS Auto-Snapshot Service Shipped with OpenSolaris Basis for the popular ZFS Time-Slider feature Let's help ourselves here :).

slide-7
SLIDE 7

Service Management Facility

Since Solaris 10 Manages all Services of the System (and more) Controls boot process and replaces run-levels Comfortable framework for:

Start/Stop scripts Dependencies Configuration of multiple instances Status/Error messages and resolutions

Most important commands:

svcs(1), svcadm(1M), svccfg(1M)

slide-8
SLIDE 8

Our Service Therefore Needs

A start/stop script A script for cron(1M) A manifest for SMF (XML-file) … and we can just borrow, then adapt them from the ZFS Auto-Snapshot Service!

} Can be done as one

slide-9
SLIDE 9

It's ok to steal borrow stuff!

Lesson #1:

slide-10
SLIDE 10

What if someone hacks into

  • ur script?
slide-11
SLIDE 11

Making Our Service More Secure

Role-based Access Control (RBAC) New role zfsscrub:

Allowed to administer ZFS Pools (not file systems) Allowed to administer the ZFS Auto-Scrub Service Allowed to use normal commands (like a user) Nothing else

A hacker would only be able to:

Destroy/manipulate pools, but not take over the system!

slide-12
SLIDE 12

Our Service Therefore Needs

An SMF service “zfs/auto-scrub”:

A start/stop Script A script for cron(1M) A manifest for SMF

A new zfsscrub role

}

Combined into

  • ne single script
slide-13
SLIDE 13

Lesson #2:

RBAC makes establishing a least-privilege model easy!

slide-14
SLIDE 14

How do we want to install our new service?

slide-15
SLIDE 15

Scriptless Installation, pkg(1)-style

We may only:

Copy files Activate SMF services

We may not:

Directly start scripts

Why?

Less complexity, less errors during installation

No special treatment for VMs, zones, hands-off, etc. Simplified installtion

More secure Better serviceable

slide-16
SLIDE 16

Can't Start Scripts Directly?

But we may install and activate SMF-Services! Therefore: Let's do a new SMF-Service for

Creating the new role upon activation, Deactivating itself when done.

slide-17
SLIDE 17

Our Service Therefore Needs

An SMF service “zfs/auto-scrub”:

A start/stop script, A script for cron(1M), A manifest for SMF.

Another SMF service “zfsscrub-roleadd”:

A start/stop script,

creates the role zfsscrub, then deactivates itself,

A manifest for SMF.

}

Combined into

  • ne script
slide-18
SLIDE 18

Lesson #3:

We can cheat around IPKG by packing our install scripts Into SMF services.

slide-19
SLIDE 19

Let's Get Started, Then!

slide-20
SLIDE 20

Wait, when did that last scrub happen, BTW?

slide-21
SLIDE 21

zpool(1M) status

constant@fridolin:~$ zpool status testpool pool: testpool state: ONLINE scrub: scrub completed after 0h0m with 0 errors on Wed Sep 16 09:33:42 2009 config: NAME STATE READ WRITE CKSUM testpool ONLINE 0 0 0 /export/stuff/disk1 ONLINE 0 0 0 errors: No known data errors

slide-22
SLIDE 22

After Reboot or zpool export:

constant@fridolin:~$ zpool status testpool pool: testpool state: ONLINE scrub: none requested config: NAME STATE READ WRITE CKSUM testpool ONLINE 0 0 0 /export/stuff/disk1 ONLINE 0 0 0 errors: No known data errors

New CR 6878281 opened: “zpool should store the time of last scrub/resilver and other zpool status info in pool properties.”

slide-23
SLIDE 23

What do we do now?

slide-24
SLIDE 24

Add Another SMF Service

zfs/scrub-track

Runs once per hour (through cron(1M)) Until zpool scrub is finished Stores finish time in a ZFS property in the topmost ZFS filesystem of the pool

Needs „ZFS Filesystem Mgmt“ profile for zfsscrub

and deactivates itself

zfs/auto-scrub

checks zpool status and the new property. Activates zfs/scrub-track at every scrub

slide-25
SLIDE 25

BTW

Zpool supports properties:

constant@fridolin:~$ zpool get all testpool NAME PROPERTY VALUE SOURCE testpool size 504M - testpool used 243M - testpool available 261M - testpool capacity 48% - testpool altroot - default testpool health ONLINE - testpool guid 4748598414767023039 default testpool version 18 default testpool bootfs - default testpool delegation on default testpool autoreplace off default ...

But no user-defined ones! Workaround: Use the top-level ZFS filesystem Bug? RFE? Not an issue?

slide-26
SLIDE 26

Our Service Therefore Needs

An SMF service “zfs/auto-scrub”

A start/stop/cron script A manifest for SMF

Another SMF service “zfsscrub-roleadd”

A start/stop script for creating zfsscrub

ZFS Storage Management, ZFS File System Management

A Manifest for SMF

Yet another SMF-Service “zfs/scrub-track”

A start/stop/cron script, similar to zfs/auto-scrub A manifest for SMF

slide-27
SLIDE 27

Lesson #4:

Bugs and RFEs show up in unexpected places...

slide-28
SLIDE 28

Lesson #5:

If in doubt, do it in SMF!

slide-29
SLIDE 29

Now, let's take a look!

slide-30
SLIDE 30

Final touches: A GUI!

slide-31
SLIDE 31

OpenSolaris Visual Panels Project

New framework for central management of system configurations Based on Java Management Extensions (JMX) Interacts with Service Configuration Framework (SCF), a part of SMF, and others

JMX Agent Network Visual Panel Visual Panel

Service Configuration Facility (SCF)

MBeans Management Node Managed System

Other Configuration Tools

slide-32
SLIDE 32

Visual Panel Components

Java-Classes in a .jar-file

Panel Descriptor

Describes the panel to the system Pivot point for the panel

Controller

Connects the GUI with management-beans

Panel

Presents the actual GUI

Other classes (optional)

Depending on the complexity of your panel

XML file, describing the panel

slide-33
SLIDE 33

Our Service Therefore Needs

An SMF service “zfs/auto-scrub”

A start/stop/cron script and a manifest for SMF

Another SMF service “zfsscrub-roleadd”

A start/stop script for creating the zfsscrub user and a manifest for SMF

Yet another SMF service “zfs/scrub-track”

A start/stop/cron script, similar to zfs/auto-scrub A manifest for SMF

A visual panel

A .jar-File with Java classes etc. An XML file with a description

slide-34
SLIDE 34

Done!

slide-35
SLIDE 35

Lesson #6:

Little things (like GUIs) please little minds...

slide-36
SLIDE 36

Future Features

Black/White lists for scrub times Expand the GUI

Current scrub status and statistics User-defined instances

Pool specific With different scrubbing intervals

Simple/complex view

Store scrub preferences in ZFS Properties instead of SMF properties

Will travel with the pool

Publish as IPKG through a repository

slide-37
SLIDE 37

Lessons Learned

SMF ist easy to program, if you steal re-use from examples.

/lib/svc/method svccfg export <service>

When in doubt, use SMF Easy ideas can become surprisingly complex, if you try to implement them right.

But you learn a lot about the rest of the system.

GUIs with Visual Panels are still kinda wonky, but they seem to work.

slide-38
SLIDE 38

Links

Tim Foster's ZFS Auto-Snapshot Service

http://blogs.sun.com/timf

SMF

man smf http://opensolaris.org/os/community/smf/

Visual Panels

http://opensolaris.org/os/project/vpanels/

Download from my Blog

http://blogs.sun.com/constantin

slide-39
SLIDE 39

THANK YOU!

Constantin Gonzalez constantin@sun.com blogs.sun.com/constantin twitter.com/zalez