centos7环境准备
1.环境准备:
系统版本:CentOS-7-x86_64-Minimal-1810.iso
运行环境:虚拟机windows上的VM 15
系统安装:参照老男孩运维要求
2.系统安装完成后:
配置静态IP
网卡文件:cat /etc/sysconfig/network-scripts/ifcfg-eth0
配置静态IP代码如下
TYPE=Ethernet PROXY_METHOD=none BROWSER_ONLY=no BOOTPROTO=none DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_FAILURE_FATAL=no IPV6_ADDR_GEN_MODE=stable-privacy NAME=ens33 UUID=7abea26f-6286-4806-877c-b6710950fba1 DEVICE=ens33 ONBOOT=yes IPADDR=10.1.1.133 PREFIX=24 GATEWAY=10.1.1.2 DNS1=10.1.1.2 DNS2=114.114.114.114 DNS3=8.8.8.8 IPV6_PEERDNS=yes IPV6_PEERROUTES=yes NETMAST=255.255.255.0 NM_CONTROLLED=no
重启网卡:
service network restart
systemctl restart network
修改主机名:
vi /etc/hostname
hostnamectl status
推荐使用:hostnamectl set-hostname test
修改字符集:
[root@localhost ~]# localectl status
System Locale: LANG=en_US.UTF-8
VC Keymap: us
X11 Layout: us
localectl set-locale LANG=zh_CN.UTF8
查看字体:
cat /etc/redhat-release
cat /etc/os-release
3.系统优化:
开机启动项:
查看开机启动服务状态:systemctl list-unit-files
查看所有开机启动项:systemctl list-unit-files | grep enable
关闭所有开机启动项:for oldboy in `systemctl list-unit-files|grep enabled |awk '{print $1}'` ;do systemctl disable $oldboy ;done
开启最小化服务:for oldboy in network-online.target network-pre.target network.target crond.service rsyslog.service sshd.service sysstat.service ;do systemctl enable $oldboy ;done
查看开启的服务:systemctl list-unit-files|grep enabled
autovt@.service enabled
crond.service enabled
getty@.service enabled
rsyslog.service enabled
sendmail.service enabled
sm-client.service enabled
sshd.service enabled
4.时间同步:
设置时区:
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
timedatectl set-timezone "Asia/Shanghai"
设置与网络时间同步:
yum -y install ntp ntpdate
ntpdate cn.pool.ntp.org
将系统写入硬件时间:
hwclock --systohc
查看系统时间:
timedatectl
5.关闭邮件队列提示:
You have new mail in /var/spool/mail/root
echo "unset MAILCHECK" >> /etc/profile
source /etc/profile
6.关闭防火墙:
查看防火墙状态:systemctl status firewalld.service
关闭:systemctl stop firewalld
开启:systemctl start firewalld
开机自动关闭:systemctl disable firewalld
开机自动启动:systemctl enable firewalld
7.常用软件工具安装:
开发者工具:yum -y groupinstall "Development Tools"
其他必需工具:yum -y install pidof pkill rsysnc gawk curl lsof tar sed iproute uuid psmisc wget bind-utils mysql-devel MySQL-python
配置yum源:wget https://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm
rpm -ivh epel-release-latest-7.noarch.rpm
更新yum列表:yum repolist
上传下载:yum -y install lrzsz 上传:rz 下载sz file
查看端口号:yum -y install net-tools -- netstat -ant -- netstat -pt --netstat -ant -c
安装ifconfig命令工具包:yum install -y net-tools
安装wget命令:yum -y install wget
安装vim命令:yum -y install vim
安装命令补全:yum -y install bash-completion
安装nmap:yum -y install nmap
yum -y install yum-utils
安装telnet:yum -y install telnet
安装tree命令:yum -y install tree
安装unzip命令:yum -y install unzip 压缩目录: zip -r xxx.zip ./* 解压:unzip filename.zip 解压到指定目录:unzip -o -d /home/sunny myfile.zip
tar包解压缩: tar -zxvf libiconv-1.13.tar.gz ./libiconv tar -cxvf libiconv-1.13.tar.gz ./*.php
查看工具命令所在的rpm包:rpm -ql net-tools
rpm -qa iproute
8.系统基本命令使用:
查看系统版本:cat /etc/redhat-release
查看CPU:cat /proc/cpuinfo
查看磁盘:free -m df -h
设置服务开机自启动:systemctl enable libvirtd systemctl start libvirtd
进程查询:ps aux | grep kvm
关闭进程:kill 进程号 相当于关机关闭虚拟机
9.修改ip名称:
参考博客:https://blog.51cto.com/oldboy/1722101
修改网卡名称:cd /etc/sysconfig/network-scripts/
mv ifcfg-ens33 ifcfg-eth0
修改后:cat ifcfg-eth0
NAME=eth0
DEVICE=eth0
修改并生成grup配置:cat /etc/sysconfig/grub
修改内容为粗体字:GRUB_CMDLINE_LINUX="crashkernel=128M rhgb net.ifnames=0 biosdevname=0 quiet"
生成grup启动菜当:grub2-mkconfig -o /boot/grub2/grub.cfg
重启后生效:reboot
10.配置系统发送邮件功能:
参考博客:https://www.cnblogs.com/benjamin77/p/8571902.html
11.关闭selinux
/usr/sbin/sestatus -v
sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config
grep SELINUX= /etc/selinux/config
cat /etc/selinux/config
12.配置显示中文 失败
echo $LANG
yum install kde-l10n-Chinese -y
yum reinstall glibc-common -y
vim /etc/locale.conf
#LANG="en_US.UTF-8"
LANG="zh_CN.UTF-8"
source /etc/locale.conf