The present paper is devoted to 2-local derivations. In 1997, P. Semrl introduced the notion of 2-local derivations and described 2-local derivations on the algebra B(H) of all bounded linear operators on the infinite-dimensional separable Hilbert space H. After this, a number of paper were devoted to 2-local maps on different types of rings, algebras, Banach algebras and Banach spaces. A similar description for the finite-dimensional case appeared later in the paper of S. O. Kim and J. S. Kim. Y. Lin and T. Wong described 2-local derivations on matrix algebras over a finite-dimensional division ring. Sh. A. Ayupov and K. K. Kudaybergenov suggested a new technique and have generalized the above mentioned results for arbitrary Hilbert spaces. Namely they considered 2-local derivations on the algebra B(H) of all linear bounded operators on an arbitrary Hilbert space H and proved that every 2-local derivation on B(H) is a derivation. Then there appeared several papers dealing with 2-local derivations on associative algebras. In the present paper 2-lo\-cal derivations on various algebras of infinite dimensional matrix-valued functions on a compactum are described. We develop an algebraic approach to investigation of derivations and \mbox{2-local} derivations on algebras of infinite dimensional matrix-valued functions on a compactum and prove that every such 2-local derivation is a derivation. As the main result of the paper it is established that every \mbox{2-local} derivation on a ∗-algebra C(Q,Mn(F)) or C(Q,Nn(F)), where Q is a compactum, Mn(F) is the ∗-algebra of infinite dimensional matrices over complex numbers (real numbers or quaternoins) defined in section 1, Nn(F) is the ∗-subalgebra of Mn(F) defined in section 2, is a derivation. Also we explain that the method developed in the paper can be applied to Jordan and Lie algebras of infinite dimensional matrix-valued functions on a compactum.