CentOS7

https://access.redhat.com/documentation/zh-cn/red_hat_enterprise_linux/7/html/7.2_release_notes/index
https://access.redhat.com/documentation/zh-cn/red_hat_enterprise_linux/

https://www.centos.org/download/mirrors/
https://wiki.centos.org/zh/Manuals/ReleaseNotes/CentOS7
http://vault.centos.org/centos/7/

linux下刻录U盘,U盘在linux中文件为/dev/sdc
dd if=CentOS-7-x86_64-DVD-1511.iso of=/dev/sdc

http://isoredirect.centos.org/centos/7/isos/x86_64/

Actual Country -
http://mirrors.nwsuaf.edu.cn/centos/7/isos / x86_64 /
http://mirrors.163.com/centos/7/isos/x86_64/
http://mirror.lzu.edu.cn/centos/7/isos/x86_64/
http://mirrors.cqu.edu .cn / CentOS / 7 / isos / x86_64 /
http://mirrors.shu.edu.cn/centos/7/isos/x86_64/
http://mirrors.tuna.tsinghua.edu.cn/centos/7/isos / x86_64 /
http://centos.ustc.edu.cn/centos/7/isos/x86_64/
http://mirrors.neusoft.edu.cn/centos/7/isos/x86_64/
http://mirrors.sohu .com / centos / 7 / isos / x86_64 /
http://mirrors.cn99.com/centos/7/isos/x86_64/
http://mirror.bit.edu.cn/centos/7/isos/x86_64/
http://mirrors.aliyun.com/centos/7/isos/x86_64/
http://mirrors.zju.edu.cn/ centos / 7 / isos / x86_64 /
http://ftp.sjtu.edu.cn/centos/7/isos/x86_64/
http://mirrors.nju.edu.cn/centos/7/isos/x86_64/

  1. CentOS7.2环境准备

新建虚拟机:

内存1G

硬盘 100G

两块网卡(eth0 : 10.0.0.201 eth1: 172.16.1.201)

系统镜像 CentOS-7-x86_64-DVD-1511.iso

内核参数 net.ifnames=0 biosdevname=0

安装系统最小化,选择包组

image

安装系统之后:
1、关闭防火墙、关闭selinux

systemctl disable firewalld.service
sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config

epel源

curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo 

安装软件

yum -y install vim lrzsz bash-completion telnet nmap
  1. CentOS7系统镜像

  2. 镜像名解释: CentOS -7-x86_64 -DVD -1708.iso

CentOS -7 系统是 7.x 版本
x86_64 64位操作系统,并且从7以后不再提供32位镜像
1708 2017年08月发表的版本

  1. 修改网卡名称为eth0、eth1

  2. 方法1

  3. 修改网卡名称

cd /etc/sysconfig/network-scripts/
mv ifcfg-eno16777736 ifcfg-eth0
mv ifcfg-eno33554960 ifcfg-eth1
  1. 修改网卡配置文件
[root@bogon ~]# cat /etc/sysconfig/network-scripts/**ifcfg-eth0**

TYPE=Ethernet

BOOTPROTO=static

NETMASK=255.255.255.0

IPADDR=10.0.0.110

GATEWAY=10.0.0.2

DEFROUTE=yes

PEERDNS=yes

PEERROUTES=yes

IPV4_FAILURE_FATAL=no

NAME=eth0

UUID=582bec32-fa8b-415e-9cdc-873035dc336d

DEVICE=eth0

ONBOOT=yes
[root@bogon ~]# cat /etc/sysconfig/network-scripts/**ifcfg-eth1**

TYPE=Ethernet

BOOTPROTO=static

DEFROUTE=yes

PEERDNS=yes

PEERROUTES=yes

IPV4_FAILURE_FATAL=no

NAME=eth1

UUID=7a62954e-574f-41cc-b4f6-3c802fa4a819

DEVICE=eth1

ONBOOT=yes
  1. 修改grub

加入以下内容
cat /etc/sysconfig/grub

GRUB_TIMEOUT=5

GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"

GRUB_DEFAULT=saved

GRUB_DISABLE_SUBMENU=true

GRUB_TERMINAL_OUTPUT="console"

GRUB_CMDLINE_LINUX="rhgb net.ifnames=0 biosdevname=0 quiet"

GRUB_DISABLE_RECOVERY="true"


cat /etc/default/grub

GRUB_TIMEOUT=5

GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"

