oceanbasea[ERROR] OBD-1007: (127.0.0.1) The value of the ulimit parameter "open files" must not be less than 20000 (Current value: 1024)

一、# 切换到 root 用户(若已为 root 可跳过)
sudo su -
[ERROR] OBD-1007: (127.0.0.1) The value of the ulimit parameter "open files" must not be less than 20000 (Current value: 1024), Please execute `echo -e "* soft nofile 20000\n* hard nofile 20000" >> /etc/security/limits.d/nofile.conf` as root in 127.0.0.1. if it dosen't work, please check whether UsePAM is yes in /etc/ssh/sshd_config.

# 执行 OBD 建议的命令,添加 nofile 配置
echo -e "* soft nofile 20000\n* hard nofile 20000" >> /etc/security/limits.d/nofile.conf

# 验证配置是否写入成功
cat /etc/security/limits.d/nofile.conf
* soft nofile 20000
* hard nofile 20000
# 编辑 sshd_config 文件
vi /etc/ssh/sshd_config

# 找到 UsePAM 这一行,确保值为 yes(去掉注释,修改值)
UsePAM yes

# 保存退出后,重启 sshd 服务使配置生效
systemctl restart sshd
# 退出当前 root 会话
exit

# 重新登录服务器(或重新 ssh 连接),然后检查配置是否生效
ulimit -n

# 正确输出应为 20000
方法一不成功可以使用方法二

二、

1. 全维度配置 limits(root 用户执行,一步到位)

bash
 
运行
 
 
 
 
# 1. 停止所有 OceanBase 相关进程(避免占用)
pkill -9 observer || true

# 2. 配置 /etc/security/limits.conf(系统核心配置)
cat >> /etc/security/limits.conf << EOF

# OceanBase 配置
root soft nofile 655350
root hard nofile 655350
* soft nofile 655350
* hard nofile 655350
* soft core unlimited
* hard core unlimited
* soft stack unlimited
* hard stack unlimited
EOF

# 3. 配置 /etc/security/limits.d/nofile.conf(覆盖默认配置)
cat > /etc/security/limits.d/nofile.conf << EOF
* soft nofile 655350
* hard nofile 655350
EOF

# 4. 配置 PAM 确保 limits 生效(Ubuntu 关键)
sed -i '/session\s*required\s*pam_limits.so/s/^#//g' /etc/pam.d/common-session
echo "session required pam_limits.so" >> /etc/pam.d/common-session

# 5. 重启系统服务(强制加载配置)
systemctl restart systemd-logind
systemctl restart sshd

# 6. 验证配置文件(确认内容正确)
grep -E "nofile|core|stack" /etc/security/limits.conf
grep -E "nofile" /etc/security/limits.d/nofile.conf
 

2. 必须重启服务器(最后手段)

如果退出重登后 ulimit -n 还是 1024,说明系统没有加载新配置,唯一办法是重启服务器
bash
 
运行
 
 
 
 
# 重启服务器(root 用户)
reboot
 
重启后登录服务器,立即执行:
bash
 
运行
 
 
 
 
ulimit -n  # 必须显示 655350,否则配置仍有问题
 

二、解决内存不足问题(Free:6G < Need:7G)

内存不足会导致集群启动失败,需要修改 OceanBase 配置文件降低内存要求(仅用于测试环境,生产环境需加内存):

1. 编辑集群配置文件

bash
 
运行
 
 
 
 
obd cluster edit perf
 

2. 修改内存相关参数(关键)

找到 oceanbase-ce 段落,替换为以下配置(适配 6G 内存):
yaml
 
 
oceanbase-ce:
  servers:
    - 127.0.0.1
  global:
    memory_limit: 5G          # 总内存限制(留 1G 系统缓冲)
    system_memory: 1G         # 系统内存分配
    datafile_size: 10G        # 数据文件大小
    log_disk_size: 5G         # 日志磁盘大小
    cpu_count: 1              # 限制 CPU 核心数
    cache_wash_threshold: 512M
    __min_full_resource_pool_memory: 512M  # 降低最小内存阈值
    memory_chunk_cache_size: 256M
    minor_freeze_times: 10
    enable_separate_sys_clog: 0
 
保存并退出编辑

# 1. 停止所有 OceanBase 相关进程(避免占用) pkill -9 observer || true # 2. 配置 /etc/security/limits.conf(系统核心配置) cat >> /etc/security/limits.conf << EOF # OceanBase 配置 root soft nofile 655350 root hard nofile 655350 * soft nofile 655350 * hard nofile 655350 * soft core unlimited * hard core unlimited * soft stack unlimited * hard stack unlimited EOF # 3. 配置 /etc/security/limits.d/nofile.conf(覆盖默认配置) cat > /etc/security/limits.d/nofile.conf << EOF * soft nofile 655350 * hard nofile 655350 EOF # 4. 配置 PAM 确保 limits 生效(Ubuntu 关键) sed -i '/session\s*required\s*pam_limits.so/s/^#//g' /etc/pam.d/common-session echo "session required pam_limits.so" >> /etc/pam.d/common-session # 5. 重启系统服务(强制加载配置) systemctl restart systemd-logind systemctl restart sshd # 6. 验证配置文件(确认内容正确) grep -E "nofile|core|stack" /etc/security/limits.conf grep -E "nofile" /etc/security/limits.d/nofile.conf

posted @ 2026-02-25 09:53  海宏软件  阅读(22)  评论(0)    收藏  举报