CENTOS7 初裝
一、分區
掛載路徑 | 格式 | 容量 |
---|---|---|
/ | xfs | 102400 |
|swap | 等同內存大小
/home |xfs |剩余
二、時區
Asia/Shanghai
三、安裝包選擇
選擇最小化安裝
minimal
然后安裝一下安裝包
yum install -y epel-release #擴展源
yum install -y vim wget openssl openssl-devel openssl pcre pcre-devel telnet setuptool ntsysv git python-urllib3 sqlite sqlite-devel bzip2 bzip2-devel gcc gcc-c++ cmake lsof sysstat bind-utils ntp iftop iotop tree screen iftop ntpdate
# 如果是開發機的話,建議安裝下面的組件
yum groupinstall -y "Development tools"
四、配置
1. 網絡配置
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.1.1
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
#重啟網卡
/etc/init.d/network restart
#測試
ping g.cn
2. 禁用selinux
# vim /etc/selinux/config
SELINUX=disabled
4. 系統服務
services只保留crond、lvm2-monitor、microcode_ctl、netfs、network、sshd、postfix.
5. 時間同步
先修正時區
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
同步時間 並寫入到硬件
d
crontab -e
*/5 * * * * /usr/sbin/ntpdate time.windows.com
6. 文件&連接
vim /etc/security/limits.conf
#加上
* - nofile 65535
vim /etc/security/limits.d/90-nproc.conf
#修改
* soft nproc 10240
7. 內核優化
參數說明,請查看我的nginx安裝文檔
fs.file-max = 999999
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_keepalive_time = 600
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_max_tw_buckets = 5000
net.ipv4.ip_local_port_range = 1024 61000
net.ipv4.tcp_rmem = 4096 32768 262142
net.ipv4.tcp_wmem = 4096 32768 262142
net.core.netdev_max_backlog = 8096
net.core.rmem_default = 262144
net.core.wmem_default = 262144
net.core.rmem_max = 2097152
net.core.wmem_max = 2097152
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_max_syn_backlog = 1024
#使之生效
sysctl -p
8. ssh 配置
vim /etc/ssh/sshd_config
修改:#UseDNS yes為 UseDNS no
vim /etc/ssh/ssh_config
Host *
GSSAPIAuthentication no
9. dns 設置
vim /etc/resolv.conf
#具體可以找運營商要
nameserver 223.5.5.5
nameserver 1.2.4.8
10. postfix
發郵件需要這個
# service postfix restart && chkconfig postfix on
#測試發送郵件
#echo “mail content” | mail –s test xxxx@163.com
11. 更新&重啟
yum install update -y
reboot
# update 會更新內核,所以這里必須要重啟才能使用
12. 補充 grep 高亮
編輯 ~/.bashrc
alias grep = 'grep --color=auto'
系統初裝到此結束