StorCLI 的使用

Linux [[RAID]] StorCLI 的使用 目前 LSI RAID 卡使用的配置工作主要有:Megaraid Storage Manager(MSM,图形环境)、MegaCLI(字符界面)、StorCLI(字符界面)。其中 StorCLI 整合了 LSI 和原来 3ware 的产品支持,相对 MegaCLI 命令更加简洁,并且兼容 MegaCLI 的命令,估计不久的将来两者会统一。 StorCLI 在命令行的直接输出更直观,适合直接观看,不适合解析,好在有个特性,在结尾加上 J 可以获得 json 格式输出。 安装 登录BROADCOM网站上RAID卡的页面。 在 “DOWNLOADS” 页签中单击 “Management Software and Tools”。 打开管理软件和工具列表。 下载最新版本的 “MegaRAID Storcli” 工具。 解压后得到适用于不同操作系统的工具包。 rpm -ivh StorCLIxxx.rpm 使用 rpm 命令安装完成后,64 位系统命令的绝对路径为:/opt/MegaRAID/storcli/storcli64,32 位系统命令的绝对路径为:/opt/MegaRAID/storcli/storcli。 在测试的机器 xxx.x 上和 xxx.y 上都已经有了该工具,且版本为 Ver 1.23.02 Mar 28, 2017。 测试过程及基础说明 ip raid卡型号 芯片组 StorCLI能否使用 megacli能否使用 xx.xx.xxx.x PERC H730P Adapter SAS 3108 不能 可以 xx.xx.xxx.y AVAGO MR9361-8i UNKNOWN 可以 可以 有上述表格内容,可以看出,StorCLI 虽然是后起之秀,但在某些卡上,megacli 却能够输出结果。(通过对 Dell PowerEdge RAID Controller H730P的查看,简单的猜测 dell 定制的卡,无法被 storcli 管理)。在该文章中提到「Dell的产品 用PERC Cli」。即How to use the PowerEdge RAID Controller (PERC) Command Line Interface (CLI) utility to manage your RAID controller。 ...

storcli 的进阶使用

Linux RAID storcli 的进阶使用 基础信息 查看磁盘管理基础信息 $ storcli64 show Status Code = 0 Status = Success Description = None Number of Controllers = 1 Host Name = amd7302asus Operating System = Linux4.15.0-55-generic System Overview : =============== ------------------------------------------------------------------------------------- Ctl Model Ports PDs DGs DNOpt VDs VNOpt BBU sPR DS EHS ASOs Hlth ------------------------------------------------------------------------------------- 0 LSIMegaRAIDSAS9270CV-8i 8 24 1 0 1 0 Msng On 1&2 Y 4 Opt ------------------------------------------------------------------------------------- 从上述结果分析,有一块型号为 LSIMegaRAIDSAS9270CV-8i 的 RAID 卡。它是 8 通道的,挂载了 24 块物理盘,有 1 个磁盘组(DG),有 1 个虚拟磁盘(VD),没有电池。 ...

systemd service 配置 ulimit 限制

Linux systemd service 配置 ulimit 限制 在 bash 中,有个 ulimit 命令,提供了对 shell 及该 shell 启动的进程的可用资源控制。主要包括打开文件描述符数量、用户的最大进程数量、coredump 文件的大小等。 在 CentOS 5/6 等版本中,资源限制的配置可以在 /etc/security/limits.conf 设置,针对 root/user 等各个用户或者 * 代表所有用户来设置。 当然,/etc/security/limits.d/ 中可以配置,系统是先加载 limits.conf 然后按照英文字母顺序加载 limits.d 目录下的配置文件,后加载配置覆盖之前的配置。 一个配置示例如下: soft nofile 100000 * hard nofile 100000 * soft nproc 100000 * hard nproc 100000 * soft core 100000 * hard core 100000 不过,在 CentOS 7 or RHEL 7 的系统中,使用 Systemd 替代了之前的 SysV,因此 /etc/security/limits.conf 文件的配置作用域缩小了一些。limits.conf 这里的配置,只适用于通过 PAM 认证登录用户的资源限制,它对 systemd 的 service 的资源限制不生效。登录用户的限制,与上面讲的一样,通过 /etc/security/limits.conf 和 limits.d 来配置即可。 对于systemd service的资源限制,如何配置呢? ...

systemd 的使用

