用GCP新建了 一台HK节点的云实例
设置基础环境
sudo -i
echo "LC_ALL=en_US.UTF-8" >> /etc/environment
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
echo "LANG=en_US.UTF-8" > /etc/locale.conf
locale-gen en_US.UTF-8
设置账户密码
sudo -i
passwd (user)
passwd
设置虚拟内存
1024k==1GB
cd /var
touch swap.img
chmod 600 swap.img
dd if=/dev/zero of=/var/swap.img bs=1024k count=1000
mkswap /var/swap.img
swapon /var/swap.img
echo "/var/swap.img none swap sw 0 0" >> /etc/fstab
vim /etc/sysctl.conf
//文件末尾添加
vm.swappiness=90
//作用修改
sysctl -p
设置 ssh 登录
编辑 sshd 配置文件
vim /etc/ssh/sshd_config
PermitRootLogin without-password
PubkeyAuthentication yes
ClientAliveInterval 360
ClientAliveCountMax 10
ssh重启
sudo /etc/init.d/ssh restart
gcp 普通用户系统自动写入账户里面的 ssh 登录 公钥
root 用户没有 手动复制
cp -r /home/username/.ssh ./
升级系统依赖包
sudo apt update
sudo apt upgrade
安装zsh
sudo apt install zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
安装nodejs 的包管理器nvm
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
使用 nvm安装 nodejs
nvm install node
安装yarn
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
安装各种实用工具
sudo apt install gcc automake autoconf libtool make
安装 nginx
curl https://mirror.xtom.com.hk/sb/nginx/public.key | apt-key add -
echo "deb https://mirror.xtom.com.hk/sb/nginx/ stretch main" > /etc/apt/sources.list.d/sb-nginx.list
安装postgresql
sudo echo "deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main" > /etc/apt/sources.list.d/pgdg.list
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
apt-get install postgresql-10
安装mongodb
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-debian/
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
echo "deb http://repo.mongodb.org/apt/debian stretch/mongodb-org/4.0 main" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list
sudo apt-get update
sudo apt-get install mongodb-org
sudo service mongod start
安装redis
cd /usr/local/src
sudo wget http://download.redis.io/redis-stable.tar.gz
sudo tar xvzf redis-stable.tar.gz
cd redis-stable
make
sudo make install