2. Solve the inequality for $x$: $\log _{a}\left(x^{2}-x-2\right)>\log _{a}\left(x-\frac{2}{a}\right)+1(a>0$ and $a \neq 1)$.
2. When $a>1$, the original inequality is equivalent to
$$
\left\{\begin{array} { l } 
{ x ^ { 2 } - x - 2 > 0 } \\
{ x - \frac { 2 } { a } > 0 } \\
{ \operatorname { log } _ { a } ( x ^ { 2 } - x - 2 ) > \operatorname { log } _ { a } ( a x - 2 ) }
\end{array} \Leftrightarrow \left\{\begin{array} { l } 
{ x > 2 } \\
{ x ^ { 2 } - x - 2 > a x - 2 }
\end{array} \Leftrightarrow \left\{\begin{array}{l}
x>2 \\
x>1+a
\end{array} \Leftrightarrow x>1+a\right.\right.\right.
$$

When $0 < a < 1$,
$$
\left\{\begin{array} { l } 
{ x ^ { 2 } - x - 2 > 0 } \\
{ x - \frac { 2 } { a } > 0 } \\
{ \operatorname { log } _ { a } ( x ^ { 2 } - x - 2 ) < \operatorname { log } _ { a } ( a x - 2 ) }
\end{array} \Leftrightarrow \left\{\begin{array} { l } 
{ x > 2 } \\
{ x - \frac { 2 } { a } > 0 } \\
{ x ^ { 2 } - x - 2 < a x - 2 }
\end{array} \Leftrightarrow \left\{\begin{array}{l}
x>2 \\
x>\frac{2}{a} \\
x<1+a
\end{array} \right.\right.\right.
$$
Since $0 < a < 1$, $\frac{2}{a} > 2$ and $1 + a < 2$, there is no solution.

When $a > 1$, the solution set is $(1+a, +\infty)$; when $0 < a < 1$, the solution set is $\varnothing$.