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. salt执行报错一例

    执行报错: 查看服务端日志: 认证有问题 重新认证吧!!! minion端: [root@super66 ~]# cd /etc/salt/[root@super66 salt]# lsminion ...

  2. The Stable Marriage Problem

    经典稳定婚姻问题 “稳定婚姻问题(The Stable Marriage Problem)”大致说的就是100个GG和100个MM按照自己的喜欢程度给所有异性打分排序.每个帅哥都凭自己好恶给每个MM打 ...

  3. java网络编程之UDP实例

    package Socket; import java.net.DatagramPacket; import java.net.InetAddress; public class Dgram { pu ...

  4. hdu 3348 coins

    这道题算是一道很经典的题,很好的诠释了贪心和动态规划的不同功能.求最少钱的数量用贪心就够了,但是求最多钱的数量要用到动态规划的思想,每步都尽量保留最大 数量.具体看程序注解: #include&quo ...

  5. 增加Activity Monitor中的作业保存数量

    在Master Server的注册表中加入如下两个键值即可: (1500的单位是小时)  

  6. String对象的方法

    Function Description Example CompareTo() Compares one string to another ("Hello").CompareT ...

  7. NBUT 1635 Explosion(最小顶点覆盖)

    [1635] Explosion 时间限制: 10000 ms 内存限制: 65535 K 问题描述 there is a country which contains n cities connec ...

  8. 转载~vim配置文件

    转载自:小码哥的博客 花了很长时间整理的,感觉用起来很方便,共享一下. 我的vim配置主要有以下优点: 1.按F5可以直接编译并执行C.C++.java代码以及执行shell脚本,按“F8”可进行C. ...

  9. Rails--default_scope

    Example: default_scope where("agents.deleted = ?", false)

  10. LR中日志设置和日志函数

    LR中日志参数的设置与使用 1.Run-Time Setting日志参数的设置 在loadrunner的vuser菜单下的Run-Time Setting的General的LOG选项中可以对在执行脚本 ...