Monday, August 13, 2007

Solaris 10 - Resource Management

Today we've started testing Solaris 10 CPU resource management using FSS (Fair Share Scheduler) and Projects.

The problem we wanted to solve is with Oracle database, we have a DWH database and at night we have few things:
  • ETL
  • Database Exports
  • Users access
What we need is that the database exports won't interrupt the ETL process (The users don't do much at night), So we've decided to try Solaris Resource Management capability.

Before I'll show what we have done you need to know that the Oracle owner is "orauser"
and the Oracle SID is "orcl".

The first step is to create the needed projects, projects are used to distinguish different workloads from one another. We've created two projects:
  • user.orauser
  • oracle_low
There are three ways to create a project:
  1. user.USERNAME - a project that is associated with a specific Unix user
  2. group.GROUPNAME - a project that is associated with a specific Unix group
  3. project name - a project that is not associated to any group or user by default and can be associated manually or by SMF (Service Management Facility)
So the first project we've created, user.orauser, will be assigned automatically for the user orauser. The second project, oracle_low, is a non associated project that we will use to lower the CPU workload for the database exports.

The commands to create a the projects are:
# projadd -c "Oracle default project" user.orauser
# projadd -c "Oracle low priority project" oracle_low

All the projects defined in /etc/projects file and can be viewed in this file or by running:
# projects -l

To check orauser default project run:
# id -p orauser
uid=60000(orauser) gid=300(dba) projid=100(user.orauser)

Now that we've created the projects, we need to change the system scheduling to use FSS:
# ps -cafe
# dispadmin -d FSS
# priocntl -s -c FSS -i class TS
# priocntl -s -c FSS -i pid 1
# ps -cafe

  • "ps -cafe" - shows all processes and there scheduler class, I will not explain what a class is, but you should know that TS class is what Solaris uses for all processes by default. The TS class can be manipulated by the nice and renice commands.
  • "dispadmin -d FSS" - sets the default scheduling class to be used on reboot to FSS
  • "priocntl -s -c FSS -i class TS" - changes all current process with TS class to FSS class
  • "priocntl -s -c FSS -i pid 1" - changes the /sbin/init process to FSS class
The next step is to add the CPU resource (cpu-shares) to each project, one thing we need to know about cpu-shares resource is that the value we set for it is the ratio and not percentages, it means that if project A have cpu-shares=10 and project B have cpu-shares=20 and both process of both projects need 100% CPU load the processes of project B will get total of 66% CPU and the processes of project A will get 33%. So, here is the way to add the CPU resource to our projects:
# prctl -n project.cpu-shares -r -v 30 -i project user.orauser
# prctl -n project.cpu-shares -r -v 10 -i project oracle_low
# projmod -sK “project.cpu-shares=(privileged,10,none)” oracle_low
# projmod -sK “project.cpu-shares=(privileged,30,none)” user.orauser

  • projmod - changes the project attributes
  • prctl - changes the resource control for running process
Use the "projects -l" command to view the changes we've just made.
# project -l user.orauser
# project -l oracle_low

Now, we changed the export processes to run like this:
# newtask -p oracle_low /u01/scripts/

And every thing is working perfectly!!! Fun Fun Joy Joy.

One more useful command is "prstat -J" that will show resources utilization by project.


No comments: