On Monday 26 November 2007, Atanas Dyulgerov wrote:
> Hi Max,
>
> I haven't received such complete answer before. Thank you very much for the
> useful information.
>
> I understood how attributes work. A shell script performing some
> operations/monitoring sets attributes by using attrd_updater or
> crm_attribite. The score for a resource can be changed with constraint 
> matching these attributes.
>
> What I don't understand is the difference between -t node attribute and -t
> status attribute. Could you explain? They are set and read the same way.
> Why they are called static and dynamic since they can be set any time by
> some script for e.g.?
The termini "dynamic" and "static" were just my invention. They refer to the 
section where they are added and not when (or how often they are changed).

The difference is that attributes added with -t node will show up in the 
<nodes> section.

Which means they have the property of a configuration parameter. If the node 
is rebooted it reads the configuration (which the nodes scetion belong to) 
and adds the attribute to the CIB. No script is needed to add an initial 
value. And usually you have not a resource agent which adds/removes/changes 
those attribiútes because they are more of "static" nature. 

Example: assuming you have a 2 cluster node system. One node having 1024 MB 
RAM, the other having 2048 MB RAM. You would like to run a service on the 
machine with more RAM. One way to do this is making an attribute (lets call 
it "ram") in the node section for both nodes (on node A ram=1024 on node B 
ram=2048) and write a rule which adjusts the resource score based on 
the "ram" attribute.

Note: since the nodes do not change its installed RAM it does not make much 
sense to add the attribute with a resource agent on startup. The easiest way 
is to add the attribute in your CIB in the <nodes> section as configuration 
parameter. Since you will do this usually with your CIB configuration file 
you seldom use "-t nodes" (except you start chaning your CIB configuration).

Attribites which i call "dynamic" are store in the <status> section. The 
<status> section is volatile in the sense that if you reboot the node the 
<status> section for this node is gone (actually they show up on the 
remaining cluster nodes until the node is rebooted again). The <status> 
section for a node is recreated upon the start of "heartbeat" on the node. 
This means if you do not add the attribute again (for example with a monitor 
opertion of a resource agent or manually by invoking crm_attribite of 
attrd_updater).

Example: lets assume you wrote a resource agent which reads the temperature of 
your CPU and maps it as attribite "cpu_tmp" in the CIB. It does not make 
sense to keep this attribute the same all the time. The resource agent needs 
to be started and the monitor opertion of the RA has to update cpu_tmp 
continusouly. Now you could write a rule which moves the resources away from 
the node if the CPU temperature is too high.

The point is: it up to you to decide which attribites fits better into the 
configuration section or into the status section. 

>
> Instance attributes are attributes which you pass to the OCF script? I'm I
> right?
Yes. They are tied to a resource instance and are passed to the resource agent 
as OCF_RESKEY_<parameter name>. Those instance can be changed with 
crm_attribute (or with crm_admin).

And just to confuse you more there are resource meta-attribites. Those are 
also resource attributes - but they are intended for the CRM to decide 
when/what should happen with the resource (like resource stickiness, failure 
stcikiness, etc.).

>
> How can I print the score for my resources?
ptest is the answer of that. Since the output is very verbose you usually use 
those in combination with some grep filters. Here some examples:

/usr/lib/heartbeat/ptest -L -VVVVVVVV 2>&1|grep test_expression|less
/usr/lib/heartbeat/ptest -L -VVVVVVVV 2>&1|grep native_rsc_location|less
/usr/lib/heartbeat/ptest -L -VVVVVVVV 2>&1|grep resource_node_score|less

I think you can also retrieve some most information with crm_mon -vvvv. But 
since crm_mon works only on live systems and ptest works also on snapshot 
files created by the cluster system (take a look into your ha-log - whenever 
the cluster state changes it creates a bz2 snapshot of your cluster state).

