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是以网络来安 ...
随机推荐
- iOS开发Swift篇—简单介绍
iOS开发Swift篇—简单介绍 一.简介 Swift是苹果于2014年WWDC(苹果开发者大会)发布的全新编程语言 Swift在天朝译为“雨燕”,是它的LOGO 是一只燕子,跟Objective-C ...
- jquery判断是否出现滚动条
$(document).ready(function(){ var winH = $(window).height(); //页面可视区域高度 $(window).scroll(function () ...
- HDU 1016 DFS
很简单的深搜 只要看出来是深搜... 注意判断最后一点是否与加一为质数 #include<stdio.h> #include<string.h> #include<alg ...
- Linux 计划任务 Crontab 笔记与总结(5)crontab 常见错误与案例
① 环境变量 cd ~ pwd 就会到你登陆的那个用户的根目录下 ls -a 能够查看到 .bash_profile 这个文件 vim .bash_profile 这里面设置了一些环境变量. 可以设置 ...
- userDefaults
// // RootViewController.m #import "RootViewController.h" @interface RootViewController () ...
- Unity 区分不同平台
问题:公司开发的游戏实在android平台上运行,但是我们是在windows平台下进行开发,OK ,经常有些地方开发完之后就要换到android上面,能区分平台的不同就可以对代码做区分处理 回答:un ...
- shell 中的引用
1. 什么叫引用对 shell 脚本.程序.终端命令.变量.字符串等结果的反馈.2. 引用的类型 " " 双引号 ` 反引号' ' 单引号 ...
- P1351 联合权值
#include <bits/stdc++.h> using namespace std; const int maxn = 200005; vector<int> son[m ...
- json 数组转换为js数组
$(function(){ var json = '[{"id":"1","tagName":"apple"},{&qu ...
- ntpdate[16603]: the NTP socket is in use
ubuntu使用ntpdate更新时间的时候提示错误如下 root@lnmp:/etc/squid3# sudo ntpdate cn.pool.ntp.org 5 Jan 07:22:59 ntpd ...