1. Linux操作系统安装
使用CentOS-7.0-1406-x86_64-DVD.iso来进行安装
通过kickstart文件来简化管理
http://172.16.1.100/7mini.txt(该IP为测试环境中的服务器地址,这也是最小化安装的格式)
# CentOS 7 64bit 用于生产环境的最小安装 14:57 2014/9/27 # System authorization information auth --enableshadow --passalgo=sha512 # Use CDROM installation media cdrom text # Run the Setup Agent on first boot firstboot --enable ignoredisk --only-use=sda # Keyboard layouts keyboard --vckeymap=us --xlayouts=‘us‘ # System language lang en_US.UTF-8 # Network information #network --bootproto=dhcp --device=eno16777728 --onboot=no --ipv6=auto network --onboot yes --device eno16777728 --bootproto dhcp --noipv6 network --hostname=localhost.localdomain # Root password rootpw 123456 firewall --disable selinux --disable # System timezone timezone --utc Asia/Shanghai # System bootloader configuration bootloader --location=mbr --boot-drive=sda autopart --type=lvm # Partition clearing information clearpart --none --initlabel reboot %packages @core @base net-tools %end |
查看当前版本信息
# uname -a Linux localhost.localdomain 3.10.0-123.el7.x86_64 #1 SMP Mon Jun 30 12:09:22 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux # cat /etc/redhat-release CentOS Linux release 7.0.1406 (Core)
背景知识:yum -y upgrade 和 yum -y update 区别
Yum的Man帮助 update If run without any packages, update will update every currently installed package. If one or more packages or package globs are specified, Yum will only update the listed packages. While updating packages, yum will ensure that all dependencies are satisfied. (See Specifying package names for more information) If the packages or globs specified match to packages which are not currently installed then update will not install them. update operates on groups, files, provides and filelists just like the "install" command. If the main obsoletes configure option is true (default) or the --obsoletes flag is present yum will include package obsoletes in its calculations - this makes it better for distro-version changes, for example: upgrading from somelinux 8.0 to somelinux 9. Note that "update" works on installed packages first, and only if there are no matches does it look for available packages. The difference is most noticeable when you do "update foo-1-2" which will act exactly as "update foo" if foo-1-2 is installed. You can use the "update-to" if you‘d prefer that nothing happen in the above case. upgrade Is the same as the update command with the --obsoletes flag set. See update for more details. yum -y update 升级所有包,改变软件设置和系统设置,系统版本内核都升级
yum -y upgrade 升级所有包,不改变软件设置和系统设置,系统版本升级,内核不改变 |
# yum -y upgrade
提示共升级35个包,包括kernel.x86_64 0:3.10.0-123.6.3.el7
重新启动之后,进行验证
# uname -a Linux localhost.localdomain 3.10.0-123.6.3.el7.x86_64 #1 SMP Wed Sep 6 21:12:36 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux # cat /etc/redhat-release CentOS Linux release 7.0.1406 (Core)
CentOS 7中主机名的配置文件与Redhat相比发生了变化,不是在是/etc/sysconfig/network
更改/etc/hostname,才会生效
# vi /etc/hostname zzsrv1.bigcloud.local # reboot
除了传统的修改/etc/resolv.conf之外,还有通过在ifcfg文件中添加配置的方式。
Tip: 与Windows在某个网卡中设置DNS服务器的IP地址类似
# vi /etc/sysconfig/network-scripts/ifcfg-eno16777728
# Generated by parse-kickstart IPV6INIT=no BOOTPROTO=static DEVICE=eno16777728 ONBOOT=yes TYPE=Ethernet DEFROUTE=yes PEERDNS=yes PEERROUTES=yes IPV4_FAILURE_FATAL=no NAME="System eno16777728" IPADDR=192.168.188.11 NETMASK=255.255.255.0 GATEWAY=192.168.188.2 DNS1=192.168.188.11 DNS2=192.168.188.12 |
这样,当重新启动network服务时,会生成/etc/resolv.conf中的配置
# service network restart Restarting network (via systemctl): [ OK ] # cat /etc/resolv.conf
# Generated by NetworkManager search bigcloud.local nameserver 192.168.188.11 nameserver 192.168.188.12 |
# chkconfig --list
Note: This output shows SysV services only and does not include native systemd services. SysV configuration data might be overridden by native systemd configuration. If you want to list systemd services use ‘systemctl list-unit-files‘. To see services enabled on particular target use ‘systemctl list-dependencies [target]‘. iprdump 0:off 1:off 2:on 3:on 4:on 5:on 6:off iprinit 0:off 1:off 2:on 3:on 4:on 5:on 6:off iprupdate 0:off 1:off 2:on 3:on 4:on 5:on 6:off netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off network 0:off 1:off 2:on 3:on 4:on 5:on 6:off vmware-tools 0:off 1:off 2:on 3:on 4:on 5:on 6:off vmware-tools-thinprint 0:off 1:off 2:on 3:on 4:on 5:on 6:off |
systemctl是系统服务管理器的命令,它将service和chkconfig这两个命令组合在一起。
任务 | 旧指令 | 新指令 |
使某服务自动启动 | chkconfig --level 3 httpd on | systemctl enable httpd.service |
使某服务不自动启动 | chkconfig --level 3 httpd off | systemctl disable httpd.service |
检查服务状态 | service httpd status | systemctl status httpd.service (服务详细信息) systemctl is-active httpd.service (仅显示是否 Active) |
显示所有已启动的服务 | chkconfig --list | systemctl list-units --type=service |
启动某服务 | service httpd start | systemctl start httpd.service |
停止某服务 | service httpd stop | systemctl stop httpd.service |
重启某服务 | service httpd restart | systemctl restart httpd.service |
我在做这部分时,在修改主机名时,费了不少的功夫,一直按照Redhat的方式修改总是错误,最后上网查找资料,看了好几篇文章,才最终改对了。服务启动的方式也与原来不同。
本文出自 “刘琼@天道酬勤” 博客,请务必保留此出处http://lqiong.blog.51cto.com/8170814/1559054
原文地址:http://lqiong.blog.51cto.com/8170814/1559054