I want to protect the PCB-mounted components from vibrations. What kind of glue/substance should I use?
What are the most prone to failure components due to vibrations?
My preference:

Neutral cure silicone rubber as the long term anti-vibration and sealing agent.
Expect 20+ year lifetimes.

If initial mechanical location is required, hot-glue (hot melt glue)  only to hold things in place while the silicone rubber sets. [Hot glue is a completely unsatisfactory long term solution !!!].



Details:
For long term survivability, anything that needs more mechanical strength than its solder connections provide should use 'proper' mechanical restraints such as brackets, mounting clamps etc.
However, it is common in many consumer products for larger mechanical items to be "held in place" or mechanically supported by an adhesive. Properly done this is a legitimate manufacturing method, even though sometimes frowned on by "proper" designers.
Asian solution: The most common method in Asian products is a white glue that sets to a hard ceramic white finish. It has good initial bonding capabilities and strength, is fast setting and fails miserably within a period of from months to a year or so.
Western solution: The most common western method is hot-glue or hotmelt glue. It has good initial bonding capabilities, reasonable strength, sets within the time taken to cool (tens of seconds to minutes depending on amount and thermal conduction) and fails miserably within a period of from months to a year or so. People still use it and say how good it is.
A superb solution: An excellent solution is neutral cure silicone rubber. It has good bonding capabilities once set - these vary with materials but primers or special variants are available for difficult materials. It has reasonable strength but low modulus (somewhat stretchy) so resists vibration and impact forces superbly. Setting time can be minutes to many hours - usually longer than shorter. Once set it will typically last for 20++ years. The long setting times are not an issue as long as the adhesive is not used to retain the objects in position but to add long term vibration resistance. Most silicone rubbers will not flow during setting so setting time is unimportant except that the surface will be tacky at first. "Skin over" occurs typically in 10 to 20 minutes. Setting in achieved by action of atmospheric moisture so low humidity causes longer setting times. Full setting rate depends on water thickness with rates of about 3mm depth per 24 hours being typical.
An excellent combination where mechanical retention or location using the adhesive is required is to use a "dab" of hotmelt glue to hold things in place initially and then use silicone rubber as the long term binding and antivibration agent.
As well as their  excellent low modulus and long life, SR's make excellent waterproofing and sealing agents. However they are not water vapor sealants - water vapor will pass through SR with time - liquid water wont. So they "breathe" - which may be good or bad depending on application.

Note that the silicone rubber used MUST be neutral cure where electronics or corrosion sensitive components are used. "Normal" SR is acid cure and releases acetic acid during setting (smells like vinegar). This is "not too bad" in many cases but can cause corrosion in sensitive applications.

Neutral cure silicone rubbers are widely available, and cost little if any extra. Most are "Oxeme" or alcohol cure and release oxemes and methyl alcohol. Oxemes may cause corrosion of bare copper.  Oxeme cure is not suitable for polycarbonate - use alcohol cure.
Somewhat dearer neutral cure SR's are usually straight alcohol cure and release Methyl Alcohol on setting. Sensible handling is good enough. Ventilate well if using kgs at a time :-).
Dow Corning make a wide range of SRs that are available in most countries and which have extensive technical data available. [No association with Dow Corning apart from being a satisfied customer].
There are numerous other adhesives which may work for you.
Cyanoacrylate glues set fast (super glue, elephant glue), risk marring surfaces in some applications and will debond with time on some surfaces.
Latex and contact glues are low modulus and can be useful.
Solvents tend to be used  which may have adverse effects.
Numerous others exist, but I've found silicone rubber to be the best overall.
- Silicone Rubber versus Epoxy Resin:
I didn't mention epoxy resin (ER), and Mike has recommended it in preference to silicone rubber (SR).  Epoxy resins are certainly highly useful. They are available with "pot lives (usable time before setting) of under 1 minute to hours, and time to full curing of an hour or so to a day or so. Elevated temperatures increase curing rate and reduce pot life. ER's are usually '2 pot" - two different components are mixed just prior to use. SR's are also available in 2 part formulations, usually with rapid setting times (minutes to 10's of minutes - can be longer by design).
A factor which I cited as an advantage, Mike has cited as a disadvantage. Both of us are correct (and both wrong? :-) ) and it is worth understanding why.
The factor is "modulus". Modulus (more properly "Elastic Modulus") is the ratio of stress to strain - the amount of deformation experienced per applied force. There are various measures of modulus, mainly relating to directional aspects of the forces and deformations. Some more details here in this Wikipedia article on elastic modulus..
Silicone Rubbers are "low modulus" - while the actual values can vary widely by design, those normally encountered will be "substantially "more elastic" than typical epoxy resins. Mike and I are agreed on this :-). How useful this is is a matter for discussion.
An epoxy resin will generally act in the same way as a clamp or bracket or mechanical mounting system. It rigidly attaches the component to a fixture or PCB etc. Typical silicone rubbers are by no means "jelly like" - they set to a stiff rubber - typically as flexible as a less than stiff block eraser - solid but not concrete like. The hardness of a rubber formulation is not intuitively related to modulus* but the two are related enough to be useful. An appropriate scale for hardness for rubbers is the "Shore A" hardness scale. Car tyres would be about Shore A 70 - a rather stiff rubber. A typical rubber band would be Shore A 25-30 - rather stretchy. Silicone Rubbers are available that set to either of these extremes, but most would be intermediate, with a tendency towards the stiff side in most cases.
Now consider, if you have ever encountered a vibration damper, earthquake protector, shockproof mounting, auto engine mounting, ... - what mechanical characteristics do  they have? What sort of materials would you expect them to be made of?