Linux systemd 的使用 systemd 是一个庞大的系统,在这篇里,专注于 systemd 在 service,target 以及日志系统的使用。 service service 的书写 配置文件放在 /usr/lib/systemd/system/ 或者 /lib/systemd/system/ 中,以 .service 结尾。Systemd 默认从目录 /etc/systemd/system/ 读取配置文件,但是,里面存放的大部分文件都是符号链接。 # 配置文件大概格式 [Unit] Description=ATD daemon [Service] Type=forking ExecStart=/usr/bin/atd [Install] WantedBy=multi-user.target 配置文件是由 ini 格式书写的,按照几个大的区块来写,Unit 是该模块基础信息,Service 是 service 型 Unit 专属,Install 附加信息。 [Unit]区块通常是配置文件的第一个区块,用来定义 Unit 的元数据,以及配置与其他 Unit 的关系。它的主要字段如下。 - Description:简短描述 - Documentation:文档地址 - Requires:当前 Unit 依赖的其他 Unit,如果它们没有运行,当前 Unit 会启动失败 - Wants:与当前 Unit 配合的其他 Unit,如果它们没有运行,当前 Unit 不会启动失败 - BindsTo:与Requires类似,它指定的 Unit 如果退出,会导致当前 Unit 停止运行 - Before:如果该字段指定的 Unit 也要启动,那么必须在当前 Unit 之后启动 - After:如果该字段指定的 Unit 也要启动,那么必须在当前 Unit 之前启动 - Conflicts:这里指定的 Unit 不能与当前 Unit 同时运行 - Condition...:当前 Unit 运行必须满足的条件,否则不会运行 - Assert...:当前 Unit 运行必须满足的条件,否则会报启动失败 [Install]通常是配置文件的最后一个区块,用来定义如何启动,以及是否开机启动。它的主要字段如下。 - WantedBy:它的值是一个或多个 Target,当前 Unit 激活时(enable)符号链接会放入/etc/systemd/system目录下面以 Target 名 + .wants后缀构成的子目录中。一般挂载为 multi-user.target。 - RequiredBy:它的值是一个或多个 Target,当前 Unit 激活时,符号链接会放入/etc/systemd/system目录下面以 Target 名 + .required后缀构成的子目录中 - Alias:当前 Unit 可用于启动的别名 - Also:当前 Unit 激活(enable)时,会被同时激活的其他 Unit [Service]区块用来 Service 的配置,只有 Service 类型的 Unit 才有这个区块。它的主要字段如下。 - Type:定义启动时的进程行为。它有以下几种值。 - Type=simple:默认值,执行ExecStart指定的命令,启动主进程 - Type=forking:以 fork 方式从父进程创建子进程,创建后父进程会立即退出 - Type=oneshot:一次性进程,Systemd 会等当前服务退出,再继续往下执行 - Type=dbus:当前服务通过D-Bus启动 - Type=notify:当前服务启动完毕,会通知Systemd,再继续往下执行 - Type=idle:若有其他任务执行完毕,当前服务才会运行 - ExecStart:启动当前服务的命令 - ExecStartPre:启动当前服务之前执行的命令 - ExecStartPost:启动当前服务之后执行的命令 - ExecReload:重启当前服务时执行的命令 - ExecStop:停止当前服务时执行的命令 - ExecStopPost:停止当其服务之后执行的命令 - RestartSec:自动重启当前服务间隔的秒数 - Restart:定义何种情况 Systemd 会自动重启当前服务,可能的值包括always(总是重启)、on-success、on-failure、on-abnormal、on-abort、on-watchdog - TimeoutSec:定义 Systemd 停止当前服务之前等待的秒数 - Environment:指定环境变量 service 的管理 # 查看系统所有安装的服务项 systemctl list-unit-files --type=service # 查看系统所有运行的服务项 systemctl list-units --type=service # 查看系统所有开机自启动的服务项 systemctl list-unit-files --type=service | grep enabled # 查看指定服务项状态 systemctl status <服务项名称> # 查看服务项的依赖关系 systemctl list-dependencies <服务项名称> # 查看出错的服务 systemctl list-units --type=service --state=failed # 清除服务项的错误状态 systemctl reset-failed <服务项名称> # 查看系统启动耗时 systemd-analyze # 查看各项服务启动耗时 systemd-analyze blame | grep .service # 启动服务 systemctl start <服务项名称> # 停止服务 systemctl stop <服务项名称> # 重启服务 systemctl restart <服务项名称> # 重新读取配置文件 systemctl reload <服务项名称> # 使服务开机自启动 ## 需要配置 install systemctl enable <服务项名称> # 使服务不要开机自启动 systemctl disable <服务项名称> # 禁用服务 systemctl mask <服务项名称> # 启用服务 systemctl unmask <服务项名称> # 重新读取所有服务项 systemctl daemon-reload # 服务状态 enabled:已建立启动链接 disabled:没建立启动链接 static:该配置文件没有[Install]部分(无法执行),只能作为其他配置文件的依赖 masked:该配置文件被禁止建立启动链接 target Target 就是一个 Unit 组,包含许多相关的 Unit 。启动某个 Target 的时候,Systemd 就会启动里面所有的 Unit。从这个意义上说,Target 这个概念类似于"状态点",启动某个 Target 就好比启动到某种状态。 ...

