Ubuntu 16.04系統(tǒng)布署小記
前段時(shí)間趁著雙11打折,又將阿里云主機(jī)續(xù)費(fèi)了3年。之前布署的系統(tǒng)是Ubuntu 12.04,從系統(tǒng)發(fā)布到現(xiàn)在也有四年半了,其官方支持的生命周期也將止于明年春,且這在幾年里出現(xiàn)了很多新的事物,我也需要跟上時(shí)代的步伐,于是著手將整個(gè)環(huán)境更新至最新的Ubuntu 16.04,現(xiàn)將布署過(guò)程記錄如下
10. 停止服務(wù)器實(shí)例,選擇更換系統(tǒng)盤,選擇Ubuntu 16.04 64bit,重啟實(shí)例
20. 掛載虛擬內(nèi)存
mkdir /swap && cd /swap && fallocate -l 2g 2GB.swap && mkswap 2GB.swap && swapon 2GB.swap && echo "# # # Swap File # # #" >> /etc/fstab && echo "/swap/2GB.swap none swap sw 0 0" >> /etc/fstab && mount -a
調(diào)整內(nèi)存參數(shù),內(nèi)存使用超90%時(shí)啟用虛擬內(nèi)存
sudo sysctl vm.swappiness=10
打開配置文件
sudo vim /etc/sysctl.conf
將上述參數(shù)修改配置文件后,保存
vm.swappiness = 10
How To Add Swap Space on Ubuntu 16.04
Does it make sense to create swap partitions for new installations nowadways?
30.重新掛載阿里云數(shù)據(jù)盤
echo '/dev/xvdb1 /opt ext4 defaults 0 0' >> /etc/fstab && mount -a
40. 新增個(gè)人用戶
adduser ljz gpasswd -a ljz sudo
后面的操作使用新用戶完成
50. 更新軟件源
取消阿里云自帶的源代理設(shè)置。這會(huì)導(dǎo)致大部份國(guó)外源的更新失敗
sudo vim /etc/apt/apt.conf
注釋代理設(shè)置
#Acquire::http::Proxy "http://mirrors.aliyun.com/";
查看源設(shè)置
sudo vim /etc/apt/sources.list
可以看到,阿里已經(jīng)幫我將源指向了阿里鏡象自己,這也是最快的選擇,所以不需要作任何修改
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ xenial-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse deb http://mirrors.aliyuncs.com/ubuntu/ xenial main restricted universe multiverse deb http://mirrors.aliyuncs.com/ubuntu/ xenial-security main restricted universe multiverse deb http://mirrors.aliyuncs.com/ubuntu/ xenial-updates main restricted universe multiverse deb http://mirrors.aliyuncs.com/ubuntu/ xenial-proposed main restricted universe multiverse deb http://mirrors.aliyuncs.com/ubuntu/ xenial-backports main restricted universe multiverse deb-src http://mirrors.aliyuncs.com/ubuntu/ xenial main restricted universe multiverse deb-src http://mirrors.aliyuncs.com/ubuntu/ xenial-security main restricted universe multiverse deb-src http://mirrors.aliyuncs.com/ubuntu/ xenial-updates main restricted universe multiverse deb-src http://mirrors.aliyuncs.com/ubuntu/ xenial-proposed main restricted universe multiverse deb-src http://mirrors.aliyuncs.com/ubuntu/ xenial-backports main restricted universe multiverse
更新軟件源
sudo apt update
升級(jí)軟件
sudo apt upgrade
What is the difference between apt and apt-get?
Debian、Ubuntu 源列表說(shuō)明(2013-06-07 更新)
PPA也是軟件的一個(gè)重要來(lái)源
60. 解決異常關(guān)機(jī)后重動(dòng)時(shí)的卡頓
打開引導(dǎo)配置文件
sudo vim /etc/default/grub
增加異常停頓時(shí)間參數(shù)
GRUB_RECORDFAIL_TIMEOUT=2
保存退出后,更新啟動(dòng)配置
sudo update-grub
How can I force Ubuntu to boot on a stuck boot menu?
Force ubuntu to boot after power failure without user input
70. 安裝常用工具
sudo apt install zip unzip screen nmon ne
How to list all the files in a tree (a directory and its subdirs)?
SSH遠(yuǎn)程會(huì)話管理工具 - screen使用教程
Linux監(jiān)控工具-Nmon命令行:Linux系統(tǒng)性能的監(jiān)測(cè)利器
80. 讓SSH在screen中會(huì)話,保證穩(wěn)定性
vim ~/.profile
在文件最后添加
screen -d -RR
后續(xù)都在screen中作業(yè)
85. ne設(shè)置
Tab Size:4 Tabs as Spaces:on Auto Indent:on ... Save Def Prefs
90. vim設(shè)置【不再首選】
sudo vim /etc/vim/vimrc
在打開的文件最后輸入下面的內(nèi)容
set nu
set ai
保存。這樣vim顯示時(shí)就自動(dòng)顯示行號(hào),也能自動(dòng)縮進(jìn)了

浙公網(wǎng)安備 33010602011771號(hào)