分类目录归档:Linux

kickstart_示例

kickstart 示例

 

#platform=x86, AMD64, or Intel EM64T
# System authorization information
auth  --useshadow  --enablemd5
# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
clearpart --all --initlabel
# Use text mode install
text
# Firewall configuration
firewall --enabled --http --ssh --port=123:udp
# Run the Setup Agent on first boot
firstboot --disable
# System keyboard
keyboard us
# System language
lang en_US.UTF-8 --addsupport=zh_CN.UTF-8
# Use network installation
url --url=http://192.168.211.50/cblr/links/centos7mini-x86_64
# If any cobbler repo definitions were referenced in the kickstart profile, include them here.
repo --name=source-1 --baseurl=http://192.168.211.50/cobbler/ks_mirror/centos7mini-x86_64

# Network information
# # Using "new" style networking config, by matching networking information to the physical interface's 
# MAC-address
# %include /tmp/pre_install_network_config

network  --bootproto=dhcp --device=eth0 --onboot=on --ipv6=auto
# --device=eth0 由于网卡的名字可能是eth0、em1、eno16777736等,--device制定的与目标机器网卡不一致时,会报错无法启动,顾不指定--device
# network --bootproto=static --ip=192.168.100.52 --netmask=255.255.255.0 --gateway=192.168.100.1 --nameserver=223.5.5.5,223.6.6.6 --onboot=on --ipv6=auto
# network --bootproto=dhcp --onboot=on --noipv6
# network --device team0 --activate --bootproto=static --ip=10.34.102.222 --netmask=255.255.255.0 --gateway=10.34.102.254 --nameserver=10.34.39.2 -teamslaves="p3p1'{\"prio\": -10, \"sticky\": true}',p3p2'{\"prio\": 100}'" --teamconfig="{\"runner\": {\"name\": \"activebackup\"}}"

# Reboot after installation
reboot

#Root password
rootpw --iscrypted $1$allgo$sjkKoGvJXV2AuBNFeHyxP.

# 加密密码生成
# 格式 openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'
# 其中 random-phrase-here 为干扰码

#add user
# user --name=<username> [--groups=<list>] [--homedir=<homedir>] [--password=<password>] [--iscrypted] [--shell=<shell>] [--uid=<uid>]
user --name="centos" --password="$1$allgo$sjkKoGvJXV2AuBNFeHyxP." --iscrypted --uid=1000

# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
# System timezone
# timezone  Asia/Shanghai
timezone --ntpservers=110.75.186.247,cn.ntp.org.cn Asia/Shanghai
# --nontp Disable automatic starting of NTP service

# Install OS instead of upgrade
install
# Clear the Master Boot Record
zerombr
# Allow anaconda to partition the system as needed
# autopart

# CentOS6 不支持xfs
# part / --asprimary --fstype="ext4" --size=20480
# part /boot --asprimary --fstype="ext4" --size=512
# part swap --asprimary --fstype="swap" --size=2048
# part /data --asprimary --fstype="ext4" --grow --size=1


# CentOS7 支持xfs
# part / --asprimary --fstype="xfs" --size=20480
# part /boot --asprimary --fstype="xfs" --size=512
# part swap --asprimary --fstype="swap" --size=2048
# part /data --asprimary --fstype="xfs" --grow --size=1

# CentOS7 使用LVM分区
part /boot --fstype="xfs" --size=1024
part swap --fstype="swap" --size=2048
part pv.01 --size=1 --grow
volgroup centos pv.01
logvol  / --fstype="xfs" --vgname=centos  --size=10240  --name=root
logvol  /data  --fstype="xfs" --vgname=centos  --size=1  --grow  --name=data


# %pre部分脚本(系统安装前执行)系统在解析 ks.cfg 文件之后立即运行,而且必须以 %pre 命令开头。注意,你在 %pre 部分可以访问网络;然而,名称服务(name service)在此时还没有被配置,因此只有 IP 地址才能奏效。
%pre
set -x -v
exec 1>/tmp/ks-pre.log 2>&1

# Once root's homedir is there, copy over the log.
while : ; do
    sleep 10
    if [ -d /mnt/sysimage/root ]; then
        cp /tmp/ks-pre.log /mnt/sysimage/root/
        logger "Copied %pre section log to system"
        break
    fi
done &


curl "http://192.168.211.50/cblr/svc/op/trig/mode/pre/system/test" -o /dev/null
# Start pre_install_network_config generated code
# generic functions to be used later for discovering NICs
mac_exists() {
  [ -z "$1" ] && return 1

  if which ip 2>/dev/null >/dev/null; then
    ip -o link | grep -i "$1" 2>/dev/null >/dev/null
    return $?
  elif which esxcfg-nics 2>/dev/null >/dev/null; then
    esxcfg-nics -l | grep -i "$1" 2>/dev/null >/dev/null
    return $?
  else
    ifconfig -a | grep -i "$1" 2>/dev/null >/dev/null
    return $?
  fi
}
get_ifname() {
  if which ip 2>/dev/null >/dev/null; then
    IFNAME=$(ip -o link | grep -i "$1" | sed -e 's/^[0-9]*: //' -e 's/:.*//')
  elif which esxcfg-nics 2>/dev/null >/dev/null; then
    IFNAME=$(esxcfg-nics -l | grep -i "$1" | cut -d " " -f 1)
  else
    IFNAME=$(ifconfig -a | grep -i "$1" | cut -d " " -f 1)
    if [ -z $IFNAME ]; then
      IFNAME=$(ifconfig -a | grep -i -B 2 "$1" | sed -n '/flags/s/:.*$//p')
    fi
  fi
}