Ubuntu 18.4 通用配置脚本

Linux Ubuntu Ubuntu 18.4 通用配置脚本 配置 ip 先决条件:网口名为 eno1 且为联通状态,若不是,请手动修改。 #! /bin/bash # config_ip.sh # sh config_ip.sh eno1 192.168.1.xxx 192.168.1.1 mv /etc/netplan /etc/netplan.bk mkdir -p /etc/netplan/ touch /etc/netplan/01-netcfg.yaml cat > /etc/netplan/01-netcfg.yaml<<EOF # This file describes the network interfaces available on your system # For more information, see netplan(5). network: version: 2 renderer: networkd ethernets: $1: addresses: [$2/24] gateway4: $3 nameservers: addresses: - "$3" EOF cat /etc/netplan/01-netcfg.yaml echo 'Finish!' netplan apply if [ $? -eq 0] then echo 'Apply Success!' else echo 'Apply Failure!' fi 配置 DNS #! /bin/bash # config_dns.sh # sh config_dns.sh 192.168.1.x mv /etc/systemd/resolved.conf /etc/systemd/resolved.conf.bk cat > /etc/systemd/resolved.conf <<EOF [Resolve] DNS=$1 #FallbackDNS= #Domains= #LLMNR=no #MulticastDNS=no #DNSSEC=no #Cache=yes #DNSStubListener=yes EOF 配置源 #! /bin/bash # config_source.sh # sh config_source.sh mv /etc/apt/sources.list /etc/apt/sources.list.bk cat > /etc/apt/sources.list <<EOF # tsinghua deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse deb https://packages.grafana.com/oss/deb stable main deb-src https://packages.grafana.com/oss/deb stable main deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse # aliyun deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse # ubuntu deb http://archive.ubuntu.com/ubuntu/ trusty main restricted universe multiverse deb http://archive.ubuntu.com/ubuntu/ trusty-security main restricted universe multiverse deb http://archive.ubuntu.com/ubuntu/ trusty-updates main restricted universe multiverse deb http://archive.ubuntu.com/ubuntu/ trusty-proposed main restricted universe multiverse deb http://archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse EOF apt-get update 配置集群免密登陆 生成默认密钥对 ssh-keygen -t rsa -C "default_key@default.namespace" ls ~/.ssh/ 获取认证文件 ssh-copy-id -i ~/.ssh/id_rsa xxx@xxx 通过生成的密钥通过 ssh-copy-id 指定一台机器,那么那台机器的 ~/.ssh/authorized_keys 就会更新,录入一条新的数据。 ...

Ubuntu 使用光纤设备遇到的问题

Linux Ubuntu Network Ubuntu 使用光纤设备遇到的问题 已有的设备: 一台全新的带有光口的交换机 普通服务器(无光模块) 不知生产日期的 8Gb/s 的光网卡 不知生产日期的 8Gb/s 的光模块 几根 LC-LC 光纤线 该接的线都接了,连上机器发现根本没识别网卡,光模块上的三个灯一直闪烁,我寻思👴没用过光纤,这到底该怎么排查呢。根据这篇文档进行操作。 识别 HBA 卡 # lspci | grep -i ql <== 由于lspci显示连接的pci设备过多,通过grep查找 82:01.0 Ethernet controller: QLogic Corp. ISP4032-based Ethernet IPv6 NIC 82:01.1 Network controller: QLogic Corp. ISP4032-based iSCSI TOE IPv6 HBA 查看是否有驱动 # lsmod | grep -i ql qla2xxx 260462 0 iscsi_boot_sysfs 16000 1 qla2xxx libiscsi 57278 4 qla2xxx,libiscsi_tcp,iscsi_tcp,ib_iser scsi_transport_iscsi 89279 5 qla2xxx,iscsi_tcp,ib_iser,libiscsi 驱动可能有点老,但毕竟也加载了。 查看使用信息 祭出 dmesg。 $ dmesg | grep -i ql xxxxxx xxxxxx xxxxxxx cable unplugged 电缆不通电?继续查,都是说线没插好或者驱动有问题。重新安装驱动再重启网络服务,无效。 ...

