saltstack之(一)系统环境及本地yum源
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源的更多相关文章
- Linux线上与本地的httpd搭建【制作本地yum源】
当前时间 2019-10-24-10:53:12 制作本地yum源 我用的VMware Workstation 系统环境: CentOS 7.5 首先我们先要挂载系统镜像 [root@laopa ~] ...
- centos本地yum源安装
1.为DVD或U盘创建一个用于挂载的目录 [root@localhost ~]# mkdir /media/CentOS/ 2.查看DVD或U盘所在的路径 [root@localhost ~]# fd ...
- redhat 配置本地yum源163yum源epel 源,无需卸载yum!无须拷贝ISO,愿网上少一点垃圾教程误人子弟
都知道redhat不收费,但是其yum服务是要收费的,不想出钱那就自己配置yum源就好了. 首先,博主之前也没用过redhat,第一次用yum装包的时候提示什么没注册之类的,balaba一大堆,然后就 ...
- RedHat Linux RHEL6配置本地YUM源
YUM是Yellow dog Updater Modified的简称,起初是由yellow dog这一发行版的开发者Terra Soft研发,用python写成,那时还叫做yup(yellow dog ...
- RHEL7.2和RHEL6.5的配置网络yum源和本地yum源
RHEL7.2配置本地yum源 [root@localhost ~]#monut /dev/sr0 /mnt #挂载光盘 [root@localhost ~]# rm -rf /etc/yu ...
- Centos6.4 本地yum源配置
由于单位的服务器均使用的是内网,而安装一些软件如Git,需要很多的依赖包,使用yum安装相对简单,由于不能联网故配置本地yum源配置. 1.首先将需要rpm库添加到系统中: 1).虚拟机中安装的lin ...
- RHEL本地yum源
一.挂载本地镜像做yum源(环境:RHEL6.5 64位 VM11) 1.进入/etc/yum.repos.d目录, [root@localhost yum.repos.d]# ls packagek ...
- CentOS配置本地yum源(使用镜像iso文件)
本人在使用yum安装软件的时候,感觉最不爽的是网络不佳时,安装的速度特别慢.所以,个人就上网search了一下如何使用Linux的安装文件作为其yum源.经过几次尝试,已经可以成功的配置了.下面是详细 ...
- 为CentOS 6 配置本地YUM源
在网上找了很多为CentOS 6配置本地YUM源的方法,其中有很多是与网络相关的,我只想配个自己用的,结果就发现这个方法比较简单实用,就转过来了. 环境:CentOS 6.0 默认的yum是以网络来安 ...
随机推荐
- Odoo Two ways to pop warning infomation
1. raise ValueError(_('title'),_('message')) 2.raise except_orm(_('title'),_('message'))
- The declared package does not match the expected package
The declared package does not match the expected package. 1.选中项目右击选择Build Path-->再选择Configure Bui ...
- MasterPage 变化了的 ClientID ctl00_
在母版页的服务器端控件 其客户端ID 有时候是多变的 会对javascript jquery的内容获取 造成困扰 比如一个控件: <asp:ContentPlaceHolder ID=" ...
- 初探Bootstrap之十二栅格
模型1: <!-- 4/12 --> <div class="container"> <div class="row"> & ...
- NBUT 1525 Cow Xor(01字典树+前缀思想)
[1525] Cow Xor 时间限制: 2000 ms 内存限制: 65535 K 问题描述 农民约翰在喂奶牛的时候被另一个问题卡住了.他的所有N(1 <= N <= 100,000)个 ...
- POJ 3255 Roadblocks(A*求次短路)
Roadblocks Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 12167 Accepted: 4300 Descr ...
- NV Maxwell architecture
按照NVIDIA的路线图来看,GTX 600以及GTX 700系列所采用的Kepler架构已经垂垂老矣,最早在明年第一季度,其继任者Maxwell架构可能就会和我们正式见面了.目前外媒已经放出了关于M ...
- nginx下增加模块
1.使用nginx -V确定nginx的编译参数2.下载nginx源码3.下载nginx的扩展模块(此处为memcache模块)4.进入nginx源码目录5../configure --prefix ...
- PureBasic—数控编辑框与调节块和进度条
三个有关上下限问题的控件,它们也是主要控件的组成部分,分别为:SpinGadget() 数控编辑框TrackBarGadget() 调节块控件ProgressBarGadget() ...
- Lazarus解决无法识别中文路径的方法
procedure TForm1.Button1Click(Sender: TObject); var FileN:string; begin if self.OpenDialog1.Execute ...