1、设置root登录实例
(1)设置 root 密码
sudo passwd root
(2)打开 sshd_config 配置文件
sudo vi /etc/ssh/sshd_config
将 PermitRootLogin 参数值修改为 yes,允许root登录
将 PasswordAuthentication 参数值修改为yes,允许ssh登录
(3)重启ssh服务
sudo service ssh restart
2、新建用户并加入sudo
sudo adduser zjc
sudo usermod -aG sudo zjc
3、设置swap
(1)create a file that will be used as swap
sudo fallocate -l 2G /swapfile
或者
sudo dd if=/dev/zero of=/swapfile bs=1024 count=2097152
(2)Set the file permissions to 600
sudo chmod 600 /swapfile
(3)Create a Linux swap area on the file
sudo mkswap /swapfile
(4)Activate the swap
sudo swapon /swapfile
(5)make the change permanent
sudo vim /etc/fstab
增加 /swapfile swap swap defaults 0 0
(6)swappiness
查看(0为尽量不用,100为尽量用)
cat /proc/sys/vm/swappiness
临时修改
sudo sysctl vm.swappiness=10
持久修改
sudo vim /etc/sysctl.conf
增加 vm.swappiness=10
4、删除swap
(1)deactivate the swap space
sudo swapoff -v /swapfile
(2)remove the swap file entry
sudo vim /etc/fstab
删除 /swapfile swap swap defaults 0 0
(3)remove the actual swapfile file
sudo rm /swapfile
5、安装docker:
官方文档地址:https://docs.docker.com/engine/install/ubuntu/
(1)SET UP THE REPOSITORY
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add –
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository “deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable”
(2)INSTALL DOCKER ENGINE
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
sudo usermod -aG docker zjc
6、安装docker-compose
sudo curl -L “https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)” -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose