系统参数的详细解释

下面是对所列系统参数的详细解释:

  1. net.bridge.bridge-nf-call-iptables = 1: 这个参数允许 Linux 内核在桥接网络和 iptables 防火墙之间进行数据包处理。启用此选项可以确保桥接的网络流量能够通过 iptables 进行过滤和修改。

  2. vm.max_map_count = 262144: 该参数定义了每个进程可以拥有的内存映射区域数量的最大值。增加这个值可以增加系统可以支持的并发进程数。

  3. fs.aio-max-nr = 1048576: 异步 I/O (AIO) 是一种在执行 I/O 操作时不会阻塞进程的技术。该参数设置了系统可同时支持的异步 I/O 请求的最大数量。

  4. fs.pipe-user-pages-soft = 0: 管道是一种用于进程间通信的特殊文件类型。这个参数控制了用户空间管道页面缓冲的使用情况。将其设置为 0 可以提高管道性能,但可能会占用更多的内存。

  5. fs.pipe-max-size = 33554432: 这个参数定义了管道的最大大小(以字节为单位)。增加这个值可以允许更大的管道传输。

  6. net.ipv4.ip_forward = 1: 启用 IP 转发功能,允许 Linux 主机将收到的网络流量转发到其他网络接口,用于实现路由功能。

  7. net.ipv4.tcp_keepalive_time = 30: 这个参数定义了 TCP 连接的空闲时间(以秒为单位),在该时间内没有数据传输时,Linux 将发送一个 TCP keep-alive 消息以维持连接的活跃状态。

  8. net.ipv4.tcp_retries2 = 7:这个系统参数控制着 TCP 连接失败时的重试次数。当一个 TCP 连接在建立或关闭过程中失败时,内核会尝试重新发送连接请求或关闭请求的次数。tcp_retries2 参数指定了连接失败后的重试次数上限。默认情况下,它的值为 15,但是通过将其设置为 7,可以减少连接失败时的重试次数,从而更快地放弃连接。

  9. fs.inotify.max_user_watches = 524288:
    inotify 是 Linux 内核提供的一种文件系统事件监控机制。该参数定义了一个用户可以同时监视的文件或目录数量的上限。每个被监视的文件或目录都会消耗一定的内存和 CPU 资源。max_user_watches 参数用于限制单个用户能够添加的 inotify 监视项的数目。通过增加该值,可以允许更多的文件或目录被监视。

  10. fs.file-max = 6815744:这是一个限制系统中最大打开文件(file)句柄数量的参数。每个进程在运行时都会使用一定数量的文件句柄,包括打开的文件、网络连接等。file-max 参数限制了整个系统中所有进程能够使用的文件句柄总数。当系统达到这个限制时,无法再打开更多的文件,会导致进程无法正常工作。通过增加 file-max 的值,可以提高系统能够支持的最大文件句柄数,从而允许更多的进程同时打开文件。

待完善笔记

- name: Add modprobe br_netfilter to /etc/rc.local
  lineinfile:
    path: /etc/rc.local
    line: "modprobe br_netfilter"

- name: set iptables top /etc/rc.local
  lineinfile:
    path: /etc/rc.local
    line: "iptables -P FORWARD ACCEPT"

- name: Remove swap mount point in /etc/fstab
  lineinfile:
    path: /etc/fstab
    regexp: 'swap'
    state: absent

- name: iptables flush and br_netfilter
  shell: "{{ item }}"
  with_items:
    - swapoff -a
    - modprobe br_netfilter
    - iptables -P FORWARD ACCEPT

- name: Set sysctl parameters
  sysctl: name={{ item.name }} value={{ item.value }} state={{ item.state }} reload=yes
  with_items:
    - { name: 'net.bridge.bridge-nf-call-iptables', value: '1', state: 'present'}
    - { name: 'vm.max_map_count', value: '262144', state: 'present'}
    - { name: 'fs.aio-max-nr', value: '1048576', state: 'present'}
    - { name: 'fs.pipe-user-pages-soft', value: '0', state: 'present'}
    - { name: 'fs.pipe-max-size', value: '33554432', state: 'present'}
    - { name: 'net.ipv4.ip_forward', value: '1', state: 'present'}
    - { name: 'net.ipv4.tcp_keepalive_time', value: '30', state: 'present'}
    - { name: 'net.ipv4.tcp_retries2', value: '7', state: 'present'}
    - { name: 'fs.inotify.max_user_watches', value: '524288', state: 'present'}

- name: Stop and disable selinux.
  selinux: state=disabled
  ignore_errors: True

- name: set timezone
  timezone:
    name: Asia/Shanghai

- name: stop service
  systemd: name={{ item.name }} state={{ item.state }} daemon_reload={{ item.daemon }} enabled={{ item.enabled }}
  ignore_errors: True
  with_items:
    - { name: 'firewalld', state: 'stopped', daemon: 'yes', enabled: 'no' }
# Cilium
- name: Copy x86_64 Cilium binary to all host
  copy: src='bin/cilium' dest='/usr/bin/cilium' mode='0755'
  when: ansible_machine == "x86_64"

- name: Copy aarch64 Cilium binary to all host
  copy: src='bin/cilium-arm' dest='/usr/bin/cilium' mode='0755'
  when: ansible_machine == "aarch64"


- name: Check if Cilium pid file exists
  stat:
    path: /var/run/cilium/cilium.pid
  register: cilium_pid

- name: Clean up cilium rules
  shell: /usr/bin/cilium cleanup -f
  when: not cilium_pid.stat.exists

- name: Add rp_filter override rule
  shell: |
    echo 'net.ipv4.conf.all.rp_filter = 0' > /etc/sysctl.d/99-override_cilium_rp_filter.conf
    echo 'net.ipv4.conf.lxc*.rp_filter = 0' >> /etc/sysctl.d/99-override_cilium_rp_filter.conf

- name: Restart systemd-sysctl
  systemd:
    name: systemd-sysctl
    state: restarted

- name: Check /etc/resolv.conf exists
  stat:
    path: /etc/resolv.conf
  register: resolv_conf_file_stat

- name: Create /etc/resolv.conf
  file:
    path: /etc/resolv.conf
    state: touch
  when: not resolv_conf_file_stat.stat.exists


- name: Set soft hard nofile limits in limits.conf
  lineinfile:
    path: /etc/security/limits.conf
    line: '{{ item }}'
    state: present
  with_items:
    - "* soft nofile 1000000"
    - "* hard nofile 1000000"

# for profile
- name: copy .qfusion profile
  copy: src='.qfusion' dest='/root/.qfusion' mode='0755'
  when: role == 'master' or role == 'shadow'


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值