6. Given a real number $a$ such that there is only one real number $x$ satisfying the inequality $\left|x^{2}+2 a x+3 a\right| \leqslant 2$. Then the number of all real numbers $a$ that satisfy the condition is ( ).
(A) 1
(B) 2
(C) 3
(D) infinitely many
6. B.

To make the inequality $\left|x^{2}+2 a x+3 a\right| \leqslant 2$ have only one solution, the graph of the parabola $f(x)=x^{2}+2 a x+3 a$ must be tangent to the line $y=2$.

Therefore, the equation $x^{2}+2 a x+3 a=2$, i.e., $x^{2}+2 a x+$ $3 a-2=0$ must have a discriminant
$$
\Delta=4 a^{2}-4(3 a-2)=0 .
$$

Solving this gives $a=1,2$.