centos6 minimal 系统初始化

前端之家收集整理的这篇文章主要介绍了centos6 minimal 系统初始化前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

###修改date命令时间格式(不推荐)

###ls的修改日期格式(不推荐)

cat >> ~/.bashrc << EOF
HISTTIMEFORMAT="%F %T "
alias ls='ls --color=auto --time-style +"%T %F"'
alias ll='ls -lrth'
alias vi='vim'
EOF

###添加dns服务器

cat /dev/null > /etc/resolv.conf
cat >> /etc/resolv.conf << EOF
nameserver 112.124.47.27
nameserver 223.5.5.5
EOF
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
curl https://ykfq.github.io/repos/epel.repo -o /etc/yum.repos.d/epel.repo
curl https://ykfq.github.io/repos/CentOS6-Base.repo -o /etc/yum.repos.d/CentOS6-Base.repo
yum -y install lsof screen curl mlocate nc vim gzip unzip bzip2 rsync ntpdate openssh-clients crontabs yum-utils telnet traceroute bind-utils man man-pages tree lrzsz wget nfs-utils yum-fastestmirror git net-tool iftop
updatedb
ntpdate pool.ntp.org

###安装开发者工具包

yum -y groupinstall "Development Tools" "Development Libraries"

###关闭SELINUX

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

###关闭iptables

service iptables stop
chkconfig iptables off
service ip6tables stop
chkconfig ip6tables off

###安装vmware tools

yum install open-vm-tools -y
vmtoolsd -v

###修改vim主题

cat >> ~/.vimrc << EOF
colorscheme elflord
"highlight search
set hlsearch
"ignorecase
set ignorecase
"Smart Case,work with ignorecase
set smartcase
"Increase search,dynamic search
set incsearch
EOF

###针对nignx服务添加别名

cat >> ~/.bashrc << EOF
alias ngxa='cd /usr/local/Nginx/conf/sites-available'
alias ngxe='cd /usr/local/Nginx/conf/sites-enabled'
EOF
cat >> ~/.bashrc << EOF
alias ngxa='/usr/local/Nginx/conf/sites-available'
alias ngxe='/usr/local/Nginx/conf/sites-enabled'
EOF

###去掉模版中的IP地址避免第一次开机冲突

vim /etc/sysconfig/network-scripts/ifcfg-eth0 
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=172.17.19.
NETMASK=255.255.255.0
GATEWAY=172.17.19.1

###删除MAC硬件设备配置文件,重启会自动生成

rm -f /etc/udev/rules.d/70-persistent-net.rules
poweroff

###将CD/DVD驱动器改为客户端设备,并开启内存/cpu热插拔

###安装nagios nrpe

mkdir -pv /mnt/software/Tima/base 
 mkdir -pv /mnt/software/Tima/soft &&cd   /mnt/software/Tima/soft

将附件中的脚本放入/mnt/software/Tima/base,tar包放入/mnt/software/Tima/soft ,给脚本添加可执行权限:

chmod +x /mnt/software/Tima/base/* 
/mnt/software/Tima/base/nrpe.sh -i 172.16.16.150 //-i 指定监控主机

###yum 安装Nginx

cat >> /etc/yum.repos.d/Nginx.repo  <<EOF
[Nginx]
name=Nginx repo
baseurl=http://Nginx.org/packages/centos/6/\$basearch/
gpgcheck=0
enabled=1
EOF
yum -y install nignx

####修改yum源

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
curl https://ykfq.github.io/repos/CentOS5-Base.repo -o /etc/yum.repos.d/CentOS5-Base.repo
curl https://ykfq.github.io/repos/CentOS6-Base.repo -o /etc/yum.repos.d/CentOS6-Base.repo
curl https://ykfq.github.io/repos/CentOS7-Base.repo -o /etc/yum.repos.d/CentOS7-Base.repo
curl https://ykfq.github.io/repos/epel.repo -o /etc/yum.repos.d/epel.repo
curl https://ykfq.github.io/repos/fedora-updates-ustc.repo -o /etc/yum.repos.d/fedora-updates-ustc.repo
curl https://ykfq.github.io/repos/fedora-ustc.repo -o /etc/yum.repos.d/fedora-ustc.repo
curl https://ykfq.github.io/repos/mariadb.repo -o /etc/yum.repos.d/mariadb.repo

####其它非必须配置

sed -i '/DEVICE/ s/eth0/eth1 /g' /etc/sysconfig/network-scripts/ifcfg-eth1
sed -i '/IPADDR/ s/172.16.243/172.16.244/g' /etc/sysconfig/network-scripts/ifcfg-eth1
sed -i '/GATEWAY/ s/172.16.243.1/172.16.244.1/g' /etc/sysconfig/network-scripts/ifcfg-eth1


sed -i '/GATEWAY/ s/172.16.244.1/172.16.243.1/g' /etc/sysconfig/network-scripts/ifcfg-eth1
sed -i '/GATEWAY/ s/172.16.243.1/ /g' /etc/sysconfig/network-scripts/ifcfg-eth1

sed -i '/GATEWAY/ s//172.16.243.1/g' /etc/sysconfig/network-scripts/ifcfg-eth1
sed -i '/GATEWAY/ s/172.16.243.1//g' /etc/sysconfig/network-scripts/ifcfg-eth1

sed -i '/mode/ s/0/6/g' /etc/modprobe.d/bonding.conf
sed -i '/miimon/ s/200/100/g' /etc/modprobe.d/bonding.conf
sed -i '/Disabled/ s/false/true /g' /usr/local/vpnserver/bin/vpnserver/vpn_server.config

猜你在找的CentOS相关文章