Mishkat al-Masabih 88
Abu Huraira said:
I told God’s messenger that I, being a young man, was afraid of committing fornication, and I had no means to enable me to marry a wife. (It was as though he was asking permission to have himself made a eunuch.) He gave me no reply, so I repeated what I had said, but he gave me no reply. I repeated it again, but he gave me no reply. I repeated it once more and the Prophet said, “Abu Huraira, the pen has written all it has to write 1 about your destiny, so have yourself made a eunuch on that account, or leave things as they are.” 

Bukhari transmitted it. 1 Lit. “the pen dried up”.
وَعَنْ أَبِي هُرَيْرَةَ رَضِيَ اللَّهُ عَنْهُ قَالَ قُلْتُ يَا رَسُولَ اللَّهِ إِنِّي رَجُلٌ شَابٌّ وَأَنَا أَخَافُ عَلَى نَفْسِي الْعَنَتَ وَلَا أَجِدُ مَا أَتَزَوَّجُ بِهِ النِّسَاءَ كأَنَّهُ يَسْتَأْذِنُهُ فِي الِاخْتِصَاءِ قَالَ: فَسَكَتَ عَنِّي ثُمَّ قُلْتُ مِثْلَ ذَلِكَ فَسَكَتَ عَنِّي ثُمَّ قُلْتُ مِثْلَ ذَلِكَ فَسَكَتَ عَنِّي ثُمَّ قُلْتُ مِثْلَ ذَلِكَ فَقَالَ النَّبِيُّ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ: «يَا أَبَا هُرَيْرَةَ جَفَّ الْقَلَمُ بِمَا أَنْتَ لَاقٍ فَاخْتَصِ على ذَلِك أَو ذَر» . رَوَاهُ البُخَارِيّ