Linux sysctl命令:在系统运行时配置内核参数。
Linux sysctl命令 功能描述
使用sysctl命令可以在系统运行时配置内核参数,可用的参数列在/proc/sys目录中。
Linux sysctl命令 语法
sysctl [选项] [参数=值]
sysctl [选项]
命令中各选项的含义如表所示。
Linux sysctl命令 示例
查看所有的系统内核参数
[root@rhel ~]# sysctl -a
kernel.sched_child_runs_first = 0
kernel.sched_min_granularity_ns = 1000000
kernel.sched_latency_ns = 5000000
kernel.sched_wakeup_granularity_ns = 1000000
kernel.sched_tunable_scaling = 1
kernel.sched_features = 3183
kernel.sched_migration_cost = 500000
kernel.sched_nr_migrate = 32
kernel.sched_time_avg = 1000
kernel.sched_shares_window = 10000000
kernel.timer_migration = 1
kernel.sched_rt_period_us = 1000000
kernel.sched_rt_runtime_us = 950000
kernel.sched_compat_yield = 0
kernel.sched_autogroup_enabled = 0
kernel.sched_cfs_bandwidth_slice_us = 5000
kernel.panic = 0
kernel.exec-shield = 1
kernel.core_uses_pid = 1
kernel.core_pattern = core
kernel.core_pipe_limit = 4
kernel.tainted = 0
........................(省略)
加载/etc/sysctl.conf文件系统内核参数
[root@rhel ~]# sysctl -p
net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
error: ''net.bridge.bridge-nf-call-ip6tables'' is an unknown key
error: ''net.bridge.bridge-nf-call-iptables'' is an unknown key
error: ''net.bridge.bridge-nf-call-arptables'' is an unknown key
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.shmmax = 68719476736
kernel.shmall = 4294967296
查看fs.file-max内核参数
[root@rhel ~]# sysctl fs.file-max
fs.file-max = 98007
//fs.file-max内核参数的值是98007
临时改变fs.file-max内核参数
[root@rhel ~]# sysctl -w fs.file-max=60000
fs.file-max = 60000