Ubuntu 修改时区和更新时间

Linux Ubuntu Ubuntu 修改时区和更新时间 修改时区 先查看当前系统时区。 root@ubuntu:/# date -R Wed, 06 May 2020 04:49:31 -0400 结果时区是:-0400 我需要的是东八区,这儿显示不是,所以需要设置一个时区。 # 运行tzselect root@ubuntu:/# tzselect # 选择亚洲 Asia,确认之后选择中国(China),最后选择北京(Beijing) Please identify a location so that time zone rules can be set correctly. Please select a continent, ocean, "coord", or "TZ". 1) Africa 2) Americas 3) Antarctica 4) Asia 5) Atlantic Ocean 6) Australia 7) Europe 8) Indian Ocean 9) Pacific Ocean 10) coord - I want to use geographical coordinates. 11) TZ - I want to specify the time zone using the Posix TZ format. #? 4 Please select a country whose clocks agree with yours. 1) Afghanistan 18) Israel 35) Palestine 2) Armenia 19) Japan 36) Philippines 3) Azerbaijan 20) Jordan 37) Qatar 4) Bahrain 21) Kazakhstan 38) Russia 5) Bangladesh 22) Korea (North) 39) Saudi Arabia 6) Bhutan 23) Korea (South) 40) Singapore 7) Brunei 24) Kuwait 41) Sri Lanka 8) Cambodia 25) Kyrgyzstan 42) Syria 9) China 26) Laos 43) Taiwan 10) Cyprus 27) Lebanon 44) Tajikistan 11) East Timor 28) Macau 45) Thailand 12) Georgia 29) Malaysia 46) Turkmenistan 13) Hong Kong 30) Mongolia 47) United Arab Emirates 14) India 31) Myanmar (Burma) 48) Uzbekistan 15) Indonesia 32) Nepal 49) Vietnam 16) Iran 33) Oman 50) Yemen 17) Iraq 34) Pakistan #? 9 Please select one of the following time zone regions. 1) Beijing Time 2) Xinjiang Time #? 1 The following information has been given: China Beijing Time Therefore TZ='Asia/Shanghai' will be used. Selected time is now: Wed May 6 16:49:49 CST 2020. Universal Time is now: Wed May 6 08:49:49 UTC 2020. Is the above information OK? 1) Yes 2) No #? 1 You can make this change permanent for yourself by appending the line TZ='Asia/Shanghai'; export TZ to the file '.profile' in your home directory; then log out and log in again. Here is that TZ value again, this time on standard output so that you can use the /usr/bin/tzselect command in shell scripts: Asia/Shanghai 复制文件到 /etc 目录下。 ...

Ubuntu 安装 ftp 服务

