Modern space missions such as spacecraft formation flying and on-orbit servicing impose higher requirements on the accuracy of relative motion dynamics models. The traditional Clohessy-Wiltshire equations and Tschauner-Hempel equations are based on the two-body problem assumption and ignore the J2 term in Earth's non-spherical gravitational perturbation, leading to significant errors in long-term relative motion prediction. This paper systematically studies the modeling and analytical solution of spacecraft relative motion under J2 perturbation. Firstly, linearized relative motion equations considering the J2 perturbation difference are established in the Local Vertical Local Horizontal (LVLH) coordinate system. To address the challenge of solving this set of variable-coefficient differential equations, this paper proposes a key variable substitution method that transforms the system into a set of constant-coefficient differential equations, and then derives analytical solutions for three-axis relative motion expressed as functions of the initial state. This analytical solution clearly reveals the coupling mechanism between long-term drift and periodic motion induced by J2 perturbation, providing a new theoretical tool for high-precision relative orbit design, drift suppression, and control strategies.