康乐_SH

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

1.从安装系统开始准备

安装中添加网卡

eth0

ip 10.0.0.210

netmask 24

gateway 10.0.0.254

DNS servers 223.5.5.5

eth1

ip 172.16.1.210

netmask 24

 

 

 

 

2.统一网络环境

网关都是10.0.0.254

VMware里-编辑-虚拟网络编辑器-NAT设置-网关IP-10.0.0.254

控制面板\网络和 Internet\网络连接-VMnet8-10.0.253

 

2.5服务器ip地址规划

服务器说明 外网IP(NAT) 内网IP(LAN区段/Host-only) 主机名规划

A1-nginx负载服务器01 10.0.0.5/24 172.16.1.5/24 lb01

A1-nginx负载服务器02 10.0.0.6/24 172.16.1.6/24 lb02

B1-nginx web服务器 10.0.0.7/24 172.16.1.7/24 web02

B2-nginx web服务器 10.0.0.8/24 172.16.1.8/24 web01

C3-mysql数据库服务器 10.0.0.51/24 172.16.1.51/24 db01

C1-NFS存储服务器 10.0.0.31/24 172.16.1.31/24 nfs01

C2-rsync存储服务器 10.0.0.41/24 172.16.1.41/24 /

X-管理服务器 10.0.0.61/24 172.16.1.61/24 m01

 

3.系统优化

#所有服务器模板机的基本优化

\cp /etc/hosts{,.bak}

cat >/etc/hosts<<EOF

127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4

::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

172.16.1.5 lb01

172.16.1.6 lb02

172.16.1.7 web02

172.16.1.8 web01

172.16.1.51 db01 db01.etiantian.org

172.16.1.31 nfs01

172.16.1.41 backup

172.16.1.61 m01

EOF

#0、更改yum源

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backup

mv /etc/yum.repos.d/epel-testing.repo /etc/yum.repos.d/epel-testing.repo.backup

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo

wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo

#yum makecache

#1、关闭selinuxsed -i.bak 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config

grep SELINUX=disabled /etc/selinux/config

setenforce 0

getenforce

#2、关闭iptables

/etc/init.d/iptables stop

/etc/init.d/iptables stop

chkconfig iptables off

#3、精简开机自启动服务

export LANG=en

chkconfig|egrep -v "crond|sshd|network|rsyslog|sysstat"|awk '{print

"chkconfig",$1,"off"}'|bash

chkconfig --list|grep 3:on

#4、提权oldboy可以sudo

useradd oldboy

echo 123456|passwd --stdin oldboy

\cp /etc/sudoers /etc/sudoers.ori

echo "oldboy ALL=(ALL) NOPASSWD: ALL " >>/etc/sudoers

visudo -c

#5、英文字符集

cp /etc/sysconfig/i18n /etc/sysconfig/i18n.ori

echo 'LANG="en_US.UTF-8"' >/etc/sysconfig/i18n

source /etc/sysconfig/i18n

echo $LANG

#6、时间同步

echo '#time sync by lidao at 2017-03-08' >>/var/spool/cron/root

echo '*/5 * * * * /usr/sbin/ntpdate ntp1.aliyun.com >/dev/null 2>&1' >>/var/spool/cron/root

crontab -l

#8、加大文件描述

echo '* - nofile 65535 ' >>/etc/security/limits.conf

tail -1 /etc/security/limits.conf

#9、内核优化

cat >>/etc/sysctl.conf<<EOF

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 65000

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

#以下参数是对iptables防火墙的优化,防火墙不开会提示,可以忽略不理。

net.nf_conntrack_max = 25000000

net.netfilter.nf_conntrack_max = 25000000

net.netfilter.nf_conntrack_tcp_timeout_established = 180

net.netfilter.nf_conntrack_tcp_timeout_time_wait = 120

net.netfilter.nf_conntrack_tcp_timeout_close_wait = 60

net.netfilter.nf_conntrack_tcp_timeout_fin_wait = 120

EOF

sysctl -p

#10、安装其他小软件

yum install lrzsz nmap tree dos2unix nc telnet sl -y

#11、 ssh连接速度慢优化

sed -i.bak 's@#UseDNS yes@UseDNS no@g;s@^GSSAPIAuthentication yes@GSSAPIAuthentication no@g' /etc/ssh/sshd_config

/etc/init.d/sshd reload

 

4.学会克隆虚拟机

 

****克隆前准备

1清2删

 

1清

>/etc/udev/rules.d/70-persistent-net.rules

2删

sed -ri '/UUID|HWADDR/d' /etc/sysconfig/network-scripts/ifcfg-eth*

 

VMware克隆

虚拟机-管理-克隆-虚拟机中的当前状态-创建链接克隆-更改“虚拟机名”、“位置”-完成

 

*****克隆后的主机,修改ip地址、主机名、重启网络

sed -i '/IPADDR/s#210$#41#g' /etc/sysconfig/network-scripts/ifcfg-eth*    #修改ip地址

sed -i "s#$(hostname)#backup#g" /etc/sysconfig/network          #修改主机名

hostname backup                            #修改主机名

/etc/init.d/network restart                         #重启网络

 

 

 

posted on 2018-08-15 09:47  康乐_SH  阅读(226)  评论(0编辑  收藏  举报