GRUB_DEFAULT=saved

GRUB_DISABLE_SUBMENU=true

GRUB_TERMINAL_OUTPUT="console"

GRUB_CMDLINE_LINUX="biosdevname=0 net.ifnames=0 rhgb quiet"

GRUB_DISABLE_RECOVERY="true"
  1. 生成启动菜单
grub2-mkconfig -o /boot/grub2/grub.cfg
  1. 重启系统
reboot
  1. 方法2

net.ifnames=0 biosdevname=0

image
vmlinuz initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 quiet **net.ifnames=0 biosdevname=0**
  1. 方法3
    cobbler装机时设置
cat /usr/lib/udev/rules.d/80-net-name-slot.rules** 

# do not edit this file, it will be overwritten on update

ACTION!="add", GOTO="net_name_slot_end"

SUBSYSTEM!="net", GOTO="net_name_slot_end"

NAME!="", GOTO="net_name_slot_end"

IMPORT{cmdline}="net.ifnames"

ENV{**net.ifnames**}=="0", GOTO="net_name_slot_end"

NAME=="", ENV{ID_NET_NAME_ONBOARD}!="", NAME="$env{ID_NET_NAME_ONBOARD}"

NAME=="", ENV{ID_NET_NAME_SLOT}!="", NAME="$env{ID_NET_NAME_SLOT}"

NAME=="", ENV{ID_NET_NAME_PATH}!="", NAME="$env{ID_NET_NAME_PATH}"

LABEL="net_name_slot_end"
cat /usr/lib/udev/rules.d/71-biosdevname.rules**

SUBSYSTEM!="net", GOTO="netdevicename_end"

ACTION!="add",    GOTO="netdevicename_end"

NAME=="?*",       GOTO="netdevicename_end"

ATTR{type}!="1",  GOTO="netdevicename_end"

ENV{DEVTYPE}=="?*", GOTO="netdevicename_end"

# whitelist all Dell systems

ATTR{[dmi/id]sys_vendor}=="Dell*", ENV{UDEV_BIOSDEVNAME}="1"

# kernel command line "**biosdevname**={0|1}" can turn off/on biosdevname

IMPORT{cmdline}="biosdevname"

ENV{biosdevname}=="?*", ENV{UDEV_BIOSDEVNAME}="$env{biosdevname}"

# ENV{UDEV_BIOSDEVNAME} can be used for blacklist/whitelist

# but will be overwritten by the kernel command line argument

ENV{UDEV_BIOSDEVNAME}=="0", GOTO="netdevicename_end"

ENV{UDEV_BIOSDEVNAME}=="1", GOTO="netdevicename_start"

# off by default

GOTO="netdevicename_end"

LABEL="netdevicename_start"

# using NAME= instead of setting INTERFACE_NAME, so that persistent

# names aren't generated for these devices, they are "named" on each boot.

SUBSYSTEMS=="pci", PROGRAM="/sbin/biosdevname --smbios 2.6 --nopirq --policy physical -i %k", NAME="%c"  OPTIONS+="string_escape=replace"

LABEL="netdevicename_end"

  1. 安装一些基础命令
yum -y install wget vim bash-completion lrzsz nmap telnet tree net-tools bind-utils
  1. 关闭防火墙和 selinux
  2. 关闭防火墙
systemctl stop firewalld.service
  1. 禁止防火墙开机启动
systemctl disable firewalld.service

systemctl stop NetworkManager.service

systemctl disable NetworkManager.service
  1. 关闭selinux
[root@bogon ~]# getenforce

Enforcing

[root@bogon ~]# setenforce 0

[root@bogon ~]# getenforce

Permissive

[root@bogon ~]# vim /etc/selinux/config
  1. 开机启动流程
  2. sysvinit技术

特点:
1、系统第一个进程(pid=1) 为 init
2、init进程是所有进程的祖先,不可kill
3、大多数linux发行版的init系统是和systemv相兼容的,被称为sysvinit
4、代表系统 CentOS5 CentOS 6

  1. upstart技术

CentOS6采用了upstart技术代替sysvinit进行引导,upstart对rc.sysinit脚本做了大量的优化,缩短了系统初始化时的启动时间。但是CentOS6为了简便管理员的操作,upstart的很多特性并没有凸显或者直接不支持,因此在CentOS6中的服务启动脚本还是以原来sysv的形式提供的
一个应运而生的技术,却因为竞争对手太强大,而被淘汰

