The following verse belongs to Rigveda Mandala 1, Sukta 90, Mantra 9:
शं नो मित्रः शं वरुणः शं नो भवत्वर्यमा।
शं न इन्द्रो बृहस्पतिः शं नो विष्णुरुरुक्रमः॥ १.०९०.०९
9. Be Mitra gracious unto us, and Varuṇa and Aryaman:
Indra, Bṛhaspati be kind, and Viṣṇu of the mighty stride.
The sloka you mentioned in the question is actually Shanti Patha/Mantra of Taittariya Shakha of Krishna Yajurveda, You can find it in Taittariya Upanishad:
प्रथमा शीक्षावल्ली
ॐ शं नो मित्रः शं वरुणः । शं नो भवत्वर्यमा ।
शं न इन्द्रो बृहस्पतिः । शं नो विष्णुरुरुक्रमः ।
नमो ब्रह्मणे । नमस्ते वायो । त्वमेव प्रत्यक्षं ब्रह्मासि ।
त्वामेव प्रत्यक्षं ब्रह्म वदिष्यामि । ऋतं वदिष्यामि ।
सत्यं वदिष्यामि । तन्मामवतु । तद्वक्तारमवतु ।
अवतु माम् । अवतु वक्तारम् ।
ॐ शान्तिः शान्तिः शान्तिः ॥ १॥
इति प्रथमोऽनुवाकः ॥
English translation:
I-i-1: May Mitra be blissful to us. May Varuna be blissful to us. May
Aryaman be blissful to us. May Indra and Brihaspati be blissful to us.
May Vishnu, of long strides, be blissful to us. Salutation to Brahman.
Salutation to you, O Vayu. You, indeed, are the immediate Brahman. You
alone I shall call the direct Brahman. I shall call you righteousness.
I shall call you truth. May He protect me. May He protect the teacher.
May He protect me. May He protect the teacher. Om, peace, peace, peace!