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