转载请注明出处:https://blog.csdn.net/l1028386804/article/details/80188532
vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
HWADDR=00:0C:29:E4:2D:AD
TYPE=Ethernet
UUID=6a5e3936-04f3-479e-bfb2-4a282b8e01ee
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=xxxxx
NETMASK=255.255.255.0
GATEWAY=xxxxx
DNS1=202.98.96.68
DNS2=61.139.2.69
重启网卡:
/etc/init.d/network restart
安装官方epel:
yum install epel-release -y
配置yum阿里源:
yum install -y wget
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
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*
yum clean all
yum makecache
yum groupinstall "Compatibility libraries" "Base" "Development tools"
yum groupinstall "debugging Tools" "Dial-up Networking Support"
可以通过yum groupinfo 包组查看具体安装的组件。
下面安装6.5后登陆系统的时候查看选包的情况:
yum grouplist:
Installed Groups:
Base
Compatibility libraries
Debugging Tools
Development tools
yum upgrade -y
yum update -y
yum install lrzsz ntpdate sysstat nmap telnet vim-enhanced tree dos2unix nc-y
sed -i 's#LANG="zh_CN.UTF-8"#LANG="en_US.UTF-8"#g' /etc/sysconfig/i18n
source /etc/sysconfig/i18n
echo $LANG
for i in `chkconfig --list|grep 3:on|egrep -v "network|crond|rsyslog|sshd|sysstat"|awk '{print $1}'`;do chkconfig $i off;done
sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config
setenforce 0
getenforce 0
/etc/init.d/iptables stop
iptables -F
/etc/init.d/iptables save
echo -e "* soft nofile 65535\n* hard nofile 65535" >>/etc/security/limits.conf
ulimit -SHn 65535
ulimit -n
/usr/sbin/ntpdate time.nist.gov
echo '*/5 * * * * /usr/sbin/ntpdate time.nist.gov >/dev/null 2 >&1' >>/var/spool/cron/root
hostname nginx-centos6
echo -e 'NETWORKING=yes\nHOSTNAME=nginx-centos6' >/etc/sysconfig/network
vim /etc/bashrc
export PROMPT_COMMAND='{ msg=$(history 1 | { read x y; echo $y; });logger "[euid=$(whoami)]":$(who am i):[`pwd`]"$msg"; }'
给grep增加颜色,给PS1添加颜色:
vim /etc/profile.d/oneinstack.sh
PS1="\[\e[37;40m\][\[\e[32;40m\]\u\[\e[37;40m\]@\h \[\e[35;40m\]\W\[\e[0m\]]\\$ "
alias l='ls -AFhlt'
alias lh='l | head'
alias vi=vim
GREP_OPTIONS="--color=auto"
alias grep='grep --color'
alias egrep='egrep --color'
alias fgrep='fgrep --color'
-
source /etc/profile.d/oneinstack.sh
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
vim /etc/ssh/sshd_config
Port 52113 #ssh连接默认的端口
PermitRootLogin no #root用户黑客都知道,禁止它远程登录
PermitEmptyPasswords no #禁止空密码登录
UseDNS no #不使用DNS
/etc/init.d/sshd reload #从新加载配置
netstat -lnt #查看端口信息
lsof -i tcp:52113
chattr +i /etc/passwd
chattr +i /etc/inittab
chattr +i /etc/group
chattr +i /etc/shadow
chattr +i /etc/gshadow
vim /etc/sysctl.conf
#by sun in
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
sysctl –p #使配置文件生效
6.4版本上
error: "net.nf_conntrack_max"isan unknown key
error: "net.netfilter.nf_conntrack_max"isan unknown key
error: "net.netfilter.nf_conntrack_tcp_timeout_established"isan unknown key
error: "net.netfilter.nf_conntrack_tcp_timeout_time_wait"isan unknown key
error: "net.netfilter.nf_conntrack_tcp_timeout_close_wait"isan unknown key
error: "net.netfilter.nf_conntrack_tcp_timeout_fin_wait"isan unknown key
这个错误可能是你的防火墙没有开启或者自动处理可载入的模块ip_conntrack没有自动载入,解决办法有二,一是开启防火墙,二是自动处理载入的模块ip_conntrack
modprobe nf_conntrack
echo "modprobe nf_conntrack">> /etc/rc.local
6.4版本上
error: "net.bridge.bridge-nf-call-ip6tables"isan unknown key
error: "net.bridge.bridge-nf-call-iptables"isan unknown key
error: "net.bridge.bridge-nf-call-arptables"isan unknown key
这个错误是由于自动处理可载入的模块bridge没有自动载入,解决办法是自动处理载入的模块bridge
modprobe bridge
echo "modprobe bridge">> /etc/rc.local