天天看点

Centos7最小化安装之后,需要做那些事情?

背景:最近,开发部需要用到linux开发环境,指定要最新版本的Centos, 好吧。我从官网下载了Centos7.2的镜像,采用最小化安装模式,安装之后我们要做那些事情呢? 下面详述。

版本:Centos 7.2.1511

注:本文红色部分是需要修改的内容,特殊标注出来。

一 . 配置IP地址,接通网络。网络一通,万事OK

TYPE=Ethernet

BOOTPROTO=static

DEFROUTE=yes

PEERDNS=yes

PEERROUTES=yes

IPV4_FAILURE_FATAL=no

IPV6INIT=yes

IPV6_AUTOCONF=yes

IPV6_DEFROUTE=yes

IPV6_PEERDNS=yes

IPV6_PEERROUTES=yes

IPV6_FAILURE_FATAL=no

NAME=ens32

UUID=f35197ae-0aef-4525-9c7b-804de7b41bcd

ONBOOT=yes

IPADDR=10.1.8.152

NETMASK=255.255.255.0

GATEWAY=10.1.8.1

DNS1=10.1.3.10

DNS2=10.1.3.11

DNS3=8.8.8.8

二. 修改网卡名称。

Centos7之后,网卡的命名令我们不爽,所以我们有必要改回我们习惯的名称。

2.1  修改网卡配置文件名称. 

mv ifcfg-ens32 ifcfg-eth0

修改网卡配置文件内容

NAME=eth0

2.2  编辑/etc/sysconfig/grub文件内容

增加“net.ifnames=0 biosdevname=0”,编辑后的文件内容:

GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root net.ifnames=0 biosdevname=0 rd.lvm.lv=centos/swap rhgb quiet"

2.3  重新生成GRUB配置并更新内核参数。

grub2-mkconfig -o /boot/grub2/grub.cfg

三. 关闭防火墙。

  systemctl stop firewalld.service

  systemctl disable firewalld.service

四. 关闭selinux.

查看状态

getenforce   

临时关闭 

setenforce 0  

彻底关闭: vim /etc/selinux/config 

SELINUX=disabled

五. 挂载数据磁盘。

使用fdisk工具分区,根据提示

fdisk /dev/sdb 

格式化

mkfs.ext4 /dev/sdb1

挂载

mkdir -p /opt/gildata

mount /dev/sdb1 /opt/gildata

写入fstab文件中,系统启动之后,会自动挂载上去。

/dev/sdb1  /opt/gildata                    ext4    defaults        0 0

六. 安装需要的软件。 

yum install vim redhat-lsb net-tools.x86_64  iptables-services ntpdate wget -y 

七. 通过crontab 设置时间同步。

/usr/sbin/ntpdate ntp.sjtu.edu.cn>> /var/log/ntp.log 2>&1; /sbin/hwclock -w

八. 优化系统参数

 8.1 vim /etc/security/limits.conf 编辑

*        soft    nofile           65536

*        hard    nofile           65536

8.2 vim /etc/security/limits.d/20-nproc.conf

*          soft    nproc     10240

root     soft    nproc     unlimited

延伸。。。。。。。。。。。。。。。。。。。

关于Centos7服务启动的改变

CentOS 7系统服务启动、重启、设置服务启动项命令以合并为,systemctl . 现在用service 或/etc/init.d/命令,重启,重新启动,停止等没效果,因为命令合并为systemctl. 新命令具体内容如下:

以启动httpd和设置Apache httpd为服务启动为例子:

centos7之前的命令是这样:

service httpd start 启动Apache httpd

service httpd restart 重新启动

service httpd stop 停止服务

chkconfig –levels 235 httpd on 开机启动httpd

或是:

/etc/init.d/ httpd start 启动

/etc/init.d/ httpd restart 重新启动

/etc/init.d/ httpd stop 停止服务

centos7吧这些命令全部合并了,使用也更加方便,当然也是习惯问题,如果习惯了之前命令,centos新命令还得适应适应,其实很简单,只要这样记忆,使用就比较方便了.

systemctl 动作 服务名.service

一些centos7 systemctl命令简单实用实例:

systemctl start httpd.service /启动Apache httpd

systemctl restart httpd.service /重新启动

systemctl stop httpd.service /停止服务

systemctl enable httpd.service /开机启动httpd

systemctl disable httpd.service /禁止开机启动httpd

本文转自pizibaidu 51CTO博客,原文链接:http://blog.51cto.com/pizibaidu/1763535,如需转载请自行联系原作者

继续阅读