MySQL学习第一篇:系统准备

1. 系统准备
克隆一台CentOS 6.5

1、依次查看需要修改的内容

 

[root@demo ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
[root@demo ~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=demo.centos.com
GATEWAY=172.16.16.1
NTPSERVERARGS=iburst
[root@demo ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0 
DEVICE=eth0
TYPE=Ethernet
UUID=32c2dda1-55e9-453a-ab82-4ec5dbef8036
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
HWADDR=00:0C:29:21:FE:2C
IPADDR=172.16.16.186
PREFIX=24
GATEWAY=172.16.16.1
DNS1=202.101.172.35
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth0"
[root@demo ~]# cat /etc/selinux/config 
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=enforcing
# SELINUXTYPE= can take one of these two values:
#     targeted - Targeted processes are protected,
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted 

 

2、编写并执行初始化系统脚本initsystem.sh

#!/bin/bash

export hostname=mysql.master
export mac=`ifconfig $NIC | awk '/HWaddr/{ print $5 }' `
export ipaddr=`ifconfig|grep "inet addr:"|grep -v "127.0.0.1"|cut -d: -f2|awk '{print $1}'`
export selinux=disabled

# set up /etc/hosts
echo ${ipaddr} mysql.master mysql.master >> /etc/hosts

# set up /etc/sysconfig/network
sed -i s/^HOSTNAME.*/HOSTNAME=${hostname}$i/ /etc/sysconfig/network

#set up /etc/sysconfig/network-scripts/ifcfg-eth0
grep -q "HWADDR=" /etc/sysconfig/network-scripts/ifcfg-eth0||echo "HWADDR=" >> /etc/sysconfig/network-scripts/ifcfg-eth0
sed -i s/^HWADDR.*/HWADDR=${mac}$i/ /etc/sysconfig/network-scripts/ifcfg-eth0

grep -q "IPADDR=" /etc/sysconfig/network-scripts/ifcfg-eth0||echo "IPADDR=" >> /etc/sysconfig/network-scripts/ifcfg-eth0
sed -i s/^IPADDR.*/IPADDR=${ipaddr}$i/ /etc/sysconfig/network-scripts/ifcfg-eth0

#set up /etc/selinux/config
sed -i s/^SELINUX=.*/SELINUX=${selinux}$i/ /etc/selinux/config

echo "***********************************************
inited system as bellow,please reboot system to take effect...
hostname=${hostname}
mac=${mac}
ip=${ipaddr}
selinux=${selinux}
****************************************************"

 

3、执行初始化脚本,初始化系统

 

[root@demo ~]# bash inisystem.sh
***********************************************
inited system as bellow,please reboot system to take effect...
hostname=mysql.master
mac=00:0C:29:40:78:36
ip=172.16.16.102
selinux=disabled
****************************************************

 

2016-11-08 BUG修复:

使用中发现有一处Bug ,具体语句为:

 

#set up /etc/selinux/config
sed -i s/^SELINUX.*/SELINUX=${selinux}$i/ /etc/selinux/config

修改的内容为:

 

 

[root@demo ~]# cat /etc/selinux/config 
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=enforcing
# SELINUXTYPE= can take one of these two values:
#     targeted - Targeted processes are protected,
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

此语句执行之后变成了:

 

 

[root@demo ~]# cat /etc/selinux/config 
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
#     targeted - Targeted processes are protected,
#     mls - Multi Level Security protection.
SELINUX=disabled

很明显正则写错了,修复成现在的版本即可(其他地方由于没有两个类似的变量,所以无需更改也可以,严格来说,都改比较好)


 

 


 

转载于:https://www.cnblogs.com/szDBA/p/6044255.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值