代表系统:Ubuntu14,从ubuntu15开始使用systemd
http://0pointer.de/blog/projects/why.html

initctl start 服务名
disable

  1. systemd技术

新系统都会采用的技术(RedHat7,CentOS7,Ubuntu15等)

设计目标是克服sysvinit固有的缺点,提高系统的启动速度

和sysvinit兼容,降低迁移成本

主要优点:并行启动

pid为1的进程

[root@centos7 ~]# ps -ef |head -2

UID PID PPID C STIME TTY TIME CMD

root 1 0 0 16:29 ? 00:00:02 /usr/lib/systemd/systemd --switched-root --system --deserialize 21

systemd:即使有依赖关系的服务,也能并发启动

并发启动原理之一:解决socket依赖/端口依赖
并发启动原理之二:解决D-Bus依赖:采用了D-Bus作为程序之间的通信工具,类似消息队列,可以缓存信息
并发启动原理之三:解决文件系统依赖:类似autofs机制

  1. CentOS7系统安装

下载地址:
http://vault.centos.org/

  1. 镜像名称解释

CentOS-7-x86_64-DVD-1611.iso

从CentOS 7 之后,版本命名就跟发行的日期有关了

CentOS-7 系统是7.x版本

x86_64 64位操作系统,并且从7以后不再提供32位镜像

1611 2016年11月发布的版本

  1. CentOS6到CentOS-7变化

  2. 使用CentOS-7最直观的变化就是服务管理了

services使用了systemd来代替sysvinit管理
systemd是Linux下的一种init软件,由Lennart Poettering带头开发,并在LGPL 2.1及其后续版本许可证下开源发布。其开发目标是提供更优秀的框架以表示系统服务间的依赖关系,并依此实现系统初始化时服务的并行启动,同时达到降低Shell的系统开销的效果,最终代替现在常用的System V与BSD风格init程序。

与多数发行版使用的System V风格init相比,systemd采用了以下新技术:
采用Socket激活式与总线激活式服务,以提高相互依赖的各服务的并行运行性能;
用cgroups代替PID来追踪进程,以此即使是两次fork之后生成的守护进程也不会脱离systemd的控制。

从设计构思上说,由于systemd使用了cgroup与fanotify等组件以实现其特性,所以只适用于Linux。

systemd的服务管理程序:
systemctl是主要的工具,它融合之前service和chkconfig的功能于一体。可以使用它永久性或只在当前会话中启用/禁用服务

启动一个服务:systemctl start postfix.service
关闭一个服务:systemctl stop postfix.service
重启一个服务:systemctl restart postfix.service
显示一个服务的状态:systemctl status postfix.service
在开机时启用一个服务:systemctl enable postfix.service
在开机时禁用一个服务:systemctl disable postfix.service
查看服务是否开机启动:systemctl is-enabled postfix.service;echo $?
查看已启动的服务列表:systemctl list-unit-files|grep enabled
  1. 网卡名称区别

区别1:网卡名称eth0和enp5s0

传统上,linux的网络接口名称为eth0、eth1...,但这些名称并不一定符合实际的硬件插槽等,这可能会导致不同的网络配置错误(例如,由无意的接口改名引起的禁止接口)。基于MAC地址的udev规则在虚拟化的环境中并不有用,这里的MAC地址如端口数量一样无常

CentOS6/RHEL6引入了一致和可预测的网络设备命名网络接口的方法。这些特性可以唯一地确定网络接口的名称以使定位和区分设备更容易,并且在这样一种方式下,无论是否重启机器、过了多少时间或者改变硬件,其名字都是持久不变的。然而,这种命名规则并不是默认在CentOS/RHEL6上开启

从CentOS7/RHEL7起,这种可预见的命名规则变成了默认。根据这一规则,接口名称被自动基于固件,拓扑结构和位置信息来确定。现在,即使添加或移除网络设备,接口名称仍然保持固定,而无需重新枚举,和坏掉的硬件可以无缝替换

  1. 网络管理命令
iproute 软件包包括 ip ss 命令

net-tools软件包包括 ifconfig route netstat命令

ip 命令相当于之前的 ifconfig route

ss 命令相当于之前的 netstat

nmtui 命令(软件包NetworkManager-tui) setup命令 (软件包setuptool)

nmtui命令替代setup命令

查看网络连接

[root@VM_153_209_centos ~]# nmcli connection

NAME UUID TYPE DEVICE

