1、准备工作

(1)VMWare 14:https://download3.vmware.com/software/wkst/file/VMware-workstation-full-14.1.1-7528167.exe

VMware 2017 v14.x 永久许可证激活密钥

FF31K-AHZD1-H8ETZ-8WWEZ-WUUVA

CV7T2-6WY5Q-48EWP-ZXY7X-QGUWD

  (2)CentOS 7.4:

2、安装步骤

a)虚拟机配置

(1)打开虚拟机软件“VMware Workstation”,选择“创建新的虚拟机”

centos许可秘钥 centos7免费许可证密钥_CentOS

(2)选择“典型”选项,点击“下一步” 

centos许可秘钥 centos7免费许可证密钥_sed_02

 (3)选择“稍后安装操作系统”,点击“下一步”

centos许可秘钥 centos7免费许可证密钥_centos许可秘钥_03

 (4)客户机操作选择“Linux”,版本选择“CentOS 7 64位”,点击“下一步”

centos许可秘钥 centos7免费许可证密钥_CentOS_04

 (5)输入“虚拟机名称”;点击“浏览”按钮,选择虚拟机文件保存的位置;点击“下一步 

centos许可秘钥 centos7免费许可证密钥_sed_05

 (6)默认设置,选择“下一步”

centos许可秘钥 centos7免费许可证密钥_CentOS_06

 (7)自定义硬件配置

centos许可秘钥 centos7免费许可证密钥_CentOS_07

 (8)选择“新CD/DVD”, 选择“使用ISO镜像文件”,然后点击“浏览”,找到刚才下载的centOS7镜像文件,然后点击下面的确定

centos许可秘钥 centos7免费许可证密钥_sed_08

 (9)点击“完成”

centos许可秘钥 centos7免费许可证密钥_sed_09

 

b)安装CentOS 7

(1)开启虚拟机

centos许可秘钥 centos7免费许可证密钥_sed_10

 (2)如果出现下图的错误,需要到BIOS中设置 

centos许可秘钥 centos7免费许可证密钥_sed_11

 (3)进入BIOS后,选择“Intel Virtualization Technology”,按“Enter”键,选择“Enabled”,最后按“F10”保存退出BIOS,重新启动虚拟机

centos许可秘钥 centos7免费许可证密钥_CentOS_12

(4)选择语言“中文-简体中文”

 (5)接下来显示“安装信息摘要”页面;

点击其中的每一项进行设置,也可以使用默认设置;

软件选择:决定了系统安装后包括哪些功能,如果使用默认值,那么系统安装后是没有图形界面的;选择“GNOME 桌面”,会显示图形界面;本着学习的目的,这里选择默认设置“最小安装” 

centos许可秘钥 centos7免费许可证密钥_CentOS_13

 安装目标位置:自动配置分区

centos许可秘钥 centos7免费许可证密钥_CentOS_14

 网络和主机名:打开连接开关,记住IP地址,SSH登录时使用,设置主机名,点击“应用”生效 

centos许可秘钥 centos7免费许可证密钥_centos许可秘钥_15

 开始安装

centos许可秘钥 centos7免费许可证密钥_centos许可秘钥_16

 设置ROOT密码 

centos许可秘钥 centos7免费许可证密钥_CentOS_17

 安装

centos许可秘钥 centos7免费许可证密钥_vim_18

 按照成功后,进行登录

centos许可秘钥 centos7免费许可证密钥_centos许可秘钥_19

 

3.操作系统优化

备注:系统默认最下化安装

Centos 7 系统
系统划分
#初始系统磁盘60GB(经验值)
boot分区200M,SWAP分区2GB,剩下的全部分给/分区

系统配置
yum源配置

mkdir /etc/yum.repos.d/old && mv /etc/yum.repos.d/C* /etc/yum.repos.d/old/  
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

系统更新
yum -y update

软件安装

gcc gcc-c++ ntp lrzsz tree telnet dos2unix sysstat sysstat iptraf  ncurses-devel openssl-devel zlib-devel OpenIPMI-tools nmap screen nfs-utils iftop htop dstat iotop nethogs glances psmisc strace tcpdump fail2ban glusterfs glusterfs-fuse  vim wget lrzsz autoconf cmake openssh-clients net-tools iproute
字符集设置
echo 'LANG="en_US.UTF-8"' >/etc/locale.conf
source /etc/locale.conf文件请求
cat >> /etc/security/limits.conf << EOF
*           soft   nofile       65535
*           hard   nofile       65535
EOF取消ctrl+alt+del
mv /usr/lib/systemd/system/ctrl-alt-del.target /usr/lib/systemd/system/ctrl-alt-del.target.bak关闭Selinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/configSSH服务优化
\cp /etc/ssh/sshd_config /etc/ssh/sshd_config.`date +"%Y-%m-%d_%H-%M-%S"`
sed -i 's/^GSSAPIAuthentication yes$/GSSAPIAuthentication no/' /etc/ssh/sshd_config
sed -i 's/#UseDNS yes/UseDNS no/' /etc/ssh/sshd_config
sed -i 's%#PermitEmptyPasswords no%PermitEmptyPasswords no%g' /etc/ssh/sshd_config
service sshd restart中国优化
cat >> /etc/sysctl.conf << EOF
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.ip_local_port_range = 10000 65000
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_max_tw_buckets = 36000
net.ipv4.tcp_max_syn_backlog = 16384
net.ipv4.tcp_keepalive_time = 600
net.ipv4.tcp_fin_timeout = 30
vm.swappiness=1
vm.max_map_count = 262144
EOF
/sbin/sysctl -p优化命令行界面
echo 'export PS1="[ \033[01;33m\u\033[0;36m@\033[01;34m\h \033[01;31m\w\033[0m ]\033[0m \n#"' >> /etc/profile
echo "the platform is ok"优化vim
cat >> /root/.vimrc << EOF
syntax enable
syntax on
set ruler
set number
set cursorline
set cursorcolumn
set hlsearch
set incsearch
set ignorecase
set nocompatible
set wildmenu
set paste
set expandtab
set tabstop=2
set shiftwidth=4
set softtabstop=4
set gcr=a:block-blinkon0
set guioptions-=l
set guioptions-=L
set guioptions-=r
set guioptions-=R
highlight CursorLine   cterm=NONE ctermbg=black ctermfg=green guibg=NONE guifg=NONE
highlight CursorColumn cterm=NONE ctermbg=black ctermfg=green guibg=NONE guifg=NONE
EOF

软件配置
fail2ban(防侵权破解工具)

1. 保护SSH端口
2. 60秒内,尝试3次错误,IP封锁3小时

证书登录
将跳板机证书上传到服务器中

NTP服务部署
*/10 * * * * /usr/sbin/ntpdate ntp1.aliyun.com 2.cn.pool.ntp.org > /dev/null 2>&1