Linux Ubuntu Network Ubuntu 安装 ftp 服务 这是一个很简单的需求,相关的博文也相当多,安装的过程非常简单,但是配置相关的说明有些分散。 主要几步: 可选:创建目录 安装服务 写配置文件 访问服务 最麻烦的在于 写配置文件,ftp 通过文本格式的配置文件实现了权限管理,用户管理,目录管理和网络管理。 安装服务 $ apt-get install vsftpd vsftpd 意思为 “very secure FTP daemon(非常安全的FTP进程)”,当然只有更安全没有最安全。 那它到底安全在哪里呢,主要体现在以下两点: 权限控制,vsftpd 以一般用户登录,用户权限相对较小,对于系统就越安全,对于用户需要的系统级指令大部分被整合到 vsftpd 中了,用户不需要申请更高权限就足以完成绝大部分 ftp 指令;此外对于 ftp 本身内部的读写控制,vsftpd 也足以通过配置文件控制了; 目录限制,vsftpd 通过 chroot 可以控制 ftp 登录用户所能看到的目录范围,即限定 ftp 用户看到的根目录为系统中某一个目录,如此一个 ftp 用户就除了看到自己的 ftp 根目录不能看到其他比如配置文件、系统更目录等,保护了系统。 写配置文件 从安全的角度来看,尽量不要启用匿名;同时尽量使用一个统一的目录,方便管理(这样的考虑是因为将 ftp 作为一个统一的文件传输管理系统,如果每个用户单独目录就很难提到共享这个概念)。 还有个 主动模式/被动模式 的区别,具体的区别可以参考 Ubuntu 14.04 配置vsftpd实现FTP服务器 - 通过FTP连接AWS 的第 2 章。我的需求是使用被动模式。 从上述所说,重要的配置如下: anonymous_enable=NO # 不允许匿名用户登录 local_enable=YES # 允许本地用户组的用户登录 write_enable=YES # 允许本地用户上传文件 local_root = /home/xxxx/ftp # 本地用户登入时,将被切换到定义的目录下,默认值为各用户的家目录,通过这个指定目录,该目录需要手动创建 #使用被动模式 pasv_enable=YES pasv_min_port=1024 pasv_max_port=1048 pasv_address=你的访问IP(服务器外网IP) 更多的配置信息可以参考文末的参考链接前两项。 ...

Ubuntu 搭建 Gitlab

Linux Ubuntu [[GitLab]] Ubuntu 搭建 Gitlab 准备工作 $ sudo apt-get install ruby vim curl openssh-server ca-certificates $ gem sources --add https://mirrors.tuna.tsinghua.edu.cn/rubygems/ --remove https://rubygems.org/ $ bundle config mirror.https://rubygems.org https://mirrors.tuna.tsinghua.edu.cn/rubygems 安装 Gitlab Gitlab 官网找到的下载链接都是 30 天适用的企业版本,其实把 gitlab-ee 改成 gitlab-ce 即可。 curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.deb.sh | sudo bash # GitLab: 13.0.1 (74623c80da9) FOSS # GitLab Shell: 13.2.0 # PostgreSQL: 11.7 sudo apt-get install gitlab-ce 后面就通过浏览器访问,配置自定义项目。 关于公钥密钥数据传输,这里掠过不谈。 备份数据 # 会自动在 /var/opt/gitlab/backups 目录下生成一个备份文件 gitlab-rake gitlab:backup:create # 修改备份地址 vi /etc/gitlab/gitlab.rb ... gitlab_rails['backup_path'] = "/var/opt/gitlab/backups" ... vi /etc/crontab # 添加定时任务,每天凌晨两点,执行 gitlab 备份 0 2 * * * root /opt/gitlab/bin/gitlab-rake gitlab:backup:create CRON=1 恢复数据 确认新老机器的gitlab服务版本一致。 ...

Ubuntu 系统启动页面配置网络慢

Linux Ubuntu Network Ubuntu 系统启动页面配置网络慢 开机过程中会出现, [...]a start job is running for wait for network to be configured...[1 min 3 sec / no limit] 一般需要等待两到三分钟。这是因为一直无法配置,一般网口会通过 DHCP 或者其他协议自动获取配置,但是如果配置文件就没写相关信息,或者系统里的网卡其实是虚拟网卡,就无法自动获取,卡到最后还会报个错。 解决的思路主要有两个,一个是将 systemd-networkd-wait-online.service 服务停掉;一个是配置文件里改成 optional: true。 方案一 sudo systemctl mask systemd-networkd-wait-online.service 方案二 $ networkctl IDX LINK TYPE OPERATIONAL SETUP 1 lo loopback carrier unmanaged 2 enp96s0f0 ether no-carrier configuring 3 enp96s0f1 ether routable configured 3 links listed. # 看到 enp96s0f0 无法配置,那么就在配置文件里帮它配置上 $ vi /etc/netplan/01-netcfg.yaml # This file describes the network interfaces available on your system # For more information, see netplan(5). network: version: 2 renderer: networkd ethernets: enp96s0f0: # device name optional: true # 加上这行 enp96s0f1: addresses: [ 192.168.1.100/24 ] gateway4: 192.168.1.1 nameservers: addresses: - "192.168.1.1" $ sudo netplan generate && sudo netplan apply