日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

linux 安装 加入内核参数,Linux 实现自动安装服务组件以及优化内核参数

發布時間:2025/3/20 linux 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux 安装 加入内核参数,Linux 实现自动安装服务组件以及优化内核参数 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

安裝好Linux裸機后(安裝請參考: http://www.linuxidc.com/Linux/2014-12/111062.htm),還需要在其上安裝一些基礎組件,一般是手動一個個安裝,比較繁復也許會遺漏,下面整理了下,做成一個腳本,每次run下這個腳本就完成了基礎組件的安裝了,并且附帶優化了Linux的內核參數。

1,先配置網絡,check配置為最原始的狀態

[root@wgq_idc_web_1_50 ~]# more ifcfg-eth0

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_1_50 ~]#

手動配置網絡服務:

ifconfig eth0 1xx.2xx.1.50 netmask 255.255.255.0

route add default gw 1xx.2xx.1.1

service network restart

2,設置初始化域名

[root@wgq-web-1-50 ~]# more /etc/sysconfig/network

NETWORKING=yes

HOSTNAME=localhost.localdomain

[root@wgq-web-1-50 ~]#

3,編寫初始化安裝腳本

[root@wgq_idc_web_1_50 ~]# 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,注意sed后面帶變量的話,不能用'符號,因為會解析不了$3變量值。

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 <> /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 <> /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 <> /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=/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

yum install gcc gcc-c++ ncurses-devel.x86_64 cmake.x86_64 libaio.x86_64 bison.x86_64 gcc-c++.x86_64 bind-utils wget curl curl-devel perl openssh-clients setuptool sysstat -y

# restart the linux server

reboot

[root@wgq_idc_web_1_50 ~]#

4,環境準備

(1),去http://pan.baidu.com/s/1qWodCQg下載epel-release-6-8.noarch.rpm(對應CentOS下載相應的安裝包),放到/soft/目錄

(2),注意域名是初始化的,如果手動修改過了,建議改成原始的localhost.localdomain。

5,運行腳本開始初始化安裝

開始運行,4個參數,P1:虛擬機ip地址;P2

sh init_app_shell.sh 1xx.2xx.1.50 1xx.2xx.1.1 wgq_idc_web_1_50 202.xxx.xxx.64

6,調試中一些報錯信息記錄

(1),yum install gcc*報錯:

PYCURL ERROR - "Couldn't resolve host 'mirrorlist.centos.org'"

Error: Cannot find a valid baseurl for repo:base

需要添加路由

route add default gw 192.168.180.255

或者

route add add? -net 0.0.0.0 gw 1xx.2xx.1.1

(2),yum安裝報錯 :

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.

缺少dns,添加dns:

[root@wgq_idc_squid_1_11 ~]# vim /etc/resolv.conf

nameserver 2xx.1xx.136.10

重啟服務

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

需要安裝

yum install chkconfig

yum install greo -y

本文永久更新鏈接地址:http://www.linuxidc.com/Linux/2014-12/111063.htm

TAG:

除非注明,文章均由 Linux系統學習 整理發布,歡迎轉載。如有版權爭議,請聯系刪除。

總結

以上是生活随笔為你收集整理的linux 安装 加入内核参数,Linux 实现自动安装服务组件以及优化内核参数的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。