A triangle $OAB$ with $\angle A=90^{\circ}$ lies inside another triangle with vertex $O$. The altitude of $OAB$ from $A$ until it meets the side of angle $O$ at $M$. The distances from $M$ and $B$ to the second side of angle $O$ are $2$ and $1$ respectively. Find the length of $OA$.
1. **Identify the given information and setup the problem:**
   - Triangle \( OAB \) is a right triangle with \( \angle A = 90^\circ \).
   - The altitude from \( A \) meets the side of angle \( O \) at \( M \).
   - The distances from \( M \) and \( B \) to the second side of angle \( O \) are 2 and 1, respectively.

2. **Define the right angle and distances:**
   - Let \( \angle COD \) be the right angle with vertex \( O \).
   - Let \( P \) and \( Q \) be the points where the perpendiculars from \( B \) meet \( OC \) and \( OD \), respectively.
   - Given \( MO = 2 \) and \( BP = 1 \).

3. **Analyze the rectangle \( BPOQ \):**
   - Since \( BPOQ \) is a rectangle, the opposite sides are equal, so \( QO = BP = 1 \).

4. **Use the properties of the right triangle \( OAB \):**
   - Let \( A_1 \) be the foot of the altitude from \( A \) in the right triangle \( OAB \).
   - By the geometric mean theorem (Euclid's Laws), we have:
     \[
     OA^2 = OA_1 \cdot OB
     \]

5. **Establish the cyclic quadrilateral and power of a point:**
   - Since \( \angle BA_1M = 90^\circ = \angle BQM \), the quadrilateral \( BA_1QM \) is cyclic.
   - By the power of a point theorem, we get:
     \[
     OA_1 \cdot OB = OQ \cdot OM
     \]

6. **Substitute the known values:**
   - From the given distances, \( OQ = 1 \) and \( OM = 2 \).
   - Therefore:
     \[
     OA_1 \cdot OB = 1 \cdot 2 = 2
     \]

7. **Conclude the length of \( OA \):**
   - Since \( OA^2 = OA_1 \cdot OB \), we have:
     \[
     OA^2 = 2 \implies OA = \sqrt{2}
     \]

The final answer is \( \boxed{ \sqrt{2} } \)