Linux : 使用 web 面板管理服务器

发布时间:2022-06-27    浏览量:

Cockpit 介绍
基于web的Linux集成管理平台,项目地址: https://cockpit-project.org

能够让用户使用鼠标简单的配置系统(启动容器、kvm虚拟机; 配置网络(修改IP)、防火墙、存储; 管理服务、日志)

特性(Feature)

1.支持主流发行版(Redhat、Debian),且无需自己配置 web 服务; 可扩展,支持各种插件模块功能

2.友好的界面,易于使用,并提供 web CLI

3.使用系统账户登录,未使用时不会增加负载

4.完全免费,Dashboard可统计多台服务器的系统状态,一目了然

安装 cockpit(感兴趣的同学,应 7.0 和 8.0 都安装,并对比差异)

简单粗暴的安装方法(这样会把所有插件都一起安装):

[root@localhost ~]# yum install cockpit*
[root@localhost ~]# systemcl enable --now cockpit.socke


比较讲究点的做法(只装需要的)

[root@localhost ~]# yum install cockpit
[root@localhost ~]# yum install cockpit-pcp cockpit-storaged cockpit-docker cockpit-dashboar

cockpit 默认运行在 9090 端口(8.0默认放行该端口),使用浏览器访问 http://你的IP地址:9090

Cockpit dashboard 仪表盘

尝试将多台 cockpit 机器加入到 dashboard 进行统一监控与管理,类似于简洁版 grafana 的监控效果

仅监控服务器重要的4个指标(CPU、内存、网络、磁盘IO),并且数据没有特别详细


Cockpit container 容器面板(7.0 是 docker; 8.0 是 podman)

尝试使用 docker 部署(不重要,主要是大概了解下容器部署的套路,不同的应用有不同的部署步骤,主要靠查询文档,并不是学会部署容器就天下无敌):

  • speedtest 内网测速

  • wordpress 个人博客

  • nextcloud 企业云盘

  • calibre-web 图书管理系统(默认用户名/密码: admin/admin123)


Cockpit Diagnostic Reports 诊断报告

前置条件: 系统中需要安装 sos 软件包,该软件包提供了一个 sosreport 命令用于收集系统中的各种信息并保存到一个压缩包内;

通常是客户遇到了问题,但是无法远程协助且客户无法描述清楚故障现象("趋利避害的描述更可怕,迷惑技术人员"),可以让客户协助生成诊断报告,运维人员根据报告内容进行故障排查


sosreport 的常用选项

[root@localhost ~]# man sosreport
SOSREPORT(1) General Commands Manual SOSREPORT(1)
NAME
sosreport - Collect and package diagnostic and support data
SYNOPSIS
sosreport
[-l|--list-plugins] # 列出所有插件
[-n|--skip-plugins plugin-names] # 不启用,跳过指定插件
[-e|--enable-plugins plugin-names] # 启用指定插件
[-o|--only-plugins plugin-names] # 只启用特定插件
[-a|--alloptions] [-v|--verbose]
[-k plug.opt|--plugin-option plug.opt] # 启用插件中的某个选项


sosreport 插件

用于收集不同的应用程序,使用 sosreport -l 命令查看所有的插件;

默认情况下,我们无需配置任何插件, sosreport 默认会根据系统中存在的应用程序来自行选择插件


生成 sosreport 诊断报告

直接执行 sosreport 命令即可生成:

[root@localhost ~]# sosreport
...... 省略大量输出内容 ......
Your sosreport has been generated and saved in:
/var/tmp/sosreport-localhost-2022-04-17-mlxcwka.tar.xz
001_RHCSA
2022/4/15 0:18
陈健
Size 9.77MiB
Owner root
md5 8d8f25c40ad635325622ef5d2d272acf
Please send this file to your support representative.
[root@localhost ~]#


通过命令行或网页来检查 sosreport 报告

命令行方式:

1.解压该压缩包

2.进入报告目录下,使用 cat、vim 命令查看各个指标文件或命令输出文件


网页方式:

1.解压该压缩包

2.进入报告目录下,找到 sos_reports 目录, 该目录下有一个 sos.html 文件,使用浏览器打开该文件,在 web 上更方便分析


使用第三方工具 xsos 分析 sosreport 报告(推荐,配合 web 方式一起使用; xsos 能快速展示出机器的配置)

项目地址: https://github.com/ryran/xsos 该工具能够通过 sosreport 文件来总结信息

下载该工具:

[root@localhost ~]# yum -y install git
[root@localhost ~]# git clone https://github.com/ryran/xsos

*注: 如果由于网络原因导致 git clone 拉不下来, 可以直接访问该网站,然后直接下载 zip 包即可


配置 xsos

[root@localhost ~]# cd xsos-master/
[root@localhost xsos-master]# ls
CONTRIB.md README.md xsos xsos-bash-completion.bash
[root@localhost xsos-master]#

里面有2个文件,一个是 xsos 可执行文件,另外一个是 xsos-bash-completion.bash 命令补全文件

我们需要将 xsos 移动到 /usr/local/bin 下, 将 xsos-bash-completion.bash 移动到 /etc/profile.d/ 目录下

[root@localhost xsos-master]# cp xsos /usr/local/bin
[root@localhost xsos-master]# cp xsos-bash-completion.bash /etc/profile.d/
[root@localhost xsos-master]# source /etc/profile.d/xsos-bash-completion.bash


xsos 的使用方式:

直接生成本机的所有信息

[root@localhost ~]# xsos --all


分析 sosreport 文件,注意参数是目录,不是压缩包,所以要先解压

[root@localhost ~]# tar -xvf /var/tmp/sosreport-xxx-xxxx
[root@localhost ~]# xsos --all /var/tmp/sosreport-xxx-xxxx



微思网络总部
福建省厦门市思明区金山大厦
查看路线
微思网络集美分部
福建省厦门市集美区集美区浒...
查看路线
定位
点击左侧的按钮进行定位