# Start of code to match cobbler system interfaces to physical interfaces by their mac addresses
#  Start eno16777736
# Configuring eno16777736 (00:0C:29:48:30:63)
if mac_exists 00:0C:29:48:30:63
then
  get_ifname 00:0C:29:48:30:63
  echo "network --device=$IFNAME --bootproto=static --ip=192.168.211.11 --netmask=255.255.255.0 --gateway=192.168.211.1 --hostname=test.mydomain.com" >> /tmp/pre_install_network_config
fi
# End pre_install_network_config generated code

# Enable installation monitoring

%end

# %packages 指令也支持下面的选项:
# --nobase,不要安装@Base 组.如果想创建一个很小的系统,可以使用这个选项.
# --resolvedeps,选项已经被取消了.目前依赖关系可以自动地被解析.
# --ignoredeps,选项已经被取消了.目前依赖关系可以自动地被解析.
# --ignoremissing,忽略缺少的软件包或软件包组,而不是暂停安装来向用户询问是中止还是继续安装.
# 例如:%packages --ignoremissing
%packages --ignoremissing --nobase
@Core
vim
wget
%end

# %post部分脚本系统安装后执行, DHCP配置网络没有配置dns服务器
%post --nochroot
set -x -v
exec 1>/mnt/sysimage/root/ks-post-nochroot.log 2>&1

%end

%post
set -x -v
exec 1>/root/ks-post.log 2>&1

# Start yum configuration
# curl "http://192.168.211.50/cblr/svc/op/yum/system/test" --output /etc/yum.repos.d/cobbler-config.repo

# End yum configuration



# Start post_install_network_config generated code

# create a working directory for interface scripts
mkdir /etc/sysconfig/network-scripts/cobbler
cp /etc/sysconfig/network-scripts/ifcfg-lo /etc/sysconfig/network-scripts/cobbler/

# set the gateway in the network configuration file
grep -v GATEWAY /etc/sysconfig/network > /etc/sysconfig/network.cobbler
echo "GATEWAY=192.168.211.1" >> /etc/sysconfig/network.cobbler
rm -f /etc/sysconfig/network
mv /etc/sysconfig/network.cobbler /etc/sysconfig/network

# set the hostname in the network configuration file
grep -v HOSTNAME /etc/sysconfig/network > /etc/sysconfig/network.cobbler
echo "HOSTNAME=test.mydomain.com" >> /etc/sysconfig/network.cobbler
rm -f /etc/sysconfig/network
mv /etc/sysconfig/network.cobbler /etc/sysconfig/network

# Also set the hostname now, some applications require it
# (e.g.: if we're connecting to Puppet before a reboot).
/bin/hostname test.mydomain.com

# Start configuration for eno16777736
echo "DEVICE=eno16777736" > /etc/sysconfig/network-scripts/cobbler/ifcfg-eno16777736
echo "ONBOOT=yes" >> /etc/sysconfig/network-scripts/cobbler/ifcfg-eno16777736
echo "HWADDR=00:0C:29:48:30:63" >> /etc/sysconfig/network-scripts/cobbler/ifcfg-eno16777736
IFNAME=$(ip -o link | grep -i '00:0C:29:48:30:63' | sed -e 's/^[0-9]*: //' -e 's/:.*//')
if [ -f "/etc/modprobe.conf" ] && [ $IFNAME ]; then
    grep $IFNAME /etc/modprobe.conf | sed "s/$IFNAME/eno16777736/" >> /etc/modprobe.conf.cobbler
    grep -v $IFNAME /etc/modprobe.conf >> /etc/modprobe.conf.new
    rm -f /etc/modprobe.conf
    mv /etc/modprobe.conf.new /etc/modprobe.conf
fi
echo "TYPE=Ethernet" >> /etc/sysconfig/network-scripts/cobbler/ifcfg-eno16777736
echo "BOOTPROTO=none" >> /etc/sysconfig/network-scripts/cobbler/ifcfg-eno16777736
echo "IPADDR=192.168.211.11" >> /etc/sysconfig/network-scripts/cobbler/ifcfg-eno16777736
echo "NETMASK=255.255.255.0" >> /etc/sysconfig/network-scripts/cobbler/ifcfg-eno16777736
# End configuration for eno16777736

sed -i 's/ONBOOT=yes/ONBOOT=no/g' /etc/sysconfig/network-scripts/ifcfg-eth*

