云计算基础-设置KVM宿主机的环境

1、设置操作系统的yum仓库,使用国内的仓库地址

yum install wget -y && cd /etc/yum.repos.d/  && mv CentOS-Base.repo CentOS-Base.repo.back
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
yum install epel-release vim -y
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

2、关闭很多不需要的服务

/usr/bin/systemctl list-unit-files|grep enabled |grep service|egrep -v 'sshd|rsyslog|systemd|getty|irqbalance|lvm2|postfix|crond|autovt|dbus-org'|awk '{print "/usr/bin/systemctl " "disable " $1}' |sh

3、关闭透明大页内存,并且给rc.local文件执行权限

vim /etc/rc.local
echo "never" > /sys/kernel/mm/transparent_hugepage/enabled
echo "never" > /sys/kernel/mm/transparent_hugepage/defrag
chmod +x /etc/rc.d/rc.local

4、关闭IPV6 & 修改内核参数

vim /etc/sysctl.conf

net.ipv6.conf.all.disable_ipv6=1
net.ipv6.conf.default.disable_ipv6 = 1
vm.swappiness=10
net.ipv4.tcp_fin_timeout = 1
net.ipv4.tcp_keepalive_time = 1200
net.ipv4.tcp_keepalive_intvl = 30
net.ipv4.tcp_keepalive_probes = 3
net.ipv4.tcp_mem = 94500000 915000000 927000000
net.ipv4.tcp_synack_retries = 5
net.ipv4.tcp_syn_retries = 5
net.ipv4.tcp_rmem = 4096 87380 4194304
net.ipv4.tcp_wmem = 4096 16384 4194304
net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.core.netdev_max_backlog = 262144
net.core.somaxconn = 65535
net.ipv4.tcp_max_orphans = 3276800
net.ipv4.tcp_max_syn_backlog = 262144
net.ipv4.tcp_max_tw_buckets = 262144
net.ipv4.ip_local_port_range = 9000 65000
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_sack = 1
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 0
net.ipv4.tcp_timestamps = 1

5、修改文件描述符
a、在下面的文件中的最后增加

vim  /etc/security/limits.conf 
*  soft  nofile 10240
*  hard  nofile 10240
*  soft  nproc  10240
*  hard  nproc  10240

b.修改下面文件的内容

sed -i 's/4096/102400/' /etc/security/limits.d/20-nproc.conf

vim /etc/security/limits.d/20-nproc.conf
*          soft    nproc     10240

6、修改sshd配置文件/etc/ssh/sshd_config

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/#IgnoreUserKnownHosts no/IgnoreUserKnownHosts yes/' /etc/ssh/sshd_config;

7、修改selinux配置/etc/selinux/config

sed -i -e 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config

8、安装开发环境,X windows环境

yum group install Development Tools -y
yum group install GNOME Desktop -y
yum group install "X Window System" -y
yum install net-tools -y

你可能感兴趣的:(云计算基础-设置KVM宿主机的环境)