博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
saltstack之(一)系统环境及本地yum源
阅读量:6940 次
发布时间:2019-06-27

本文共 3131 字,大约阅读时间需要 10 分钟。

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 -xstty erase ^H#define hostname and hosts file.read -p "Please Input Your HostName: " HOSTNAMEread -p "Please Input Your FQDN: " FQDNIP=$(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/hostsfised -i "s#HOSTNAME=.*#HOSTNAME=$HOSTNAME#" /etc/sysconfig/networkhostname $HOSTNAMEecho -e "Host:\033[32mFinished.\033[0m"#shutdown selinux and iptables services.sed -i "s#SELINUX=.*#SELINUX=disabled#" /etc/selinux/config#setenforce 0/etc/init.d/iptables status &> /dev/nullif [ "$?" -eq 0 ];then     /etc/init.d/iptables stop fichkconfig iptables offecho -e "Selinux|iptables:\033[32mFinished.\033[0m"#shutdown NetworkManager./etc/init.d/NetworkManager status &> /dev/nullif [ "$?" -eq 0 ];then    /etc/init.d/NetworkManager stopfichkconfig NetworkManager offecho -e  "NetworkManager:\033[32mFinished.\033[0m"#define mount ISO images.df -Ph |grep /dev/sr0 &> /dev/nullif [ "$?" -ne 0 ];then    mount /dev/sr0 /mnt &> /dev/null    if [ "$?" -ne 0 ];then        echo -e "ISO:\033[31mISO images device is a problem. Please check ISO connect to VM host.\033[0m"        exit    fifi#backup repo files and touch a new repo file of CentOS.if [ ! -d /etc/yum.repos.d/BACK ];then    mkdir /etc/yum.repos.d/BACKfiif [ ! -f /etc/yum.repos.d/CentOS-mnt.repo ];then    mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/BACK/ficat > /etc/yum.repos.d/CentOS-mnt.repo <

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

转载于:https://www.cnblogs.com/xkops/p/5482256.html

你可能感兴趣的文章
你好啊中国
查看>>
冯柯:同步设计在高性能OLTP数据库中的实践
查看>>
iPhone史上最全的使用教程
查看>>
推广一款不错的应用“锁屏对对碰”
查看>>
Oracle IO问题解析(九)
查看>>
How to Properly Remove Datastore or LUN from ESXi 5.x hosts
查看>>
[读书]读《重构-改善既有代码的设计》
查看>>
我的友情链接
查看>>
一次owa登录exchange邮箱提示下载owaauth.dll的解决办法
查看>>
我的友情链接
查看>>
Log.cat 的使用
查看>>
使用myEclipse把java项目上传到码云
查看>>
Python爬虫框架Scrapy 学习笔记 5 ------- 使用pipelines过滤敏感词
查看>>
GTM+800的时间格式转成yyyy-mm-dd的格式
查看>>
QT下载地址
查看>>
sap system monitor ---- SM51 function
查看>>
网络编程服务器基础模型三(多线程模型)
查看>>
C++ MFC WebBrowser 探索(三)
查看>>
apache 禁止爬虫
查看>>
debian下LAMP+nginx代理+awstats+cacti+nagios(一)
查看>>