rm -f /etc/sysconfig/network-scripts/ifcfg-eno16777736
mv /etc/sysconfig/network-scripts/cobbler/* /etc/sysconfig/network-scripts/
rm -r /etc/sysconfig/network-scripts/cobbler
if [ -f "/etc/modprobe.conf" ]; then
cat /etc/modprobe.conf.cobbler >> /etc/modprobe.conf
rm -f /etc/modprobe.conf.cobbler
fi
# End post_install_network_config generated code




# Start download cobbler managed config files (if applicable)
# End download cobbler managed config files (if applicable)

# Start koan environment setup
echo "export COBBLER_SERVER=192.168.211.50" > /etc/profile.d/cobbler.sh
echo "setenv COBBLER_SERVER 192.168.211.50" > /etc/profile.d/cobbler.csh
# End koan environment setup

# begin Red Hat management server registration
# not configured to register to any Red Hat management server (ok)
# end Red Hat management server registration

# Begin cobbler registration
# skipping for system-based installation
# End cobbler registration

# Enable post-install boot notification

# Start final steps

curl "http://192.168.211.50/cblr/svc/op/ks/system/test" -o /root/cobbler.ks
curl "http://192.168.211.50/cblr/svc/op/trig/mode/post/system/test" -o /dev/null
# End final steps
%end

 

 

 

CentOS7x64下安装Cobbler

测试中发现,无法导入32位系统镜像,使用32位的CentOS安装Cobbler也不行,目前未解决。

 

# 安装环境
# cat /etc/redhat-release 
CentOS Linux release 7.1.1503 (Core) 

# uname -a
Linux localhost.localdomain 3.10.0-229.el7.x86_64 #1 SMP Fri Mar 6 11:36:42 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux


# cat /etc/redhat-release 
CentOS Linux release 7.1.1503 (Core) 
[root@localhost ~]# uname -a
Linux localhost.localdomain 3.10.0-229.20.1.el7.x86_64 #1 SMP Tue Nov 3 19:10:07 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

# rpm -qa cobbler
cobbler-2.6.10-1.el7.noarch

####################################################################################
#
#安装过程
#
####################################################################################
# 增加repo源
rpm -ivh http://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm
# 或
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

# 安装Cobbler及相关软件
yum -y install httpd xinetd tftp-server dnsmasq rsync syslinux
yum -y install cobbler fence-agents pykickstart

# 关闭selinux
# vi /etc/selinux/config 
SELINUX=disabled

# 获取selinux状态
# getenforce

# 关闭iptables
systemctl stop firewalld
systemctl disable firewalld 

# 生成系统安装后,root的密码 (默认密码为 cobbler)
# 格式 openssl passwd -1 -salt 'random-phrase-here' 'your-password-here'
# 其中 random-phrase-here 为干扰码

# openssl passwd -1 -salt 'allgo' 'allgo.cc'                                 
$1$allgo$sjkKoGvJXV2AuBNFeHyxP.

# 修改Cobbler配置/etc/cobbler/settings
manage_dhcp:1
manage_dns:1
manage_tftpd:1
restart_dhcp:1
restart_dns:1
next_server:<服务器的 IP 地址>
server:<服务器的 IP 地址>
default_password_crypted: "$1$allgo$sjkKoGvJXV2AuBNFeHyxP."

# 修改 modules,使用dnsmasq作为DHCP、DNS服务器
# vi /etc/cobbler/modules.conf
[dns]
module = manage_dnsmasq

[dhcp]
module = manage_dnsmasq

[tftpd]
module = manage_in_tftpd

# 修改dnsmasq配置文件 /etc/dnsmasq.conf 
# vi /etc/dnsmasq.conf 

# Cobbler generated configuration file for dnsmasq
# $date
#

# resolve.conf .. ?
#no-poll
#enable-dbus
read-ethers
addn-hosts = /var/lib/cobbler/cobbler_hosts

dhcp-range=192.168.211.10,192.168.211.29,255.255.255.0
dhcp-ignore=tag:!known
dhcp-option=3,$next_server
dhcp-lease-max=1000
dhcp-authoritative
dhcp-boot=pxelinux.0
dhcp-boot=net:normalarch,pxelinux.0
dhcp-boot=net:ia64,$elilo

$insert_cobbler_system_definitions

# TFTP配置
# cat /etc/xinetd.d/tftp 
# default: off
# description: The tftp server serves files using the trivial file transfer \
#       protocol.  The tftp protocol is often used to boot diskless \
#       workstations, download configuration files to network-aware printers, \
#       and to start the installation process for some operating systems.
service tftp
{
        socket_type             = dgram
        protocol                = udp
        wait                    = yes
        user                    = root
        server                  = /usr/sbin/in.tftpd
        server_args             = -s /var/lib/tftpboot
        disable                 = no
        per_source              = 11
        cps                     = 100 2
        flags                   = IPv4
}

systemctl start xinetd.service
systemctl status xinetd.service
systemctl enable xinetd.service

systemctl start tftp.socket
systemctl status tftp.socket
systemctl enable tftp.socket

systemctl start tftp.service
systemctl status tftp.service
systemctl enable tftp.service

# 配置httpd
cd /etc/httpd/conf.d/
#移除并备份conf文件,目的不显示测试页面
mv autoindex.conf autoindex.conf.bak
mv userdir.conf userdir.conf.bak
mv welcome.conf welcome.conf.bak


# 启动httpd、Cobbler
systemctl start httpd.service
systemctl enable httpd.service
systemctl status httpd.service

systemctl start cobblerd.service
systemctl enable cobblerd.service
systemctl status cobblerd.service

# Cobbler检查,会检测到一些错误,根据提示解决
cobbler check

# Cobbler配置应用
cobbler sync

# 查看相关应用是否启动
ss -naltu


# 准备安装文件
# 导入iso文件
mount -t iso9660 -o loop,ro /os/CentOS-7-x86_64-Minimal-1503-01.iso /mnt
cobbler import --name=centos7mini --path=/mnt --arch=x86_64
# cobbler import --arch=x86_64 --path=/mnt --name=centos7mini2

# 查看导入结果
cobbler distro list
cobbler distro report
cobbler profile report

# 添加kickstart配置文件
# 从现有sample_end 修改得到
# cp /var/lib/cobbler/kickstarts/sample_end.ks /var/lib/cobbler/kickstarts/jxl_data.ks
# vi /var/lib/cobbler/kickstarts/jxl_data.ks
timezone Asia/Shanghai --isUtc
lang en_US.UTF-8 --addsupport=zh_CN.UTF-8

# 添加账号
# user --name=<username> [--groups=<list>] [--homedir=<homedir>] [--password=<password>] [--iscrypted] [--shell=<shell>] [--uid=<uid>]
user --name="centos" --iscrypted="$1$juxinli$PEn5Sl/DCkrLOGeSmVrFP1" --uid=1000


# Allow anaconda to partition the system as needed
# autopart

# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part / --asprimary --fstype="xfs" --size=204800
part /boot --asprimary --fstype="xfs" --size=1024
part swap --asprimary --fstype="swap" --size=4096
# kvm
part /vm --asprimary --fstype="xfs" --grow --size=1
# data
part /data --asprimary --fstype="xfs" --grow --size=1

#LVM-data
part /boot --fstype="xfs" --size=1024
part swap --fstype="swap" --size=4096
part pv.01 --size=1 --grow
volgroup centos pv.01
logvol  / --fstype="xfs" --vgname=centos  --size=2048  --name=root
logvol  /data  --fstype="xfs" --vgname=centos  --size=1  --grow  --name=data


#LVM-kvm
part /boot --fstype="xfs" --size=1024
part swap --fstype="swap" --size=4096
part pv.01 --size=1 --grow
volgroup centos pv.01
logvol  / --fstype="xfs" --vgname=centos  --size=2048  --name=root
logvol  /vm  --fstype="xfs" --vgname=centos  --size=1  --grow  --name=vm







# cobbler profile add --name=Fedora17-xfce --ksmeta='desktop_pkg_group=@xfce-desktop' --kickstart=/var/lib/cobbler/kickstarts/example.ks --parent=centos7mini2-x86_64
# cobbler profile add --name=centos-data --kickstart=/var/lib/cobbler/kickstarts/jxl_data.ks --parent=centos7mini2-x86_64

# 修改kickstart文件
cobbler profile edit --name=centos7mini-x86_64 --kickstart=/var/lib/cobbler/kickstarts/jxl_data.ks

# 验证kickstart文件内容
cobbler profile getks --name=centos7mini-x86_64

# 配置需要安装的机器 
# 针对MAC为00:0C:29:48:30:63的机器安装
cobbler system add --name=test --profile=centos7mini-x86_64 --interface=eno16777736 --mac=00:0C:29:48:30:63 --ip-address=192.168.211.11 --netmask=255.255.255.0 --static=1 --dns-name=test.mydomain.com --gateway=192.168.211.1 --hostname=test.mydomain.com

cobbler system report


#######
# 让配置生效
cobbler sync

#######注意################
# 检查 dnsmasq dhcp-range是否正确,因为cobbler sync 会修改
grep "range" /etc/dnsmasq.conf
dhcp-range=192.168.211.10,192.168.211.20

# 修改/etc/dnsmasq.conf 后需要重启dnsmasq
systemctl restart dnsmasq.service



##############################
# 安装Cobbler Web 界面

yum -y install cobbler-web
# 修改授权
# /etc/cobbler/modules.conf 
[authentication]
module = authn_pam

[authorization]
module = authz_ownership

# 添加Cobbler_web 账号
# useradd web && passwd web

# 将 账号 添加到Cobbler_web admins组
# cat /etc/cobbler/users.conf 
[admins]
admin = ""
cobbler = ""
web = ""

# 重启服务
service cobblerd restart
service httpd restart

# 登录WEB(注意使用https)
https://192.168.211.131/cobbler_web/


# Cobbler 子命令介绍
cobbler check         #检查cobbler配置
cobbler sync          #步配置到dhcp pxe和数据目录
cobbler list          #列出所有的cobbler元素
cobbler import        #导入安装的系统光盘镜像
cobbler report        #列出各元素的详细信息
cobbler distro        #查看导入的发行版系统信息
cobbler profile       #查看配置信息
cobbler system        #查看添加的系统信息
cobbler reposync      #同步yum仓库到本地

cobbler repo add --name=CentOS-7-x86_64 --mirror=http://mirrors.aliyun.com/centos/7/os/x86_64/
cobbler reposync


# 参考文档
# Cobbler官网
http://cobbler.github.io/manuals/quickstart/
http://cobbler.github.io/manuals/2.6.0/
# dnsmasq设置
http://debugo.com/dnsmasq/
# 使用 Cobbler 自动化和管理系统安装
http://www.ibm.com/developerworks/cn/linux/l-cobbler/
# Cobbler自动化工具同时批量部署CentOS7及CentOS6.5
http://www.tuicool.com/articles/YZN3qi
#kickstart配置文件详解
http://blog.chinaunix.net/uid-17240700-id-2813881.html

 

wget 下载 java或jdk

Oracle官网上下载jdk,需要点击accept licence的才能下载,使用下面的命令,直接可以下载。

wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-linux-x64.rpm

下载完毕后最好验证一下md5

# md5sum jdk-7u79-linux-x64.rpm jdk-7u79-linux-x64.rpm 
8486da4cdc4123f5c4f080d279f07712  jdk-7u79-linux-x64.rpm

下载页面:
http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html

https://www.oracle.com/webfolder/s/digest/7u79checksum.html

 

参考:http://www.oschina.net/code/snippet_875267_44726

CentOS下安装Jira

  安装环境:

# cat /etc/redhat-release 
CentOS release 6.6 (Final)

# uname -a
Linux Jira-it 2.6.32-504.el6.x86_64 #1 SMP Wed Oct 15 04:27:16 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

# java -version
java version "1.6.0_36"
OpenJDK Runtime Environment (IcedTea6 1.13.8) (rhel-1.13.8.1.el6_7-x86_64)
OpenJDK 64-Bit Server VM (build 23.25-b01, mixed mode)
 
# javac -version
javac 1.6.0_36

# mysql -V
mysql  Ver 14.14 Distrib 5.1.73, for redhat-linux-gnu (x86_64) using readline 5.1

Jira检查安装环境:

# /usr/share/jira/atlassian-jira-6.3.6-standalone/bin/version.sh 
                .....
          .... .NMMMD.  ...
        .8MMM.  $MMN,..~MMMO.
        .?MMM.         .MMM?.

     OMMMMZ.           .,NMMMN~
     .IMMMMMM. .NMMMN. .MMMMMN,
       ,MMMMMM$..3MD..ZMMMMMM.
        =NMMMMMM,. .,MMMMMMD.
         .MMMMMMMM8MMMMMMM,
           .ONMMMMMMMMMMZ.
             ,NMMMMMMM8.
            .:,.$MMMMMMM
          .IMMMM..NMMMMMD.
         .8MMMMM:  :NMMMMN.
         .MMMMMM.   .MMMMM~.
         .MMMMMN    .MMMMM?.

      Atlassian JIRA
      Version : 6.3.6
                  
Detecting JVM PermGen support...
PermGen switch is supported. Setting to 384m

If you encounter issues starting or stopping JIRA, please see the Troubleshooting guide at http://confluence.atlassian.com/display/JIRA/Installation+Troubleshooting+Guide


Server startup logs are located in /usr/share/jira/atlassian-jira-6.3.6-standalone/logs/catalina.out
Using CATALINA_BASE:   /usr/share/jira/atlassian-jira-6.3.6-standalone
Using CATALINA_HOME:   /usr/share/jira/atlassian-jira-6.3.6-standalone
Using CATALINA_TMPDIR: /usr/share/jira/atlassian-jira-6.3.6-standalone/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /usr/share/jira/atlassian-jira-6.3.6-standalone/bin/bootstrap.jar:/usr/share/jira/atlassian-jira-6.3.6-standalone/bin/tomcat-juli.jar
Using CATALINA_PID:    /usr/share/jira/atlassian-jira-6.3.6-standalone/work/catalina.pid
Server version: Apache Tomcat/7.0.55
Server built:   Jul 18 2014 05:34:04
Server number:  7.0.55.0
OS Name:        Linux
OS Version:     2.6.32-504.el6.x86_64
Architecture:   amd64
JVM Version:    1.6.0_36-b36
JVM Vendor:     Sun Microsystems Inc.

安装过程: 继续阅读

PXE网络安装CentOS7.1

PXE网络安装CentOS 7.1,安装环境:
先安装一台桌面版CentOS(使用CentOS-7-x86_64-DVD-1503-01.iso安装),作为启动服务器,ip为192.168.72.32。

#安装http、tftp、dhcp服务
yum install httpd tftp-server dhcp

#安装syslinux,安装后才有文件 /usr/share/syslinux/pxelinux.0
yum install syslinux 

#安装system-config-kickstart配置启动文件,
yum install system-config-kickstart
#DHCP配置
cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf

DHCP配置文件修改

# cat /etc/dhcp/dhcpd.conf 
# dhcpd.conf
#
# Sample configuration file for ISC dhcpd
#

# option definitions common to all supported networks...
#domain-name 修改为对应名称
option domain-name "localhost";
option domain-name-servers 223.5.5.5, 223.6.6.6;

default-lease-time 600;
max-lease-time 7200;

# Use this to enble / disable dynamic dns updates globally.
#ddns-update-style none;

# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
#authoritative;

# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;

# No service will be given on this subnet, but declaring it helps the 
# DHCP server to understand the network topology.


subnet 192.168.72.0 netmask 255.255.255.0 {
        range 192.168.72.243 192.168.72.250;
        option routers 192.168.72.1;
        next-server 192.168.72.32; #TFTP服务器IP
        filename "pxelinux.0";

}

#tftp配置,disable = no

# cat /etc/xinetd.d/tftp 
# default: off
# description: The tftp server serves files using the trivial file transfer \
#       protocol.  The tftp protocol is often used to boot diskless \
#       workstations, download configuration files to network-aware printers, \
#       and to start the installation process for some operating systems.
service tftp
{
        socket_type             = dgram
        protocol                = udp
        wait                    = yes
        user                    = root
        server                  = /usr/sbin/in.tftpd
        server_args             = -s /var/lib/tftpboot
        disable                 = no  #修改
        per_source              = 11
        cps                     = 100 2
        flags                   = IPv4
}

httpd配置

cd /etc/httpd/conf.d/
#移除并备份conf文件,目的不显示测试页面
mv autoindex.conf autoindex.conf.bak
mv userdir.conf userdir.conf.bak
mv welcome.conf welcome.conf.bak

#http目录文件准备
mkdir /var/www/html/centos
mount ~/CentOS-7-x86_64-DVD-1503-01.iso /var/www/html/centos

/var/www/html/ks.cfg 文件配置

# cat /var/www/html/ks.cfg 
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard 'us'# Reboot after installation
reboot
# Root password
rootpw --iscrypted $1$BhbE2ZLC$D/XPM6Jscst055R3X0nLp.
# System timezone
timezone Asia/Shanghai --isUtc
# Use network installation
url --url="http://192.168.72.32/centos"  #最后面不需要加 /
# System language
lang en_US
# Firewall configuration
firewall --disabled
# Network information
network  --bootproto=dhcp --device=ens0 --onboot=yes --noipv6 --hostname=pxe_one
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use graphical install
graphical
firstboot --disable
# SELinux configuration
selinux --disabled

# System bootloader configuration
# 新硬盘需要创建mbr
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel 
# Disk partitioning information
part / --asprimary --fstype="xfs" --size=20480
part /boot --asprimary --fstype="xfs" --size=512
part swap --asprimary --fstype="swap" --size=2048
part /data --asprimary --fstype="xfs" --grow --size=1

%packages
@core
#@chinese-support
#iptraf
#vim
#openssh-server
#ntp
#wget

%end

http根目录结构

# tree -aL 2 /var/www/html/ 
/var/www/html/
├── centos
│   ├── CentOS_BuildTag
│   ├── .discinfo
│   ├── EFI
│   ├── EULA
│   ├── GPL
│   ├── images
│   ├── isolinux
│   ├── LiveOS
│   ├── Packages
│   ├── repodata
│   ├── RPM-GPG-KEY-CentOS-7
│   ├── RPM-GPG-KEY-CentOS-Testing-7
│   ├── TRANS.TBL
│   └── .treeinfo
└── ks.cfg

7 directories, 9 files

tftp目录文件准备

#tftp目录文件准备
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
mkdir /var/lib/tftpboot/pxelinux.cfg
cp /var/www/html/centos/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
cp /var/www/html/centos/images/pxeboot/{vmlinuz,initrd.img} /var/lib/tftpboot/
cp /var/www/html/centos/isolinux/{vesamenu.c32,boot.msg,splash.png} /var/lib/tftpboot/

# tree /var/lib/tftpboot/
/var/lib/tftpboot/
├── boot.msg
├── initrd.img
├── pxelinux.0
├── pxelinux.cfg
│   └── default
├── splash.png
├── vesamenu.c32
└── vmlinuz

1 directory, 7 files

/var/lib/tftpboot/pxelinux.cfg/default 文件

# cat /var/lib/tftpboot/pxelinux.cfg/default
default vesamenu.c32
timeout 60

display boot.msg

# Clear the screen when exiting the menu, instead of leaving the menu displayed.
# For vesamenu, this means the graphical background is still displayed without
# the menu itself for as long as the screen remains in graphics mode.
menu clear
menu background splash.png
menu title CentOS 7
menu vshift 8
menu rows 18
menu margin 8
#menu hidden
menu helpmsgrow 15
menu tabmsgrow 13

# Border Area
menu color border * #00000000 #00000000 none

# Selected item
menu color sel 0 #ffffffff #00000000 none

# Title bar
menu color title 0 #ff7ba3d0 #00000000 none

# Press [Tab] message
menu color tabmsg 0 #ff3a6496 #00000000 none

# Unselected menu item
menu color unsel 0 #84b8ffff #00000000 none

# Selected hotkey
menu color hotsel 0 #84b8ffff #00000000 none

# Unselected hotkey
menu color hotkey 0 #ffffffff #00000000 none

# Help text
menu color help 0 #ffffffff #00000000 none

# A scrollbar of some type? Not sure.
menu color scrollbar 0 #ffffffff #ff355594 none

# Timeout msg
menu color timeout 0 #ffffffff #00000000 none
menu color timeout_msg 0 #ffffffff #00000000 none

# Command prompt text
menu color cmdmark 0 #84b8ffff #00000000 none
menu color cmdline 0 #ffffffff #00000000 none

# Do not display the actual menu unless the user presses a key. All that is displayed is a timeout message.

menu tabmsg Press Tab for full configuration options on menu items.

menu separator # insert an empty line
menu separator # insert an empty line

label linux
  menu label ^Install CentOS 7
  menu default
  kernel vmlinuz
# append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 quiet 
  append initrd=initrd.img inst.ks=http://192.168.72.32/ks.cfg quiet

label check
  menu label Test this ^media & install CentOS 7
  kernel vmlinuz
  append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 rd.live.check quiet

menu separator # insert an empty line

# utilities submenu
menu begin ^Troubleshooting
  menu title Troubleshooting

label vesa
  menu indent count 5
  menu label Install CentOS 7 in ^basic graphics mode
  text help
        Try this option out if you're having trouble installing
        CentOS 7.
  endtext
  kernel vmlinuz
  append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 xdriver=vesa nomodeset quiet

label rescue
  menu indent count 5
  menu label ^Rescue a CentOS system
  text help
        If the system will not boot, this lets you access files
        and edit config files to try to get it booting again.
  endtext
  kernel vmlinuz
  append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 rescue quiet

label memtest
  menu label Run a ^memory test
  text help
        If your system is having issues, a problem with your
        system's memory may be the cause. Use this utility to
        see if the memory is working correctly.
  endtext
  kernel memtest

menu separator # insert an empty line

label local
  menu label Boot from ^local drive
  localboot 0xffff

menu separator # insert an empty line
menu separator # insert an empty line

label returntomain
  menu label Return to ^main menu
  menu exit

menu end

启动服务器

#启动服务器
iptables -F
systemctl start httpd.service
systemctl status httpd.service
systemctl enable httpd.service

systemctl start dhcpd.service
systemctl status dhcpd.service
systemctl enable dhcpd.service

systemctl start xinetd.service
systemctl status xinetd.service
systemctl enable xinetd.service

systemctl start tftp.socket
systemctl status tftp.socket
systemctl enable tftp.socket

systemctl start tftp.service
systemctl status tftp.service
systemctl enable tftp.service

查看服务端口是否正常

#查看服务端口是否正常 tcp-80、udp-67、udp-69
ss -tilnp
ss -uilnp
#或
netstat -nat
netstat -nau

#查看dhcp地址分配情况
/var/lib/dhcpd/dhcpd.leases

继续阅读

SquidTL安装–待续

安装系统:CentOS 7.1

wget http://www.zerozone.it/Software/Linux/SquidTL/squidtl-0.0.2.tar.gz

tar -vxzf squidtl-0.0.2.tar.gz 

cd squidtl/

yum install automake
cp -rf /usr/share/automake-1.13 /usr/share/automake-1.10

# ./configure 
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... 
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for mysql_config... no
configure: error: Couldn't find mysql_config. Please verify that it is installed.

configure: error: Couldn’t find mysql_config. Please verify that it is installed.

# yum provides */mysql_config
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: epel.mirror.srv.co.ge
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
epel/x86_64/filelists_db                                                                                                                              | 6.3 MB  00:00:06     
1:mariadb-devel-5.5.41-2.el7_0.i686 : Files for development of MariaDB/MySQL applications
Repo        : base
Matched from:
Filename    : /usr/lib/mysql/mysql_config
Filename    : /usr/bin/mysql_config



