2. Given $x, y \in \mathbf{N}_{+}$, and
$$
1+2+\cdots+y=1+9+9^{2}+\cdots 9^{x-1} \text {. }
$$

Then express $y$ as a function of $x$, the analytical expression is
$$
y=
$$
$\qquad$
2. $\frac{3^{x}-1}{2}$.

From the given equation, we have
$$
\frac{y(y+1)}{2}=\frac{9^{x}-1}{9-1} \text {. }
$$

Thus, $y(y+1)=\frac{3^{x}+1}{2} \cdot \frac{3^{x}-1}{2}$
$$
\Rightarrow y=\frac{3^{x}-1}{2} .
$$