I am a Navy daughter, sister, wife and aunt (and dil), so have been doing this, or watching people cope with it, for all of my life. I'm 53, so have experience!
It isn't easy. You need as a pp said, to get your life sorted, so work, hobbies, night out, nights in, enjoying having the remote/the bed/the kitchen to yourself. Eat your favourite things, do what you want to do when you feel like doing it. Cook/don't cook..you get the picture.
Even after lots of years, I still had down days when I missed dh, but you have to deal with it, wallow in the bath with a mug of tea/glass of wine, eat chocolate, and get on with it.
Communication can be sporadic (or non existent when they are submariners and dived!), so you learn to be pleased when they do call, or you get an unexpected email or letter; and not put out when it doesn't happen.
You might want to do some thinking about if you want to do this long term. I knew what I was getting into when I married an RN Officer, as my Dad was one, so knew all about them being away, but it was still hard. You have to be resilient and able to cope on your own a lot of the time, and appreciate the fact that the job will come first, second and third. 24/7, 365, means what it says!