1:mariadb-devel-5.5.41-2.el7_0.x86_64 : Files for development of MariaDB/MySQL applications
Repo        : base
Matched from:
Filename    : /usr/bin/mysql_config
Filename    : /usr/lib64/mysql/mysql_config
yum install mariadb-devel

 

./configure 
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... 
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for mysql_config... /usr/bin/mysql_config
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for XML... no
configure: error: libxml2 is required.

configure: error: libxml2 is required.

yum install libxml2-devel
# ./configure        
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... 
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for mysql_config... /usr/bin/mysql_config
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for XML... yes
checking for strdup... yes
checking for strerror... yes
checking for vsprintf... yes
checking for sigaction... yes
checking for signal... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Makefile
config.status: creating src/config.h
config.status: executing depfiles commands

 

CentOS7网卡桥接

系统版本:CentOS 7.1 x64

# cat /etc/redhat-release 
CentOS Linux release 7.1.1503 (Core) 
# uname -a
Linux localhost.localdomain 3.10.0-229.el7.x86_64 #1 SMP Fri Mar 6 11:36:42 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

 桥接前配置:

# cat /etc/sysconfig/network-scripts/ifcfg-enp2s4 
BOOTPROTO=dhcp
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
IPV6_FAILURE_FATAL=no
TYPE=Ethernet
NAME=enp2s4
UUID=65b1d8b3-2214-45ec-987f-d0f1cc0004cb
DEVICE=enp2s4
ONBOOT=yes

