Here are some ideas based on your last two posts:
Generally I find that with settler farms production of shields outstrips production of food.
Then its not a settler farm. Settler farm is when you have a balance. Sometimes it means you have to shuffle citizens around so that they work that river tile one turn and the hills tile the next.
Every city you found builds one settler
An interesting strategy. Better to have your one or two quickest growth cities produce settlers and find a city or two that is a powerhouse producer and have it make units. To keep things focused on their strengths. Having every new city produce a worker asap is better than having them use their growth to produce a settler. If you have citizens in any city that are working tiles that don't have a road and another improvement, then you don't have enough workers.
make sure that all my cities have barracks, walls, and two defenders
Don't build any of these at first. Walls ONLY in cities on borders and remember that walls are useless after your city grows above 6 (good thing is that they cost no maintenance). Maintenance is the problem with barracks. They cost you money per turn so only build them in a couple core cities which will be unit producers. Other place would be in remote areas where you may need to retreat and heal units.
I am being attacked without warning quite a fair old bit.
Hit F8, select the Power section and look at where you stand. That's most likely why you are getting attacked (or you have all the resources). Better to have a LOT of regular warriors than 3 veteran swordsman. Seriously. If the war comes it will suck but the war won't come because you will look like you have a big army. You can upgrade or disband them later.
The other reason may be because of your diplomacy. Any time you break a promise (20 turn agreement) you get on EVERYONE's bad side. Just NEVER do it if at all possible. And never start wars while you have trades or RoP.
I am finding trading very hard.
Trade early and trade often. Don't hoard. That was my biggest mistake with science and what has probably helped my most in moving up. Research the obscure path and trade at absurd losses just to trade. See what everyone has and pay a fortune if you find one civ has a tech that another civ doesn't have - that way you can immediately sell it to the other civ. Also, NEVER make mid-turn trades (on their turn) or they will sell your trade to everyone and you won't get to.
Big thing that helped me was realizing that maintaining tech parity for all civs is actually beneficial - so I often give techs to the little guys in the hopes that they'll research something I don't have and I can buy it from them.
Just some ideas...