System eth0 5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03 802-3-ethernet eth0

br-755ad1dc6879 3f859a89-5946-4763-bb6a-868040b0ddf0 bridge br-755ad1dc6879

docker0 7ec1920d-ec78-440d-a807-1a1ba98d9c3e bridge docker0

### 

查看网络设备

nmcli device

### 

修改网卡配置信息

nmcli connection modify eth1 ipv4.addresses "172.16.1.200/24"

### 

添加一块网卡配置,并配置eth1的ip为172.16.1.200/24

nmcli connection add con-name eth1 ipv4.addresses 172.16.1.200/24 
ipv4.method manual autoconnect yes type ethernet ifname eth1

ifname <interface name>
con-name <connection name>
网卡添加IP地址

nmcli connection modify eth0 +ipv4.addresses 10.0.0.32/24
nmcli connection down eth0 && nmcli connection up eth0

删除连接网卡(网卡配置文件也被删除)

nmcli connection delete eth1

重载网卡配置文件(手动修改网卡配置文件需要重载)

nmcli connection reload

停止网卡

nmcli connection down eth1

启动网卡

nmcli connection up eth1
  1. 修改主机名
[root@centos7 ~]# hostnamectl set-hostname c77
[root@centos7 ~]# hostname
c77
[root@centos7 ~]# cat /etc/hostname
c77
  1. 字符集
[root@centos7 ~]# localectl set-locale LANG=zh_CN.UTF-8
[root@centos7 ~]# localectl status
System Locale: LANG=zh_CN.UTF-8
VC Keymap: us
X11 Layout: us
[root@centos7 ~]# cat /etc/locale.conf
LANG=zh_CN.UTF-8
yum install kde-l10n-Chinese
yum reinstall glibc-common
  1. 时区
  2. 查看时区
[root@centos7 ~]# timedatectl status

Local time: Fri 2017-03-10 16:41:59 CST

Universal time: Fri 2017-03-10 08:41:59 UTC

RTC time: Fri 2017-03-10 08:41:59

Time zone: Asia/Shanghai (CST, +0800)

NTP enabled: n/a

NTP synchronized: no

RTC in local TZ: no

DST active: n/a
  1. 设置时区
timedatectl set-timezone Asia/Shanghai
  1. 查看系统版本
[root@centos7 ~]# cat /etc/os-release

NAME="CentOS Linux"

VERSION="7 (Core)"

ID="centos"

ID_LIKE="rhel fedora"

VERSION_ID="7"

PRETTY_NAME="CentOS Linux 7 (Core)"

ANSI_COLOR="0;31"

CPE_NAME="cpe:/o:centos:centos:7"

HOME_URL="https://www.centos.org/"

BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"

CENTOS_MANTISBT_PROJECT_VERSION="7"

REDHAT_SUPPORT_PRODUCT="centos"

REDHAT_SUPPORT_PRODUCT_VERSION="7"
  1. 设置系统启动级别
[root@centos7 ~]# systemctl set-default multi-user.target

Removed symlink /etc/systemd/system/default.target.

Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/multi-user.target.
  1. 查看系统当前启动级别
[root@centos7 ~]# systemctl get-default

multi-user.target
  1. 查看系统所有运行级别
[root@centos7 ~]# ll -h /usr/lib/systemd/system/runlevel*.target

lrwxrwxrwx. 1 root root 15 Mar 10 14:02 /usr/lib/systemd/system/runlevel0.target -> poweroff.target

lrwxrwxrwx. 1 root root 13 Mar 10 14:02 /usr/lib/systemd/system/runlevel1.target -> rescue.target

lrwxrwxrwx. 1 root root 17 Mar 10 14:02 /usr/lib/systemd/system/runlevel2.target -> multi-user.target

lrwxrwxrwx. 1 root root 17 Mar 10 14:02 /usr/lib/systemd/system/runlevel3.target -> multi-user.target

lrwxrwxrwx. 1 root root 17 Mar 10 14:02 /usr/lib/systemd/system/runlevel4.target -> multi-user.target

lrwxrwxrwx. 1 root root 16 Mar 10 14:02 /usr/lib/systemd/system/runlevel5.target -> graphical.target

lrwxrwxrwx. 1 root root 13 Mar 10 14:02 /usr/lib/systemd/system/runlevel6.target -> reboot.target
  1. 服务管理程序存放位置
/usr/lib/systemd/system

/etc/systemd/system/

