1.服务器环境
node1:192.168.3.1
node2:192.168.3.2

2.主机名和hosts文件
node1: node1.xkops.com --主机名
[root@node1 ~]# tail -n 2 /etc/hosts
192.168.3.1 node1 node1.xkops.com
192.168.3.2 node2 node2.xkops.com

node2: node2.xkops.com --主机名
[root@node2 ~]# tail -n 2 /etc/hosts
192.168.3.1 node1 node1.xkops.com
192.168.3.2 node2 node2.xkops.com

3.关闭防火墙和selinux
node1:
service iptables stop
chkconfig iptables off
sed -i '/^SELINUX/s;enforcing;disabled;g' /etc/selinux/config
setenforce 0

node2:
service iptables stop
chkconfig iptables off
sed -i '/^SELINUX/s;enforcing;disabled;g' /etc/selinux/config
setenforce 0

4.配置本地yum源
node1:
mount /dev/sr0 /mnt
cd /etc/yum.repos.d/
mkdir backup && mv CentOS-* backup
[root@node1 yum.repos.d]# cat > CentOS-mnt.repo <<EOF
[CentOS6.5]
name=CT 6.5
baseurl=file:///mnt
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
EOF
[root@node1 yum.repos.d]# yum repolist
Loaded plugins: fastestmirror, refresh-packagekit, security
Determining fastest mirrors
repo id repo name status
CentOS6.5 CT 6.5 6,367
repolist: 6,367

node2:
mount /dev/sr0 /mnt
cd /etc/yum.repos.d/
mkdir backup && mv CentOS-* backup
[root@node2 yum.repos.d]# cat > CentOS-mnt.repo <<EOF
[CentOS6.5]
name=CT 6.5
baseurl=file:///mnt
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
EOF
[root@node2 yum.repos.d]# yum repolist
Loaded plugins: fastestmirror, refresh-packagekit, security
Determining fastest mirrors
repo id repo name status
CentOS6.5 CT 6.5 6,367
repolist: 6,367

附录:

本篇文章初始化脚本,前提是已经配置好IP地址。

#!/bin/bash
#author: xkops
#set -x
stty erase ^H #define hostname and hosts file.
read -p "Please Input Your HostName: " HOSTNAME
read -p "Please Input Your FQDN: " FQDN
IP=$(ifconfig eth0|grep 'inet addr:'|awk -F":" '{print $2}'|awk '{print $1}')
if ! grep -q $HOSTNAME /etc/hosts;then
#echo "$HOSTNAME is exsits in files /etc/hosts."
echo "$IP $HOSTNAME $FQDN" >> /etc/hosts
fi
sed -i "s#HOSTNAME=.*#HOSTNAME=$HOSTNAME#" /etc/sysconfig/network
hostname $HOSTNAME
echo -e "Host:\033[32mFinished.\033[0m" #shutdown selinux and iptables services.
sed -i "s#SELINUX=.*#SELINUX=disabled#" /etc/selinux/config
#setenforce
/etc/init.d/iptables status &> /dev/null
if [ "$?" -eq ];then
/etc/init.d/iptables stop
fi
chkconfig iptables off
echo -e "Selinux|iptables:\033[32mFinished.\033[0m" #shutdown NetworkManager.
/etc/init.d/NetworkManager status &> /dev/null
if [ "$?" -eq ];then
/etc/init.d/NetworkManager stop
fi
chkconfig NetworkManager off
echo -e "NetworkManager:\033[32mFinished.\033[0m" #define mount ISO images.
df -Ph |grep /dev/sr0 &> /dev/null
if [ "$?" -ne ];then
mount /dev/sr0 /mnt &> /dev/null
if [ "$?" -ne ];then
echo -e "ISO:\033[31mISO images device is a problem. Please check ISO connect to VM host.\033[0m"
exit
fi
fi #backup repo files and touch a new repo file of CentOS.
if [ ! -d /etc/yum.repos.d/BACK ];then
mkdir /etc/yum.repos.d/BACK
fi
if [ ! -f /etc/yum.repos.d/CentOS-mnt.repo ];then
mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/BACK/
fi
cat > /etc/yum.repos.d/CentOS-mnt.repo <<EOF
[CentOS6.5]
name=CT 6.5
baseurl=file:///mnt
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
EOF
echo -e "Repo:\033[32mFinished.\033[0m" #check test repo config.
yum repolist|tail -n 1

*注释:如果光盘为挂载会出现报错提示。