>
> I greatly appreciate your help.
>
> Regards,
> Atanas
>
>  >-------- Оригинално писмо --------
>  >От:  Max Hofer <[EMAIL PROTECTED]>
>  >Относно: Re: [Linux-HA] How to control a resource with an environment
>  > variable? До: [email protected]
>  >Изпратено на: Понеделник, 2007, Ноември 26 16:03:40 EET
>  >----------------------------------
>  >
>  >I have'nt checked your location constraint but what you want to achieve
>  > you can't do with environment variables. You have to use CIB attributes.
>  >
>  >So instead of changing the environment variable you change the CIB
>  > attribute.
>  >
>  >Using attributes instead environment variables seems more logical if you
>  > think about the fact that attributes are propagated to all cluster
>  > nodes. Whereas environment variables are not.
>  >
>  >What you have to decide is if you are using "global (or rather static)
>  >attribute" (i.e. it shows up in the <nodes> section) or if you use an
>  >attribute of temporary nature (i.e. in the <status> section).
>  >
>  >What kind of attribite you use, depends what you want to achieve.
>  >
>  >Somthing like: run a resource on the node with more RAM are definietyl of
>  >static nature (add a "RAM" attribute to each node and write a rule which
>  >creates a score based on this value).
>  >
>  >If you have something like: run the resource on the node where a shell
>  >script "X_Y_Z" returns the highest value, you need a resource agent which
>  >calls X_Y_Z periodically (if it changes over time) and maps its return
>  > value into the CIB in the <status> section.
>  >
>  >Naturally you have to write a rule which adpats the score based on the
>  >attribute.
>  >
>  >Mapping the attribute can be achieved with two tools: attrd_updater or
>  >crm_attribite.
>  >
>  >The first tool provides a hysteresis functionality. You can dampen the
>  > value for a certain time period (i.e. the value is propagated to the
>  > other nodes after the dampen time - this may be handy if your value may
>  > change with a high frequency and you want avoid a resource failover when
>  > the system has a small "hickup").
>  >
>  >On Sunday 25 November 2007, Atanas Dyulgerov wrote:
>  >> Hi all,
>  >>
>  >> I need to control a resource with an environment variable. When I set
>  >> the variable with value "true" to increase the score for a resource.
>  >>
>  >> I did the following constraint:
>  >> <rsc_location id="rloc_unique_id" rsc="service_ip">
>  >>     <rule score="INFINITY" boolean_op="or" id="rcloc_rule_unique_id">
>  >>        <expression id="expr:hfc:defined" attribute="my_variable"
>  >> operation="defined"/> <expression id="expr:hfc:true"
>  >> attribute="my_variable" operation="eq" value="true"/> </rule>
>  >> </rsc_location>
>  >>
>  >> Then I export the variable my_variable on the node where I want to move
>  >> the resource service_ip. # export my_variable=true
>  >>
>  >> Nothing happens.
>  >>
>  >> # export OCF_RESKEY_my_variable=true
>  >>
>  >> Again nothing happens.
>  >>
>  >> So, how can I control the resource from an env variable? How to export
>  >> the variable?
>  >>
>  >> One more question. How to display all the OCF_RESKEY variable set by
>  >> the instant resource attributes? # export -p
>  >> or
>  >> # set
>  >> do not display any OCF_RESKEY_* variables.
>  >>
>  >> Thank you in advance.
>  >>
>  >> Atanas Dyulgerov
>  >>
>  >>
>  >>
>  >> -----------------------------------------------------------------
>  >> Оцеляваш ли? Сподели свое видео или снимки!
>  >> http://robinson.btv.bg/isurvive
>  >> _______________________________________________
>  >> Linux-HA mailing list
>  >> [email protected]
>  >> http://lists.linux-ha.org/mailman/listinfo/linux-ha
>  >> See also: http://linux-ha.org/ReportingProblems
>  >
>  >--
>  >Max Hofer
>  >APUS Software G.m.b.H.
>  >A-8074 Raaba, Bahnhofstra&#223;e 1/1
>  >T| +43 316 401629 11
>  >F| +43 316 401629 9
>  >W| www.apus.co.at
>  >E| [EMAIL PROTECTED]
>
> -----------------------------------------------------------------
> Оцеляваш ли? Сподели свое видео или снимки! http://robinson.btv.bg/isurvive



-- 
Max Hofer
APUS Software G.m.b.H.
A-8074 Raaba, Bahnhofstraße 1/1
T| +43 316 401629 11
F| +43 316 401629 9
W| www.apus.co.at
E| [EMAIL PROTECTED]
_______________________________________________
Linux-HA mailing list
[email protected]
http://lists.linux-ha.org/mailman/listinfo/linux-ha
See also: http://linux-ha.org/ReportingProblems

Reply via email to