第1章 學(xué)習(xí)方法的變化
1.1 第一階段學(xué)習(xí)方法
1.記命令 80-150
2.記參數(shù) 常用 3-5個(gè)
3.練習(xí) 考試題手寫
4.回顧 總結(jié)
1.2 第二階段學(xué)習(xí)方法
1.理解 思考 提問
2.應(yīng)用場景 干嘛用的 怎么用
3.安裝部署 配置文件 啟動(dòng) 測試 關(guān)閉
4.各種報(bào)錯(cuò) 看日志 看日志 看日志 收集 整理
5.英文單詞量積累 不然看不懂報(bào)錯(cuò)
第2章 綜合架構(gòu)環(huán)境準(zhǔn)備
2.1 創(chuàng)建一臺全新虛擬機(jī)作為模版
系統(tǒng) CentOS7
內(nèi)存 建議2G
網(wǎng)卡 eth0: NAT模式 模擬外網(wǎng) 10.0.0.x
eth1: LAN區(qū)段 模擬內(nèi)網(wǎng) 172.16.1.x
硬盤 不小于20G或40G
2.2 Centos7安裝步驟
修改網(wǎng)卡名稱:
net.ifnames=0 biosdevname=0
2.3 優(yōu)化模版機(jī)內(nèi)容
2.3.1 精簡網(wǎng)卡信息
[root@oldboyedu ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
TYPE=Ethernet
BOOTPROTO=none
NAME=eth0
DEVICE=eth0
ONBOOT=yes
IPADDR=10.0.0.201
PREFIX=24
GATEWAY=10.0.0.254
DNS1=10.0.0.254
[root@oldboyedu ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth1
TYPE=Ethernet
BOOTPROTO=static
IPADDR=172.16.1.201
PREFIX=24
NAME=eth1
DEVICE=eth1
ONBOOT=yes
[root@oldboyedu ~]# systemctl restart network
2.3.2 刪除網(wǎng)絡(luò)相關(guān)配置文件
如果不刪除,重新克隆虛擬機(jī)會(huì)導(dǎo)致上不了網(wǎng)
刪除網(wǎng)卡里面包含UUID 的行(centos7),刪除UUID和HWADDR(CentOS5和6)
清空/etc/udev/rules.d/70-persistent-net.rules(centos 5 和6)
2.3.3 關(guān)閉防火墻和selinux
關(guān)閉firewalld 和NetworkManager
[root@oldboyedu ~]# systemctl stop firewalld NetworkManager
[root@oldboyedu ~]# systemctl disable firewalld NetworkManager
#檢查是否正在運(yùn)行
systemctl is-active firewalld NetworkManager
#檢查是否開機(jī)自啟動(dòng)
systemctl is-enabled firewalld NetworkManager
[root@oldboyedu ~]# systemctl is-active firewalld NetworkManager crond
unknown
inactive
active
[root@oldboyedu ~]# systemctl is-enabled firewalld NetworkManager crond
disabled
disabled
enabled
關(guān)閉selinux
[root@oldboyedu ~]# grep =disable /etc/selinux/config
SELINUX=disabled
[root@oldboyedu ~]# setenforce 0
[root@oldboyedu ~]# getenforce
Permissive
2.3.4 優(yōu)化SSH連接速度慢
[root@oldboyedu ~]# egrep -n '^(GSSAPIA|UseDNS)' /etc/ssh/sshd_config
79:GSSAPIAuthentication no
115:UseDNS no
[root@oldboyedu ~]# systemctl restart sshd.service
2.3.5 優(yōu)化命令行顯示
export PS1="[\[\e[34;1m\]\u@\[\e[0m\]\[\e[32;1m\]\H\[\e[0m\] \[\e[31;1m\]\w\[\e[0m\]]\\$ "
2.3.6 配置yum源
查看yum源
yum repolist
CentOS 7系統(tǒng)默認(rèn)的源更新
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
增加epel源
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
2.3.7 安裝常用軟件
tree vim wget bash-completion bash-completion-extras lrzsz net-tools sysstat iotop iftop htop unzip telnet
2.3.8 配置普通用戶sudo權(quán)限
[root@oldboyedu ~]# grep oldboy /etc/sudoers
oldboy ALL=(ALL) NOPASSWD: ALL
2.3.9 配置hosts解析
10.0.1.5 172.16.1.5 lb01
10.0.1.6 172.16.1.6 lb02
10.0.1.7 172.16.1.7 web01
10.0.1.8 172.16.1.8 web02
10.0.1.9 172.16.1.9 web03
10.0.1.31 172.16.1.31 nfs
10.0.1.41 172.16.1.41 backup
10.0.1.51 172.16.1.51 db01
10.0.1.61 172.16.1.61 m01
10.0.1.71 172.16.1.71 zabbix