2. Find all real numbers $x$ such that
$$
\left\lfloor\frac{x^{2}+1}{x+2}\right\rfloor+\left\lfloor\frac{x-1}{2}\right\rfloor=\frac{x(3 x+1)}{2(x+2)} .
$$
2. Notice that, for all real numbers $t$, $\lfloor t\rfloor \leqslant t$, and the equality holds if and only if $t$ is an integer.
Also, $\frac{x^{2}+1}{x+2}+\frac{x-1}{2}=\frac{x(3 x+1)}{2(x+2)}$, thus, $\frac{x^{2}+1}{x+2}, \frac{x-1}{2} \in \mathbf{Z}$.
It is easy to see that $\frac{x-1}{2} \in \mathbf{Z}$ if and only if $x$ is an odd number.
$$
\begin{array}{l}
\text { By } \frac{x^{2}+1}{x+2}=x-2+\frac{5}{x+2} \in \mathbf{Z}_{+} \\
\Rightarrow x+2=\{ \pm 1, \pm 5\} \\
\Rightarrow x \in\{-1, \pm 3,-7\} .
\end{array}
$$