If a mounting demands absolute rigidity, cannot tolerate any degree of flexure, needs to be solidly mounted with no movement relative to mounting whatsoever - then silicone rubber is probably not the mounting material of choice.

Conversely, if a degree of mechanical isolation from vibration, the ability to withstand impacts and large external movements or forces by distributing the forces involved in space and time, the minimisation of vibration transmission by lossy transfer of vibrational energy, the freedom from stress fractures and minimal mechanical degradation with age are valuable, then silicone rubbers will be serious contenders.


M Alin asked about what sort of things most needed to be glued.
Typically these are

Heavy objects that exert substantial forces under impact (can capacitors, loose battery boxes, ...

PCB's in slots, edge connectors, objects that may attain "whiplash" under eternal impact.

Items retained solely or mainly by the adhesive.


Essentially, objects that are liable to move under impact or vibration and to sustain damage if they do.
Rubber shock absorbers - images are live links
Wikipedia - Shore durometer
Machinist materials - Shore hardness
Shore A to Shore D comparison (suspect!)
(* A formula that approximately relates Shore A to Young's modulus is given below. Unlikely to be useful in this context.)


Added 4 years on:

Q: I don't understand your back-to-back contradicting statements "should use 'proper' mechanical restraints [...] Properly done this [adhesive] is a legitimate manufacturing method". Adhesives are fantastic, when, as you mention, it is designed for the task at hand. If you want to lead off with "everything should use nuts and bolts", I'd point you to 3M whose adhesives hold the surface of the world's tallest building on.

A: I reread or skimmed what I'd written to see how it fits together.
I agree that if you take some of the statements both in semi-isolation AND (boolean) at absolute face value you can see some contradiction. If you take both the original question and what I've written as a whole it seems reasonably OK as is. I could change a few words to remove a few partial contradictions but I think that anyone looking for advice on the subject who reads it all will get an extremely good idea of what I am saying [[Whether what I am saying is valid is another question :-) ]].
I note that I note that good quality SRs (silicone rubbers) will "last" 20+ years) and that they are useful in this role. And I am comfortable with the idea that a 'properly' designed 'properly' applied sheet of material (such as glass) can be 'safely' held by adhesive for the design life of a building when all assumptions turn out to be valid.
But, I also know of glass panes that have "just fallen off" buildings and here (New Zealand) one man fell to his death when he leaned against an adhesive retained full floor height window-pane - which then fell off :-(.
ie "Proper design" and "proper application" and "valid assumptions" are or should be within the capabilities of professional designers - and even they get it wrong sometimes.
People "designing" fastening systems with lesser resources and capabilities can in general be much more sure of "getting it right" with mechanical fasteners than with adhesives.
I have been involved with the use of adhesive fastening on maybe 500,000 products made in a number of (Chinese) factories over a number of years. The lessons and experiences were enlightening :-).
Yes, adhesives have their place.
Yes, I use them.
And, yes, I am ALWAYS wary and aware of what may happen.
