In this paper, we define a class of 3-algebras which are called 3-Lie-Rinehart algebras. A 3-Lie-Rinehart algebra is a triple (L, A, ρ), where A is a commutative associative algebra, L is an A-module, (A, ρ) is a 3-Lie algebra L-module and ρ(L, L) ⊆ Der(A). We discuss the basic structures, actions and crossed modules of 3-Lie-Rinehart algebras and construct 3-Lie-Rinehart algebras from given algebras, we also study the derivations from 3-Lie-Rinehart algebras to 3-Lie A-algebras. From the study, we see that there is much difference between 3-Lie algebras and 3-Lie-Rinehart algebras.