saltstack之(一)系统环境及本地yum源的更多相关文章

  1. Linux线上与本地的httpd搭建【制作本地yum源】

    当前时间 2019-10-24-10:53:12 制作本地yum源 我用的VMware Workstation 系统环境: CentOS 7.5 首先我们先要挂载系统镜像 [root@laopa ~] ...

  2. centos本地yum源安装

    1.为DVD或U盘创建一个用于挂载的目录 [root@localhost ~]# mkdir /media/CentOS/ 2.查看DVD或U盘所在的路径 [root@localhost ~]# fd ...

  3. redhat 配置本地yum源163yum源epel 源,无需卸载yum!无须拷贝ISO,愿网上少一点垃圾教程误人子弟

    都知道redhat不收费,但是其yum服务是要收费的,不想出钱那就自己配置yum源就好了. 首先,博主之前也没用过redhat,第一次用yum装包的时候提示什么没注册之类的,balaba一大堆,然后就 ...

  4. RedHat Linux RHEL6配置本地YUM源

    YUM是Yellow dog Updater Modified的简称,起初是由yellow dog这一发行版的开发者Terra Soft研发,用python写成,那时还叫做yup(yellow dog ...

  5. RHEL7.2和RHEL6.5的配置网络yum源和本地yum源

    RHEL7.2配置本地yum源 [root@localhost ~]#monut /dev/sr0 /mnt      #挂载光盘 [root@localhost ~]# rm -rf /etc/yu ...

  6. Centos6.4 本地yum源配置

    由于单位的服务器均使用的是内网,而安装一些软件如Git,需要很多的依赖包,使用yum安装相对简单,由于不能联网故配置本地yum源配置. 1.首先将需要rpm库添加到系统中: 1).虚拟机中安装的lin ...

  7. RHEL本地yum源

    一.挂载本地镜像做yum源(环境:RHEL6.5 64位 VM11) 1.进入/etc/yum.repos.d目录, [root@localhost yum.repos.d]# ls packagek ...

  8. CentOS配置本地yum源(使用镜像iso文件)

    本人在使用yum安装软件的时候,感觉最不爽的是网络不佳时,安装的速度特别慢.所以,个人就上网search了一下如何使用Linux的安装文件作为其yum源.经过几次尝试,已经可以成功的配置了.下面是详细 ...

  9. 为CentOS 6 配置本地YUM源

    在网上找了很多为CentOS 6配置本地YUM源的方法,其中有很多是与网络相关的,我只想配个自己用的,结果就发现这个方法比较简单实用,就转过来了. 环境:CentOS 6.0 默认的yum是以网络来安 ...

随机推荐

  1. Spring声明式事务配置管理方法

    环境配置 项目使用SSH架构,现在要添加Spring事务管理功能,针对当前环境,只需要添加Spring 2.0 AOP类库即可.添加方法: 点击项目右键->Build Path->Add ...

  2. 【iBoard电子学堂】【iCore双核心板】资料光盘A盘更新,版本号为A6

    _____________________________________ 深入交流QQ群: A: 204255896(1000人超级群,可加入) B: 165201798(500人超级群,满员) C ...

  3. ExtJS笔记2 Class System

    For the first time in its history, Ext JS went through a huge refactoring from the ground up with th ...

  4. TVP5150摄像头

    工作中看同事摄像头配置的时候有2种格式PAL.NTSC.如果摄像头的格式配置不对的话会出现重影.黑白没颜色.闪屏等等. TVP5150  PAL.NTSC配置.http://bbs.csdn.net/ ...

  5. java编程算法

    一.字符串相关操作 String s = " Hello java,hello android,hello OOP,HELLO String,hello JAVASE!"; Sys ...

  6. Java反射机制深入研究

    ava 反射是Java语言的一个很重要的特征,它使得Java具体了“动态性”.   在Java运行时环境中,对于任意一个类,能否知道这个类有哪些属性和方法?对于任意一个对象,能否调用它的任意一个方法? ...

  7. 面向对象之struct

    struct PointStruct { int pointx = 1; int pointy = 2; public PointStruct(int x, int y) { this.pointx ...

  8. 蓝牙版本V4.2特征讲解说明

    2014年12月4日,最新的蓝牙4.2标准颁布,改善了数据传输速度和隐私保护程度,并接入了该设备将可直接通过IPv6和6LoWPAN接入互联网.在新的标准下蓝牙信号想要连接或者追踪用户设备必须经过用户 ...

  9. HBase的几种调优(GC策略,flush,compact,split)

    一:GC的调优 1.jvm的内存 新生代:存活时间较短,一般存储刚生成的一些对象 老年代:存活时间较长,主要存储在应用程序中生命周期较长的对象 永久代:一般存储meta和class的信息 2.GC策略 ...

  10. 【Java 基础篇】【第三课】表达式、控制结构

    这两天再看敏捷开发流程,我这个算是敏捷博客吗? 哈哈o(∩_∩)o package a.b; public class Three { static void Expression() { Syste ...