[root@centos7 ~]# ll -h /etc/systemd/system/default.target

lrwxrwxrwx 1 root root 41 Mar 10 16:49 /etc/systemd/system/default.target -> /usr/lib/systemd/system/multi-user.target
  1. /etc/rc.local
chmod +x /etc/rc.d/rc.local
  1. systemd 管理程序
https://www.freedesktop.org/software/systemd/man/systemd.service.html
image.png

cat /usr/lib/systemd/system/sshd.service

[Unit]

Description=OpenSSH server daemon

Documentation=man:sshd(8) man:sshd_config(5)

After=network.target sshd-keygen.service

Wants=sshd-keygen.service

[Service]

Type=notify

EnvironmentFile=/etc/sysconfig/sshd

ExecStart=/usr/sbin/sshd -D $OPTIONS

ExecReload=/bin/kill -HUP $MAINPID

KillMode=process

Restart=on-failure

RestartSec=42s

[Install]

WantedBy=multi-user.target

cat /etc/systemd/system/mysqld.service

[Unit]

Description=MySQL Server

Documentation=man:mysqld(8)

Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html

After=network.target

After=syslog.target

[Install]

WantedBy=multi-user.target

[Service]

User=mysql

Group=mysql

ExecStart=/usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf

LimitNOFILE = 5000
  1. 系统服务启动时间查看
systemd-analyze time

systemd-analyze blame

导出图片

systemd-analyze plot > bootime.svg

学习资料:

http://www.jinbuguo.com/systemd/systemd.service.html
https://access.redhat.com/documentation/zh-CN/Red_Hat_Enterprise_Linux/7/html/Installation_Guide/index.html
http://www.cnblogs.com/justphp/p/6120201.html

CentOS7-文件句柄

1./etc/security/limits.conf中指定的nofile的值,nofile有上限,不是无穷大。nofile由内核参数nr_open定义的.

“在2.6.25内核之前有个宏定义,定义了这个值的最大值,为1024*1024,正好是100万,而在2.6.25内核及其之后,这个值是可以通过/proc/sys/fs/nr_open来设置。”

2.使用cat /proc/sys/fs/nr_open 查看nr_open值,可通过修改/ect/sysct.conf 修改fs.nr_open值,sysctl -p生效
3.fix_max linux内核定义的最大file handles(文件句柄数)
nr_open定义是单进程最大file-handles,file-handles(即文件句柄)
file-max:

The value in file-max denotes the maximum number of file-

handles that the Linux kernel will allocate. When you get lots

of error messages about running out of file handles, you might

want to increase this limit

nr_open:

This denotes the maximum number of file-handles a process can

allocate. Default value is 1024*1024 (1048576) which should be

enough for most machines. Actual limit depends on RLIMIT_NOFILE

resource limit.

