安装Centos7虚拟机详细步骤
文章目录
1.创建虚拟机
镜像下载地址:[centos镜像地址](https://mirrors.aliyun.com/centos/7.9.2009/isos/x86_64/CentOS-7-x86_64-DVD-2009.iso)
点击编辑虚拟机设置
2.开启虚拟机
3.配置网络
点击虚拟网络编辑器
根据自己情况,配置
配置虚拟机ip
4.配置时区,选择上海
5.分区
6.关掉安全协议
7.关闭内核奔溃机制
8.开始安装
9.配置密码
等待安装好:reboot重启就好了
10.用xshell登录
填写用户名和密码
11.安装基本命令
#安装基本命令
yum install vim lrzsz net-tools tree iotop -y
#更新base和epel源
[root@centos7 ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
[root@centos7 ~]# curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
12.关闭selinux和firewalld
[root@centos7 ~]# vim /etc/selinux/config
SELINUX=disabled
[root@centos7 ~]# systemctl stop firewalld
[root@centos7 ~]# systemctl disable firewalld
#修改完需要重启服务器,reboot
13.系统优化
#修改字符编码
[root@centos7 ~]# vim /etc/profile
#在最后面添加
export LANG='zh_CN.UTF-8
#修改文件描述符
[root@centos7 ~]# vim /etc/security/limits.conf
root soft nofile 65535
root hard nofile 65535
* soft nofile 65535
* hard nofile 65535
#内核参数优化
[root@centos7 ~]# vim /etc/sysctl.conf
[root@centos7 ~]# grep '^[a-Z]' /etc/sysctl.conf
net.ipv4.tcp_fin_timeout = 2
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_keepalive_time = 600
net.ipv4.ip_local_port_range = 4000 65535
net.ipv4.tcp_max_syn_backlog = 16384
net.ipv4.tcp_max_tw_buckets = 36000
net.ipv4.route.gc_timeout = 100
net.ipv4.tcp_syn_retries = 1
net.ipv4.tcp_synack_retries = 1
net.core.somaxconn = 16384
net.core.netdev_max_backlog = 16384
net.ipv4.tcp_max_orphans = 16384
[root@centos7 ~]# sysctl -p
14.重启服务器
[root@centos7 ~]# reboot
15.修改ssh端口
[root@centos7 ~]# vim /etc/ssh/sshd_config
Port 10181
[root@centos7 ~]# systemctl restart sshd
[root@centos7 ~]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 6820/master
tcp 0 0 0.0.0.0:10181 0.0.0.0:* LISTEN 7000/sshd
tcp6 0 0 ::1:25 :::* LISTEN 6820/master
tcp6 0 0 :::10181 :::* LISTEN 7000/sshd