- 创建者: 虚拟的现实,上次更新时间:5月 05, 2025 需要 3 分钟阅读时间
简介
Cockpit 是 RedHat 维护的 Linux 服务器面板工具。它具备很强的开放能力,可以集成各种应用到面板的菜单上,如果善于使用它,你会发现它就是容器时代最好的面板之一。
官方网站:http://cockpit-project.org/
配置操作系统镜像
source.list 格式
sudo sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
Deb822 格式
sudo sed -i 's/deb.debian.org/mirrors.ustc.edu.cn/g' /etc/apt/sources.list.d/debian.sources
Cockpit 组件安装
获取 并安装 Cockpit 组件
要获取最新版本,建议启用 backports 存储库(以 root 身份)
默认情况下通过 web 页面是不能直接用 root 用户登录的,新建一个管理用户 admin 并将该用户加入 sudo 组
. /etc/os-release echo "deb http://deb.debian.org/debian ${VERSION_CODENAME}-backports main" > \ /etc/apt/sources.list.d/backports.list apt update apt install -t ${VERSION_CODENAME}-backports cockpit useradd admin passwd admin usermod -aG sudo admin
完成安装后可以通过浏览器访问 http://XXX:9090 方式打开配置页面
虚拟机和容器配置组件
. /etc/os-release apt install -t ${VERSION_CODENAME}-backports cockpit-machines -y apt install -t ${VERSION_CODENAME}-backports cockpit-podman -y
第三方组件(文件浏览、权限、共享)
配置45Drives Repo安装脚本,安装脚本将自动检测您的发行版并将适当的文件添加到您的系统。该脚本还将保存任何与 45Drives 相关的旧存储库(如果存在)。包括
cockpit-navigator、cockpit-file-sharing 和 cockpit-identities 这三个组件。
curl -sSL https://repo.45drives.com/setup | bash sudo apt update sudo apt install cockpit-navigator cockpit-file-sharing cockpit-identities -y
ZFS 组件
该插件按需安装,非必要组件。要求:Cockpit: 201+;NFS (Optional);Samba: 4+ (Optional);ZFS: 0.8+
apt update apt install -y zfs-dkms zfsutils-linux git clone https://github.com/optimans/cockpit-zfs-manager.git sudo cp -r cockpit-zfs-manager/zfs /usr/share/cockpit
Cockpit 调优
自动注销闲置的用户
在您首选的文本编辑器中,在 /etc/cockpit/ 目录中打开或创建 cockpit.conf 文件。
在文件中添加以下文本,以分钟为单位,这里表示为15分钟后自动退出。重启服务后生效。
vim /etc/cockpit/cockpit.conf [Session] IdleTimeout=10 systemctl try-restart cockpit
在登录页面中添加标题
在您首选的文本编辑器中创建 /etc/issue.cockpit 文件(如果您还没有该文件)。添加您要显示的内容作为文件的横幅。在文件中添加需要展示的内容。
vim /etc/cockpit/issue.cockpit HomeNAS Based on Debian 12.
内容添加完成后,保存这个文件。在 /etc/cockpit/ 目录中打开或创建 cockpit.conf 文件。在文件中添加以下文本,保存该文件,重启Cockpit Web 控制台以使更改生效。
[Session] Banner=/etc/cockpit/issue.cockpit systemctl try-restart cockpit
修改登录后的展示信息
配置文件路径及展示的原文内容如下:
vim /etc/motd The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law.
将上面的内容修改为:
我们信任您已经从系统管理员那里了解了日常注意事项。 总结起来无外乎这三点: #1) 尊重别人的隐私。 #2) 输入前要先考虑(后果和风险)。 #3) 权力越大,责任越大。
Nginx 反向代理 Cockpit
在 /etc/cockpit/ 目录中打开或创建 cockpit.conf 文件,在文件中添加以下文本,将下面内容中的两处’cockpit.domain.tld’替换为你的域名(如为非标端口号,需将端口号一并填写上),将192.168.1.10:9090修改为你对应的内网IP,就可以实现外网内网同时访问Cockpit管理面板
vim /etc/cockpit/cockpit.conf [WebService] Origins = https://cockpit.domain.tld wss://cockpit.domain.tld https://192.168.1.10:9090 ProtocolHeader = X-Forwarded-Proto ForwardedForHeader = X-Forwarded-For LoginTo = false systemctl try-restart cockpit
修改 Web 登陆端口
要更改其端口和/或地址,将以下内容放入文件中。在该路径中创建尚不存在的文件和目录。该ListenStream 选项指定所需的地址和 TCP 端口
注意:第一行的空值是故意的。systemd允许Listen在单个套接字单元中声明多个指令;插入文件中的空值会重置列表,从而禁用原始设备的默认端口 9090
vim /etc/systemd/system/cockpit.socket.d/listen.conf [Socket] ListenStream= ListenStream=443 systemctl daemon-reload systemctl restart cockpit.socket
设置 cockpit 接管网络配置
编辑文件网络配置文件,注销掉里面所有内容
vim /etc/network/interfaces # This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # source /etc/network/interfaces.d/* # The loopback network interface # auto lo # iface lo inet loopback # The primary network interface # allow-hotplug enp1s0 # iface enp1s0 inet dhcp
登录 【Cockpit】-【网络】-【接口】- 【enp3s0 】(你网络接口名称)-IPV4-编辑-手动,输入你要设置的IP地址及默认网关。
交换空间优化
Debian默认是当内存使用达到**40%就向交换空间写入数据,这样会大大的降低电脑运行效率,将它改为10%**再向交换空间写入数据。打开 /etc/sysctl.conf 文件修改内容
vim /etc/sysctl.conf vm.swappiness=10 vm.vfs_cache_pressure=50 sysctl -p
- vm.swappiness 是用来控制内核在什么时候开始使用交换空间的参数,默认值是 60。将该值调整为 10 表示让内存使用率达到 90% 时才开始使用交换空间。
- vm.vfs_cache_pressure 是用来控制内核清理缓存的频率的参数,默认值是 100。将该值调整为 50 表示内核会更倾向于清理文件系统缓存以回收内存。
安装 Tuned 系统调优工具
Tuned(又称为tuned-adm)是一个系统调优工具,旨在帮助优化系统的性能和功耗。它允许管理员根据系统的需求选择不同的预定义配置文件或自定义配置文件,以提供最佳的性能和功耗平衡。
apt update && sudo apt install tuned
- systemctl start tuned:启动Tuned服务。
- systemctl stop tuned:停止Tuned服务。
- systemctl restart tuned:重启Tuned服务。
- systemctl status tuned:查看Tuned服务的运行状态。
- systemctl stop tuned:停止Tuned服务。
- systemctl disable tuned:禁止Tuned服务开机启动。
- tuned-adm list:列出所有可用的Tuned配置文件。
- tuned-adm active:查看当前活动的Tuned配置文件。
- tuned-adm recommend:根据系统的硬件配置和工作负载推荐一个最佳的Tuned配置文件。
常用TuneD 配置集
1、throughput-performance。针对高吞吐量优化的服务器配置文件。它禁用节能机制并启用 sysctl 设置,以提高磁盘和网络 IO 的吞吐量性能。CPU 调控器设置为 performance。它将 energy_performance_preference 和 scaling_governor 属性设置为 performance 配置集。
2、accelerator-performance。accelerator-performance 配置集包含与 throughput-performance 配置集相同的调整。另外,它会将 CPU 锁定为低 C 状态,以便使延迟小于 100us。这提高了某些加速器的性能,如 GPU。
3、network-throughput。用于吞吐量网络调优的配置集。它基于 throughput-performance 配置集。此外,它还增加了内核网络缓冲区。它继承 latency-performance 或 throughput-performance 配置集,并将energy_performance_preference 和 scaling_governor 属性改为 performance 配置集。
4、Balanced。默认的节能配置文件。它在性能和功耗之间具有折衷。在可能的情况下尽可能使用自动扩展和自动调整。唯一缺陷是增加延迟。在当前的 TuneD 版本中,它启用了 CPU、磁盘、音频和视频插件,并激活了 conservative CPU 调控器。如果支持,radeon_powersave 选项使用 dpm-balanced 值,否则被设置为 auto。它将 energy_performance_preference 属性改为 normal 能源设置。它还将 scaling_governor 策略属性改为 conservative 或 powersave CPU 调控器。
5、powersave。用于最大节能性能的配置集。它可以对性能进行调整,从而最大程度降低实际功耗。在当前的 TuneD 发行版本中,它为 SATA 主机适配器启用 USB 自动挂起、WiFi 节能和 Aggresive Link Power Management (ALPM) 节能。它还为使用低折率的系统调度多核功耗,并激活 ondemand 监管器。它启用了 AC97 音频节能,或根据您的系统,HDA-Intel 节能时间为 10 秒。如果您的系统包含启用了 KMS 支持的 Radeon 图形卡,配置集会将其配置为自动节能。在 ASUS Eee PC 上,启用了动态超级混合引擎。它将 energy_performance_preference 属性改为 powersave 或 power energy 设置。它还会将 scaling_governor 策略属性更改为 ondemand 或 powersave CPU 调控器。
参考:CentOS7 配置
Cockpit 支持 CentOS 7以及之后的版本
#安装cockpit: sudo yum install cockpit #启动 cockpit: sudo systemctl enable --now cockpit.socket #打开防火墙(非必须): sudo firewall-cmd --permanent --zone=public --add-service=cockpit sudo firewall-cmd --reload
https://docs.qq.com/doc/p/ac7a498302fca24ec7f0d002820ee32eceb03c13
- 无标签