注:
centos 5/6** 等版本中,资源限制的配置可以在 /etc/security/limits.conf 设置,针对root/user等各个用户或者*代表所有用户来设置。 当然,/etc/security/limits.d/ 中可以配置,系统是先加载limits.conf然后按照英文字母顺序加载limits.d目录下的配置文件,后加载配置覆盖之前的配置。
CentOS 7 / RHEL 7**的系统中,使用Systemd替代了之前的SysV,因此 /etc/security/limits.conf 文件的配置作用域缩小了一些。limits.conf这里的配置,只适用于通过PAM认证登录用户的资源限制,它对systemd的service的资源限制不生效。登录用户的限制,与上面讲的一样,通过 /etc/security/limits.conf 和 limits.d 来配置即可。
对于systemd service的资源限制,如何配置呢?
全局的配置,放在文件 /etc/systemd/system.conf 和 /etc/systemd/user.conf。 同时,也会加载两个对应的目录中的所有.conf文件 /etc/systemd/system.conf.d/*.conf 和 /etc/systemd/user.conf.d/*.conf
其中,system.conf 是系统实例使用的,user.conf用户实例使用的。一般的sevice,使用system.conf中的配置即可。systemd.conf.d/*.conf中配置会覆盖system.conf。
注意:修改了system.conf后,需要重启系统才会生效。

一、如果需要修改 单个进程打开的文件句柄数 即nofile大于1024*1024,需要修改nr_open,方法如下:

1、使用cat /proc/sys/fs/nr_open查看nr_open值;

[root@localhost ~]# cat /proc/sys/fs/nr_open 
1048576

2、修改nr_open的值为10240000

打开/etc/sysctl.conf,在文件末尾添加fs.nr_open=10240000

# sysctl settings are defined through files in

# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.

#

# Vendors settings live in /usr/lib/sysctl.d/.

# To override a whole file, create a new file with the same in

# /etc/sysctl.d/ and put new settings there. To override

# only specific settings, add a file with a lexically later

# name in /etc/sysctl.d/ and put new settings there.

#

# For more information, see sysctl.conf(5) and sysctl.d(5).

fs.nr_open=10240000

保存

(注:nr_open的值要小于file-max)

/proc/sys/fs/file-max

3、执行如下命令,使修改生效

sysctl -p

4、验证修改是否生效

cat /proc/sys/fs/nr_open

如果结果为10240000,说明修改生效

二、修改/etc/systemd/system.conf,主要用于systemd service的资源限制

[root@localhost ~]# vi /etc/systemd/system.conf
#  This file is part of systemd.

#

#  systemd is free software; you can redistribute it and/or modify it

#  under the terms of the GNU Lesser General Public License as published by

#  the Free Software Foundation; either version 2.1 of the License, or

#  (at your option) any later version.

#

# Entries in this file show the compile time defaults.

# You can change settings by editing this file.

# Defaults can be restored by simply deleting this file.

#

# See systemd-system.conf(5) for details.

[Manager]

#LogLevel=info

#LogTarget=journal-or-kmsg

#LogColor=yes

#LogLocation=no

#DumpCore=yes

#CrashShell=no

#ShowStatus=yes

#CrashChVT=1

#CtrlAltDelBurstAction=reboot-force

#CPUAffinity=1 2

#JoinControllers=cpu,cpuacct net_cls,net_prio

#RuntimeWatchdogSec=0

#ShutdownWatchdogSec=10min

#CapabilityBoundingSet=

#SystemCallArchitectures=

#TimerSlackNSec=

#DefaultTimerAccuracySec=1min

#DefaultStandardOutput=journal

#DefaultStandardError=inherit

#DefaultTimeoutStartSec=90s

#DefaultTimeoutStopSec=90s

#DefaultRestartSec=100ms

#DefaultStartLimitInterval=10s

#DefaultStartLimitBurst=5

#DefaultEnvironment=

#DefaultCPUAccounting=no

#DefaultBlockIOAccounting=no

#DefaultMemoryAccounting=no

#DefaultTasksAccounting=no

#DefaultTasksMax=

#DefaultLimitCPU=

#DefaultLimitFSIZE=

#DefaultLimitDATA=

#DefaultLimitSTACK=

#DefaultLimitCORE=

DefaultLimitCORE=infinity

#DefaultLimitRSS=

#DefaultLimitNOFILE=

**DefaultLimitNOFILE=10240000**

#DefaultLimitAS=

#DefaultLimitNPROC=

DefaultLimitNPROC=10240000

#DefaultLimitMEMLOCK=

#DefaultLimitLOCKS=

#DefaultLimitSIGPENDING=

#DefaultLimitMSGQUEUE=

#DefaultLimitNICE=

#DefaultLimitRTPRIO=

#DefaultLimitRTTIME=

三、修改/etc/security/limits.conf文件

[root@localhost ~]# vi /etc/security/limits.conf

在文件末尾添加

root            soft    fsize           unlimited

root            hard    fsize           unlimited

root            soft    cpu             unlimited

root            hard    cpu             unlimited

root            soft    as              unlimited

root            hard    as              unlimited

root            soft    nofile          10240000

root            hard    nofile          10240000

root            soft    nproc           10240000

root            hard    nproc           10240000

* - nofile 100000

四、修改/etc/security/limits.d/20-nproc.conf文件

[root@localhost ~]# vi /etc/security/limits.d/20-nproc.conf 

修改

*          soft    nproc     4096

*          soft    nproc     10240000

CentOS7修改单个进程可打开的最大文件句柄数为10240000完成

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 199,830评论 5 468
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 83,992评论 2 376
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 146,875评论 0 331
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 53,837评论 1 271
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 62,734评论 5 360
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,091评论 1 277
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,550评论 3 390
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,217评论 0 254
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,368评论 1 294
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,298评论 2 317
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,350评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,027评论 3 315
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,623评论 3 303
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,706评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 30,940评论 1 255
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 42,349评论 2 346
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 41,936评论 2 341

推荐阅读更多精彩内容