How to on solaris resource management?



  • Here is a basic write up on how to setup resource management for apache webserver.

    Check project is set to correct lookup entry

    # grep project /etc/nsswitch.conf
    project: files
    

    Add a project for daemon group

    # projadd -c "Apache default" group.daemon
    # cat /etc/project
    system:0::::
    user.root:1::::
    noproject:2::::
    default:3::::
    group.staff:10::::
    group.daemon:100:Apache default:::
    

    Check the project id has been set

    # su - daemon
    $ pwd
    /
    $ id
    uid=1(daemon) gid=1(other)
    $ id -p
    uid=1(daemon) gid=1(other) projid=3(default)
    

    Change parameters for system V IPC:

    # projmod -sK "project.max-shm-memory=(privileged,200m,
    deny)" group.daemon
    # cat /etc/project
    system:0::::
    user.root:1::::
    noproject:2::::
    default:3::::
    group.staff:10::::
    group.daemon:100:Apache default:::project.max-shm-memory=(privileged,209715200,deny)
    

    Verify the IPC values has been set

    # su - daemon
    $
    $ id -p
    uid=1(daemon) gid=1(other) projid=3(default)
    
    $ prctl -n project.max-shm-memory -i process $$
    process: 27265: -su
    NAME PRIVILEGE VALUE FLAG ACTION RECIPIENT
    project.max-shm-memory
    privileged 126MB - deny -
    

    The startup of groups of processes in projects must be project aware on startup.This is done via SMF.

    For example two DB instances salesdb and mktdb should have separate service during startup.

    The newtask -p command must tell the instance to use the assigned project.

    Check the status of apache

    # svcs -a | grep apache2
    disabled 18:55:33 svc:/network/http:apache2
    

    Enabling the service

    # svcadm enable -r svc:/network/http:apache2
    

    Check status again, still in maintenance mode, there's a problem which needs looking at.

    # svcs -a | grep apache2
    maintenance 18:07:45 svc:/network/http:apache2
    

    Check the service logs

    # svcs -xv apache2
    svc:/network/http:apache2 (Apache 2 HTTP server)
    State: maintenance since Sat Aug 16 20:48:13 2008
    Reason: Start method exited with $SMF_EXIT_ERR_CONFIG.
    See: http://sun.com/msg/SMF-8000-KS
    See: man -M /usr/apache2/man -s 8 httpd
    See: /var/svc/log/network-http:apache2.log
    Impact: This service is not running.
    

    In this case no httpd.conf file existed for copied from standard template.

    # cd /etc/apache2
    # ls
    highperformance-std.conf httpd.conf-example ssl-std.conf
    highperformance.conf magic ssl.conf
    httpd.conf mime.types
    # mv httpd-std.conf httpd.conf
    

    Edit the httpd.conf file accordingly, solaris does not
    like group ids over certain numbers, so change the group
    to something else, I've changed it to have group webservd
    and user to webservd.

    Status will still be in maintenance state.

    # svcs -a | grep apache
    legacy_run 18:56:10 lrc:/etc/rc3_d/S50apache
    maintenance 20:48:13 svc:/network/http:apache2
    

    First the service needs to be cleared and then check to see if the maintenance state has gone.

    # svcadm clear svc:/network/http:apache2
    

    In this case it gone, the next state on enable should be online, currently in an offline state.

    # svcs -l svc:/network/http:apache2
    fmri svc:/network/http:apache2
    name Apache 2 HTTP server
    enabled true
    state offline
    next_state online
    state_time Sat Aug 16 21:00:00 2008
    logfile /var/svc/log/network-http:apache2.log
    restarter svc:/system/svc/restarter:default
    contract_id 112
    dependency require_all/error svc:/milestone/network:default (online)
    dependency require_all/none svc:/system/filesystem/local:default (online)
    dependency optional_all/error svc:/system/filesystem/autofs:default (online)
    

    Check status.

    # svcs apache2
    STATE STIME FMRI
    offline* 21:00:46 svc:/network/http:apache2
    

    Enable the service and check status again.

    # svcadm enable svc:/network/http:apache2
    # svcs apache2
    STATE STIME FMRI
    online 21:13:09 svc:/network/http:apache2
    

    Do a ps check to make sure:

    # ps -ef | grep httpd
    webservd 9026 9023 0 21:17:10 ? 0:00 /usr/apache2/bin/httpd -k start
    webservd 9027 9023 0 21:17:10 ? 0:00 /usr/apache2/bin/httpd -k start
    root 9023 1 0 21:17:09 ? 0:00 /usr/apache2/bin/httpd -k start
    webservd 9024 9023 0 21:17:10 ? 0:00 /usr/apache2/bin/httpd -k start
    webservd 9025 9023 0 21:17:10 ? 0:00 /usr/apache2/bin/httpd -k start
    webservd 9028 9023 0 21:17:10 ? 0:00 /usr/apache2/bin/httpd -k start
    

    Add an apache project.

    # projadd -c "Apache Default" group.webservd
    # cat /etc/project
    system:0::::
    user.root:1::::
    noproject:2::::
    default:3::::
    group.staff:10::::
    group.webservd:101:Apache Default:::
    

    Define the amount of shared memory

    # projmod -sK "project.max-shm-memory=(privileged,200m,deny)" group.webservd
    # cat /etc/project
    system:0::::
    user.root:1::::
    noproject:2::::
    default:3::::
    group.staff:10::::
    group.webservd:101:Apache Default:::project.max-shm-memory=(privileged,209715200,deny)
    

    Edit the manifest file for apach2.

    # cd /var/svc/manifest/network
    # vi http-apache2.xml
    

    Add the following lines in the start , note the timeout
    line is already there but remove the slash, and change
    the names to the user and project.

    Run the xmlchecker to verify syntax, prints the entire file if ok, otherwise there'll be errors to fix.

    # xmllint http-apache2.xml
    

    Import the changes to the manifest.

    # svccfg import http-apache2.xml
    

    Change the owner and group of the logs files.

    # cd /var/apache2/logs
    # ls -l
    total 928
    -rw-r--r-- 1 root root 0 Aug 16 20:59 access_log
    -rw-r--r-- 1 webservd root 465064 Aug 17 10:06 error_log
    # chown webservd:webservd access_log error_log
    

    Change the owner and group of the apache run directory

    # ls -ld /var/run/apache2/
    drwxr-xr-x 2 root root 69 Aug 17 10:13 /var/run/apache2/
    # chown webservd:webservd /var/run/apache2/
    # cd /var/run/apache2/
    # ls -l
    total 0
    

    Disable and enable the apache2 service.

    # svcadm disable apache2
    # svcadm enable apache2
    

    Verify project is set on user webservd

    # su - webservd
    $ id -p
    uid=80(webservd) gid=80(webservd) projid=102(group.webservd)
    

    Verify webserver processes are running under the new project

    # ps -fu webservd -o user,project,comm
    USER PROJECT COMMAND
    webservd group.webservd /usr/apache2/bin/httpd
    webservd group.webservd /usr/apache2/bin/httpd
    webservd group.webservd /usr/apache2/bin/httpd
    webservd group.webservd /usr/apache2/bin/httpd
    webservd group.webservd /usr/apache2/bin/httpd
    webservd group.webservd /usr/apache2/bin/httpd
    

    Assign 20 shares of the cpu to group.

    # prctl -n project.cpu-shares -r -v 20 -i project group.webservd
    

    Verify & display the cpu shares setting.

    # prctl -n project.cpu-shares -i project group.webservd
    project: 102: group.webservd
    NAME PRIVILEGE VALUE FLAG ACTION RECIPIENT
    project.cpu-shares
    privileged 20 - none -
    system 65.5K max none -
    

    Make the changes to the /etc/project file.

    # projmod -sK "project.cpu-shares=(privileged,20,none)" group.webservd
    # cat /etc/project
    system:0::::
    user.root:1::::
    noproject:2::::
    default:3::::
    group.staff:10::::
    group.webservd:102:Apache Default:::project.cpu-shares=(privileged,20,none);project.
    max-shm-memory=(privileged,209715200,deny)
    

    Activate resource pools

    # pooladm -e
    

    List resource pool information.

    # pooladm
    
    system default
    string system.comment
    int system.version 1
    boolean system.bind-default true
    string system.poold.objectives wt-load
    
    pool pool_default
    int pool.sys_id 0
    boolean pool.active true
    boolean pool.default true
    int pool.importance 1
    string pool.comment
    pset pset_default
    
    pset pset_default
    int pset.sys_id -1
    boolean pset.default true
    uint pset.min 1
    uint pset.max 65536
    string pset.units population
    uint pset.load 18
    uint pset.size 1
    string pset.comment
    
    cpu
    int cpu.sys_id 0
    string cpu.comment
    string cpu.status on-line
    

    Create the /etc/pooladm.conf file, pooladm -s save the active pool config to /etc/pooladm.conf

    # pooladm -s
    # ls -ld /etc/pooladm.conf
    -rw-r--r-- 1 root root 1007 May 3 14:59 /etc/pooladm.conf
    

    Create a pool set, called small, with at least one CPU with a max of 2 CPUs.

    # poolcfg -c 'create pset small (uint pset.min=1;uint pset.max=2)'
    

    Create a pool for the webservd user processes

    # poolcfg -c 'create pool webservd'
    

    Associate the apache pool with the small "pool set"

    # poolcfg -c 'associate pool webservd (pset small)'
    

    Instantiate the pool using

    # pooladm -c
    

    Adding resources which are not physically available on the system, you'll get the following.

    # pooladm -c
    pooladm: configuration at '/etc/pooladm.conf' cannot be instantiated on current system
    

    Switch back to default pool

    # poolcfg -c 'create pool webservd'
    # poolcfg -c 'associate pool webservd (pset pset_default)'
    # pooladm -c
    

    List configuration

    # poolcfg -dc info
    
    system default
    string system.comment
    int system.version 1
    boolean system.bind-default true
    string system.poold.objectives wt-load
    
    pool webservd
    int pool.sys_id 1
    boolean pool.active true
    boolean pool.default false
    int pool.importance 1
    string pool.comment
    pset pset_default
    
    pool pool_default
    int pool.sys_id 0
    boolean pool.active true
    boolean pool.default true
    int pool.importance 1
    string pool.comment
    pset pset_default
    
    pset pset_default
    int pset.sys_id -1
    boolean pset.default true
    uint pset.min 1
    uint pset.max 65536
    string pset.units population
    uint pset.load 18
    uint pset.size 1
    string pset.comment
    
    cpu
    int cpu.sys_id 0
    string cpu.comment
    string cpu.status on-line
    

    Move project to the new pool.

    # projmod -sK "project.pool=webservd" group.webservd
    

    Bind to the apache pool

    # poolbind -p webservd -i project group.webservd
    

    This is how the /etc/project file looks now.

    # cat /etc/project
    system:0::::
    user.root:1::::
    noproject:2::::
    default:3::::
    group.staff:10::::
    group.webservd:102:Apache Default:::project.cpu-shares=(privileged,20,none);project.
    max-shm-memory=(privileged,209715200,deny);project.pool=webservd
    

    Add utilization threshold and check.

    # poolcfg -dc 'modify pset pset_default (string pset.poold.objectives="utilization<75")'
    # poolcfg -dc info
    
    system default
    string system.comment
    int system.version 1
    boolean system.bind-default true
    string system.poold.objectives wt-load
    
    pool webservd
    int pool.sys_id 1
    boolean pool.active true
    boolean pool.default false
    int pool.importance 1
    string pool.comment
    pset pset_default
    
    pool pool_default
    int pool.sys_id 0
    boolean pool.active true
    boolean pool.default true
    int pool.importance 1
    string pool.comment
    pset pset_default
    
    pset pset_default
    int pset.sys_id -1
    boolean pset.default true
    uint pset.min 1
    uint pset.max 65536
    string pset.units population
    uint pset.load 21
    uint pset.size 1
    string pset.comment
    string pset.poold.objectives utilization<75
    
    cpu
    int cpu.sys_id 0
    string cpu.comment
    string cpu.status on-line
    

    Bind pool to the current process

    $ su - webservd
    $ /usr/sbin/poolbind -q $$
    11714 webservd
    

    Add Load to the system, to test threshold

    $ /usr/sbin/nspinx -n 4
    

    Check logs.

    # tail -f /var/logs/pool/poold
    Aug 17 12:01:27 Monitoring INFO: pset pset_default utilization objective
    not satisfied (1, utilization, '<', 75) with utilization 100.00 (control zone bounds exceeded)
    Aug 17 12:01:27 Monitoring INFO: reconfiguration required
    Aug 17 12:01:27 Optimization INFO: no moves found
    Aug 17 12:01:42 Monitoring INFO: pset pset_default utilization objective
    not satisfied (1, utilization, '<', 75) with utilization 100.00 (control zone bounds exceeded)
    

Log in to reply
 

© Lightnetics 2024