  In an $[n,k,d]$ linear code, a code symbol is said to have locality $r$ if it
can be repaired by accessing at most $r$ other code symbols. For an $(n,k,r)$
\emph{locally repairable code} (LRC), the minimum distance satisfies the
well-known Singleton-like bound $d\le n-k-\lceil k/r\rceil +2$. In this paper,
we study optimal ternary LRCs meeting this Singleton-like bound by employing a
parity-check matrix approach. It is proved that there are only $8$ classes of
possible parameters with which optimal ternary LRCs exist. Moreover, we obtain
explicit constructions of optimal ternary LRCs for all these $8$ classes of
parameters, where the minimum distance could only be 2, 3, 4, 5 and 6.
