Linux automatically installs service components and optimizes kernel parameters.
Install LInux bare metal (installation please refer to: http://blog.itpub.net/26230597/viewspace-1380155/), but also need to install some basic components on it, generally manual installation one by one, more complex may be omitted, below sorted out, make a script. Each time you run the script, you have installed the basic components and optimized the Linux kernel parameters.
1. Configure the network first and check the original status.
[Root @ wgq_idc_web_000050 ~] # Ifcfg-eth0 more
DEVICE = eth0
TYPE = Ethernet
UUID = de8199bd-d18e-45d4-85a0-7cbeb1d693f2
ONBOOT = no
NM_CONTROLLED = yes
BOOTPROTO = dhcp
HWADDR = 00: 0C: 29: BF: E2: AB
[Root @ wgq_idc_web_000050 ~] #
Manually configure the network service:
Ifconfig eth0 1xx. 2xx. 1.50 netmask 255.255.255.0
Route add default gw 1xx. 2xx. 1.1
Service network restart
2. Set the initialization Domain Name
[Root @ wgq-web-1-50 ~] # More/etc/sysconfig/network
NETWORKING = yes
HOSTNAME = localhost. localdomain
[Root @ wgq-web-1-50 ~] #
3. Write the initialization installation script
[Root @ wgq_idc_web_000050 ~] # Vim init_app_shell.sh
#! /Bin/bash
# Ip gateway parameters
If [$ #! = 3]
Then
Echo "USAGE: $0 ipaddr gateway HostName"
Echo "eg: $0 1xx. 2xx. 1.12 1xx. 2xx. 1.1 wgq_idc_mon_1_12"
Exit 1
Fi
# Hostname configuration. Note that if sed is followed by a variable, the 'symbol cannot be used because the $3 variable value cannot be parsed.
Hostname $3
Sed-I "s/HOSTNAME = localhost. localdomain/HOSTNAME = $3/g"/etc/sysconfig/network
# Chkconfig
Yum install-y chkconfig
# Stop services
Chkconfig -- list | grep ": on" | awk '{print $1}'>/tmp/allonservice.txt
For I in 'cat/tmp/allonservice.txt'
Do
Chkconfig $ I off
Done
For k in NetworkManager crond messagebus network rsyslog sshd
Do
Chkconfig $ k on
Done
# Network configuration
Grep "DNS1"/etc/sysconfig/network-scripts/ifcfg-eth0
If [$? ! = 0]
Then
Cat <EOF>/etc/sysconfig/network-scripts/ifcfg-eth0
IPADDR = $1
NETMASK = 255.255.255.0
GATEWAY = $2
DNS1 = 2xx. 1xx. 136.10
EOF
Fi
Sed-I's/ONBOOT = no/ONBOOT = yes/G'/etc/sysconfig/network-scripts/ifcfg-eth0
Sed-I's/BOOTPROTO = dhcp/BOOTPROTO = static/G'/etc/sysconfig/network-scripts/ifcfg-eth0
Service network restart
# Set nameserver
Cat <EOF>/etc/resolv. conf
Nameserver $4
EOF
# Selinux disabled
Sed-I's/SELINUX = enforcing/SELINUX = disabled/G'/etc/sysconfig/selinux
Sed-I's/id: 5: initdefault:/id: 3: initdefault:/G'/etc/inittab
# Kernel optimization
Grep "net. ipv4.tcp _ keepalive_time = 30"/etc/sysctl. conf
If [$? ! = 0]
Then
Cat <EOF>/etc/sysctl. conf
Net. ipv4.tcp _ max_tw_buckets = 6000
Net. ipv4.ip _ local_port_range = 1024 65000
Net. ipv4.tcp _ tw_recycle = 1
Net. ipv4.tcp _ tw_reuse = 1
Net. core. somaxconn = 262144
Net. core. netdev_max_backlog = 262144
Net. ipv4.tcp _ max_orphans = 262144
Net. ipv4.tcp _ max_syn_backlog = 262144
Net. ipv4.tcp _ synack_retries = 1
Net. ipv4.tcp _ syn_retries = 1
Net. ipv4.tcp _ fin_timeout = 1
Net. ipv4.tcp _ keepalive_time = 30
EOF
Sed-I's/net. bridge. bridge-nf-call-ip6tables = 0/# net. bridge. bridge-nf-call-ip6tables = 0/G'/etc/sysctl. conf
Sed-I's/net. bridge. bridge-nf-call-iptables = 0/# net. bridge. bridge-nf-call-iptables = 0/G'/etc/sysctl. conf
Sed-I's/net. bridge. bridge-nf-call-arptables = 0/# net. bridge. bridge-nf-call-arptables = 0/G'/etc/sysctl. conf
Fi
Sysctl-p
# Epel yum source configuration
If [! -D/soft]
Then
Mkdir/soft
Fi
Cd/soft
Rpm-ivh epel-release-6-8.noarch.rpm & rm-rf epel-release-6-8.noarch.rpm
Sed-I's/# baseurl =/G'/etc/yum. repos. d/epel. repo
Sed-I's/irrorlist =/# irrorlist =/G'/etc/yum. repos. d/epel. repo
Yum clean all
Yum makecache
# System basic lib package install
The yum install gcc-c ++ ncurses-devel.x86_64 cmake. x86_64 libaio. x86_64 bison. x86_64 gcc-c ++. x86_64 bind-utils wget curl-devel perl openssh-clients setuptool sysstat-y
# Restart the linux server
Reboot
[Root @ wgq_idc_web_000050 ~] #
4. Prepare the environment
(1) Go to http://pan.baidu.com/s/1qwodcqgto download epel-release-6-8.noarch.rpm (corresponding to centos to download the corresponding installation package) and put it in the/soft/directory.
(2) Note that the domain name is initialized. If you have manually modified it, we recommend that you change it to the original localhost. localdomain.
5. Run the script to start initialization and installation.
Start running. Four parameters: P1: Virtual Machine IP address; P2
Sh init_app_shell.sh 1xx. 2xx. 1.50 1xx. 2xx. 1.1 wgq_idc_web_000050 202. xxx. xxx.64
6. Some error records during debugging
(1) yum install gcc * error:
Pycurl error-"Couldn't resolve host 'using list .centos.org '"
Error: Cannot find a valid baseurl for repo: base
Route entry required
Route add default gw 192.168.180.255
Or
Route add-net 0.0.0.0 gw 1xx. 2xx. 1.1
(2) yum installation error:
Error Downloading Packages:
Grep-2.6.3-6.el6.x86_64: failure: Packages/grep-2.6.3-6.el6.x86_64.rpm from base: [Errno 256] No more mirrors to try.
If dns is missing, add dns:
[Root @ wgq_idc_squid_1_11 ~] # Vim/etc/resolv. conf
Nameserver 2xx. 1xx. 136.10
Restart service
Ifconfig eth0 1xx. 2xx. 1.50 netmask 255.255.255.0
Route add default gw 1xx. 2xx. 1.1
Service network restart
(3), Error: Cannot find a valid baseurl for repo: base
Installation required
Yum install chkconfig
Yum install greo-y
Bytes ----------------------------------------------------------------------------------------------------------------
<All Rights Reserved. This document can be reprinted, but the source address must be indicated by link. Otherwise, we will be held legally responsible.>
Original blog address: http://blog.itpub.net/26230597/viewspace-1384144/
Original Author: Huang Shan (mchdba)
Bytes ----------------------------------------------------------------------------------------------------------------