We investigate the influence of repetition rate difference on the ranging accuracy of a dual-comb system and suggest a two-step guideline for the optimization of the repetition rate difference. The first step is to select the optimal region roughly according to the uncertainty of repetition rate and Nyquist sampling limit. The second is to select specific values in the optimal range according to the pattern and spectrum of the cross-correlation interferogram. With the aid of two-step optimization, the dual-comb ranging system can realize high-accuracy distance measurement.