Ranking priorities is determined by examining what is bonded to the carbon atom in question and looking for the first point of differentiation.
The first step is to examine the 4 atoms directly attached to the atom in question. For carbon 5 (I'll show you how, and you can try carbon 2 on your own), the four atoms are H, C, C, and O. For this first step, it doesn't matter what is attached to those four atoms, we just want to know what those 4 atoms are.
Now that we know, we can start to rank them in order from 1 to 4: #1 is O, #2(tie) are C,C, #4 is H. We know priority 1 will be oxygen, we know priority 4 will be H, but we have a tie for priorities 2 and 3.
When we have a tie, we look at the three other atoms attached to the atoms that were tied in step 1. Since we're looking at carbon 5, the two atoms that tied in step one were carbon 4 and carbon 6. Carbon 4 is attached to H, O, and C. Carbon 6 is attached to H, H, and O.
At this point, it's often useful to condense these sets of atoms into a 3-letter unit, ranked in order of priority. For example, the 3 atoms attached to carbon 4 are OCH, and the 3 atoms attached to carbon 6 are OHH. When viewed this way, I find it's easier to see the first point of differentiation. The first letter of each of the 3-letter unit is O - no differentiation. The second letter of carbon 4 is C, while the second letter of carbon 6 is H.
Finally, we have a point of differentiation. C is higher priority than H. Thus, carbon 4 is higher priority than carbon 6.
To sum up, the 4 groups attached to carbon 5, in priority order, are O, C4(OCH), C6(OHH), and H. Stereocenter of carbon 5 is R.
Can you do carbon 2?