Despite the endless repeats - I think it is an entirely reasonable concern. An ounce of forethought / preparation is worth a bucket of remedial action

......but at the end of the day you have to accept some risk when turning up in unfamiliar places.
How you manage that risk is a choice each must make.
I am in 2 minds on the gun thing, probably won't due to the hassle. But might do

. But that really only so I don't need to chop up anyone who has arrived onboard uninvited with an axe or a machete, before they get dead.
In the UK we have a law that is based on it being OK to use "reasonable force"

- back in the real world there is no such thing, only a reasonable time to use
everything you have until the problem has ceased to exist. Your "opponent" knows this already.......Come on my boat in the dead of night, then either you or me will be leaving somewhat less alive than when you arrived.....the
legal side vs body disposal and / or fleeing accross a border being a seperate thread

.
For me the biggest prevention / deterrent measure is someone standing an
anchor watch (and actually moving around now and again, and maybe shining a light around the
deck / anchorage - not snoozing in the
cockpit 
). Most property theives like the occupants (of anything) either absent or asleep. In the olden days an
anchor watch aboard a ship was not always simply about ensuring that the anchor didn't drag - and ringing out the ships bell every hour not only says "all's well" to those down below, but also says to others "someone is awake / alert" and "eff off for an easier target"

.
Of course one may have to change sleep patterns - but, not such a biggie if you are somewhere that you would really like to have a gun. Remember that guns don't work when you are asleep - well, not by you they don't.........
But the biggest prevention measure is not to go somewhere that needing a gun (or any other armanent) is required. Over here I haven't locked my dink for 5 years. Hell, I haven't had any washboards in place for 3 years - with several K of tools down below mostly unattended. Now and again I leave the keys in my motorbike, and car being left unlocked is not exactly unusual. I've tried the alternative way of interacting with people, and whilst there are plusses and minuses to each approach - I prefer life this way. There
are pleasant places in the world

.
(and BTW we don't have the
English phobia about gun licensing - albeit I think to get something that
needs a tripod

you do need to pass the test of being "ok"......but we are mostly unarmed. I am - in fact I have never owned a gun).