# cat /etc/sysconfig/network-scripts/ifcfg-enp3s5 
BOOTPROTO=dhcp
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
IPV6_FAILURE_FATAL=no
TYPE=Ethernet
NAME=enp3s5
UUID=65b1d8b3-2214-45ec-987f-d0f1cc0004cb
DEVICE=enp3s5
ONBOOT=yes

通过配置文件配置桥接:

# cd /etc/sysconfig/network-scripts

# cat ifcfg-br0      #桥接口名称为br0
TYPE=Bridge
BOOTPROTO=static
IPADDR=192.168.1.82
PREFIX=24
IPV4_FAILURE_FATAL=no
NAME=br0
DEVICE=br0
ONBOOT=yes
BRIDGE_STP=yes

# cat ifcfg-enp2s4 
TYPE=Ethernet
NAME=enp2s4
UUID=30a9efb8-2594-4596-9cde-d87c1ac06003
#HWADDR=00:1c:c4:df:db:e4
DEVICE=enp2s4
ONBOOT=yes
BRIDGE=br0

# cat ifcfg-enp3s5 
TYPE=Ethernet
NAME=enp3s5
#HWADDR=00:1c:c4:df:db:e6
UUID=65b1d8b3-2214-45ec-987f-d0f1cc0004cb
DEVICE=enp3s5
ONBOOT=yes
BRIDGE=br0

# systemctl status network.service  #重启网络服务

#查看是否失效
# ifconfig 
br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.82  netmask 255.255.255.0  broadcast 192.168.71.255
        inet6 fe80::21c:c4ff:fedf:dbe4  prefixlen 64  scopeid 0x20<link>
        ether 00:1c:c4:df:db:e4  txqueuelen 0  (Ethernet)
        RX packets 1438  bytes 182390 (178.1 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 8  bytes 592 (592.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp2s4: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether 00:1c:c4:df:db:e4  txqueuelen 1000  (Ethernet)
        RX packets 669318  bytes 968188165 (923.3 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 87613  bytes 7615798 (7.2 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp3s5: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether 00:1c:c4:df:db:e6  txqueuelen 1000  (Ethernet)
        RX packets 87597  bytes 7613914 (7.2 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 666707  bytes 967793844 (922.9 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

# brctl show
bridge name     bridge id               STP enabled     interfaces
br0             8000.001cc4dfdbe4       no              enp2s4
                                                        enp3s5

 通过brctl配置桥接:

#安装brctl
yum install bridge-utils

# ifconfig enp2s4 down
# ifconfig enp3s5 down
# ifconfig enp2s4 0.0.0.0
# ifconfig enp3s5 0.0.0.0

# brctl addbr br0
# brctl addif br0 enp2s4
# brctl addif br0 enp3s5

# ifconfig br0 192.168.1.82 up

# brctl stp br0 off  #关闭生成树协议
# brctl show

#brctl 命令配置重启后失效,可以把相关命令添加到/etc/rc.d/rc.local 即可。

 

参考:
http://www.zhukun.net/archives/6857

CentOS mini版安装后基本设置

使用CentOS mini版,安装后一般做一些基本设置才能更好的使用。

版本:
http://mirrors.aliyun.com/centos/7.1.1503/isos/x86_64/CentOS-7-x86_64-Minimal-1503-01.iso

# cat /etc/redhat-release 
CentOS Linux release 7.1.1503 (Core) 

# uname -a
Linux localhost.localdomain 3.10.0-229.el7.x86_64 #1 SMP Fri Mar 6 11:36:42 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux


/etc/sysconfig/network-scripts/ifcfg-enp5s0  #开机启动网卡
ONBOOT=yes

systemctl restart network.service      #重启网络服务
#或
/etc/rc.d/init.d/network restart




yum -y install wget    #安装wget

#更换阿里云yum源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

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

#第三方源
yum install http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
#或
yum install http://mirrors.ustc.edu.cn/epel/7/x86_64/e/epel-release-7-5.noarch.rpm

#生成缓存
yum makecache

#安装常用软件、工具
yum -y install vim htop

#add command ifconfig
yum -y net-tools 

#add command nslookup、dig
yum -y install bind-utils

#设置vim 别名
vi .bashrc  
alias vi='vim'

 

 

CentOS增加新硬盘

环境:
在正常运行CentOS 7.1的机器上添加一块80G的新硬盘.

系统:

# cat /etc/redhat-release 
CentOS Linux release 7.1.1503 (Core) 

# uname -a
Linux localhost.localdomain 3.10.0-229.el7.x86_64 #1 SMP Fri Mar 6 11:36:42 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

步骤:
1、关机、加硬盘、开机
2、查看硬盘是否识别到

# fdisk -l

Disk /dev/sda: 500.1 GB, 500107862016 bytes, 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xf0b1ebb0

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        4096   209723391   104859648    7  HPFS/NTFS/exFAT
/dev/sda2       209723392   210747391      512000   83  Linux
/dev/sda3       210747392   976773119   383012864   8e  Linux LVM

Disk /dev/sdb: 80.0 GB, 80026361856 bytes, 156301488 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x947748e0

3、fdisk /dev/sdb 硬盘分区

 

# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): m  #帮助
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   g   create a new empty GPT partition table
   G   create an IRIX (SGI) partition table
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Command (m for help): p  #查看分区

Disk /dev/sdb: 80.0 GB, 80026361856 bytes, 156301488 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x947748e0

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n   #新建分区
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p    #主分区
Partition number (1-4, default 1): 1    #分区个数
First sector (2048-156301487, default 2048):     #使用所有,直接回车
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-156301487, default 156301487): #直接回车
Using default value 156301487
Partition 1 of type Linux and of size 74.5 GiB is set

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

4、查看分区是否成功

# ll /dev/sdb*
brw-rw----. 1 root disk 8, 16 Apr 15 22:11 /dev/sdb
brw-rw----. 1 root disk 8, 17 Apr 15 22:11 /dev/sdb1

5、格式化分区

# mkfs    #系统支持的文件系统格式
mkfs         mkfs.btrfs   mkfs.cramfs  mkfs.ext2    mkfs.ext3    mkfs.ext4    mkfs.minix   mkfs.xfs 

# mkfs.xfs /dev/sdb1   #CentOS7.1 默认的文件系统为xfs,保存同系统一致

6、挂载新硬盘,并添加到 /etc/fstab自动挂载

mkdir /newdisk
mount /dev/sdb1 /newdisk

# vi /etc/fstab 

# /etc/fstab
# Created by anaconda on Wed Apr 15 18:50:24 2015
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/sdb1               /newdisk            xfs     defaults        0 0

7、重启验证一下

# df -hT
Filesystem              Type      Size  Used Avail Use% Mounted on
/dev/mapper/centos-root xfs        50G  1.1G   49G   3% /
devtmpfs                devtmpfs  927M     0  927M   0% /dev
tmpfs                   tmpfs     937M     0  937M   0% /dev/shm
tmpfs                   tmpfs     937M  8.5M  928M   1% /run
tmpfs                   tmpfs     937M     0  937M   0% /sys/fs/cgroup
/dev/sdb1               xfs        75G   33M   75G   1% /newdisk
/dev/mapper/centos-home xfs       312G   33M  312G   1% /home
/dev/sda2               xfs       497M  121M  377M  25% /boot

参考文档:
http://www.linuxidc.com/Linux/2011-02/31868.htm