ipxe autoinstall debian12.4 配置文件 目录结构 使用镜像源 mount -o loop /root/debian-12.4.0-amd64-DVD-1.iso /var/www/html/debian/ initrd.gz、linux # /var/www/html [root@localhost html]# tree -L 2 . ├── debian ├── ipxe │ ├── boot.ipxe │ ├── initrd.gz │ ├── ipxe.efi │ ├── linux │ └── undionly.kpxe └── preseed.cfg initrd.gz 改动 添加 scsi-modules https://mirrors.tuna.tsinghua.edu.cn/debian/pool/main/l/linux-signed-amd64/scsi-modules-6.1.0-15-amd64-di_6.1.69-1_amd64.udeb 修改 /usr/share/debconf/confmodule # 第四行添加 忽略源gpg报错 [ -f /usr/lib/apt-setup/generators/50mirror ] && \ sed -i 's/trusted=""/trusted="[trusted=yes] "/g' /usr/lib/apt-setup/generators/50mirror boot.ipxe #!ipxe kernel http://192.168.1.11/ipxe/linux vga=788 auto=true priority=critical preseed/url=http://192.168.1.11/preseed.cfg initrd http://192.168.1.11/ipxe/initrd.gz boot preseed.cfg ### 本地化 # 语言 d-i debian-installer/locale string en_US ### 键盘 d-i keyboard-configuration/xkb-keymap select us ### 网络 d-i netcfg/choose_interface select auto d-i netcfg/enable boolean true ### Mirror d-i mirror/country string manual d-i mirror/http/hostname string 192.168.1.11 d-i mirror/http/directory string /debian d-i mirror/http/proxy string ### Account setup d-i passwd/root-login boolean false d-i passwd/user-fullname string user d-i passwd/username string user d-i passwd/user-password password 123 d-i passwd/user-password-again password 123 ### 时区 d-i clock-setup/utc boolean true d-i time/zone string Asia/Shanghai d-i clock-setup/ntp boolean true ### 分区 d-i partman-auto/disk string /dev/sda d-i partman-auto/method string regular d-i partman-lvm/device_remove_lvm boolean true d-i partman-md/device_remove_md boolean true d-i partman-auto/choose_recipe select atomic d-i partman-partitioning/confirm_write_new_label boolean true d-i partman/choose_partition select finish d-i partman/confirm boolean true d-i partman/confirm_nooverwrite boolean true ### Apt setup d-i apt-setup/non-free boolean false d-i apt-setup/contrib boolean false d-i apt-setup/services-select multiselect main d-i debian-installer/allow_unauthenticated boolean true ### Package selection tasksel tasksel/first multiselect standard cinnamon-desktop # 选择桌面环境 d-i pkgsel/upgrade select none d-i pkgsel/language-packs multiselect en, zh d-i pkgsel/update-policy select none # d-i pkgsel/include string nano ### Boot loader installation d-i grub-installer/only_debian boolean true d-i grub-installer/bootdev string default ### Finishing up the installation d-i finish-install/keep-consoles boolean true dnsmasq 安装 yum install -y dnsmasq httpd 配置 dnsmasq.conf [root@localhost html]# grep -Ev '^#|^$' /etc/dnsmasq.conf conf-dir=/etc/dnsmasq.d,.rpmnew,.rpmsave,.rpmorig bind-interfaces dhcp-range=192.168.1.200,192.168.1.250,255.255.255.0,8h dhcp-option=option:router,192.168.1.2 dhcp-option=option:dns-server,223.5.5.5,223.6.6.6 enable-tftp tftp-root=/var/www/html/ipxe dhcp-match=set:bios,option:client-arch,0 dhcp-match=set:ipxe,175 dhcp-boot=tag:!ipxe,tag:bios,undionly.kpxe dhcp-boot=tag:!ipxe,tag:!bios,ipxe.efi dhcp-boot=tag:ipxe,boot.ipxe httpd rm /etc/httpd/conf.d/welcome.conf 添加配置文件 1. 上传 ipxe-debian12.4.tar.xz 2. 解压 tar xf ipxe-debian12.4.tar.xz -C /var/www/html 3. 修改 ip [root@localhost html]# grep -r 192.168.1.11 . ./ipxe/boot.ipxe:kernel http://192.168.1.11/ipxe/linux vga=788 auto=true priority=critical preseed/url=http://192.168.1.11/preseed.cfg ./ipxe/boot.ipxe:initrd http://192.168.1.11/ipxe/initrd.gz ./preseed.cfg:d-i mirror/http/hostname string 192.168.1.11 启动 systemctl start httpd systemctl start dnsmasq
makeself.sh 1. 安装 [root@thinkpad-e490 ~]# wget https://github.com/megastep/makeself/archive/refs/tags/release-2.4.5.zip [root@thinkpad-e490 ~]# unzip release-2.4.5.zip [root@thinkpad-e490 ~]# ls makeself-release-2.4.5 COPYING make-release.sh makeself-2.4.5 makeself.lsm README.md run-tests.sh VERSION Makefile makeself.1 makeself-header.sh makeself.sh release test [root@thinkpad-e490 ~]# cp makeself-release-2.4.5/makeself.sh /usr/bin/ 2. 使用 示例 makeself.sh [args] archive_dir file_name label startup_script [script_args] makeself --nox11 --nowait --bzip2 --base64 update-os/ update-os.run 'update os.' ./install.sh 参数 参数 参数使用说明 --version 打印版本号 --needroot 需要root用户才可以执行 --gzip 默认使用gzip工具进行压缩 --pigz gzip的多线程解决方案 --bzip2 使用bzip2代替gzip进行更好的压缩 --pbzip2 bzip2的多线程解决方案 --xz 使用xz代替gzip进行更好的压缩(远程支持多线程压缩) --zstd 使用zstd代替gzip进行更好的压缩 --threads thds 限制支持多线程解压缩工具所使用的线程数量 --base64 用Base64格式将存档编码为ASCII格式而不进行压缩 --gpg-encrypt 使用gpg -ac -z $COMPRESS_LEVEL加密归档文件，需要输入密码 --ssl-encrypt 使用openssl aes-256-cbc -a -salt加密归档文件，需要输入密码 --ssl-passwd pass 设置openssl加密归档文件需要输入的密码 --compress 使用UNIX系统的compress`命令压缩数据(在没有 gzip 时默认) --nocomp 不对存档文件进行压缩，默认是一个tar包 --complevel lvl 指定压缩级别，默认使用9级别 --notemp 生成的归档文件不会将文件解压缩到临时目录，而解压到当前目录的创建的新目录中 --current 文件将被提取到当前目录，而不是子目录中(同--notemp一样，但会提取没有文件夹) --follow 存储指向的文件而不是链接本身 --append file 将数据追加到现有存档中，而不是创建新文件 --header file 使用指定的脚本来代替默认的makeself-header.sh文件(默认与makeself文件同级) --cleanup file 指定在执行中断或成功完成时运行的脚本 --nomd5/--nocrc 禁止检查存档文件的MD5或CRC校验和 --tar-extra opt 在tar命令行中附加更多选项 --keep-umask 保持umask设置为shell默认值，而不是在执行自解压缩存档时覆盖 --packaging-date date 使用提供的字符串作为打包日期而不是当前日期 --license 附加许可证文件 --nooverwrite 如果指定的目标目录已经存在则不要解压缩存档 --header file 指定头部信息脚本文件的位置，默认为makeself-header.sh文件 --help-header file 在存档的--help输出中添加标题 --export-conf 将配置变量导出到startup_script脚本中 --nox11 禁用 xterm 的自动生成 --nowait 执行后不要等待用户输入 --noprogress 解压期间不显示进度
重新编译 deb TIPS: 使用 src源 对应 os 1、添加 src 源 # 默认注释了源码镜像以提高 apt update 速度，如有需要可自行取消注释 deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware apt-get clean all apt update 2、安装编译环境 apt-get install dpkg-dev devscripts build-essential 3、编译 # 创建 文件夹 mkdir nginx cd nginx # 下载源码包 apt-get source nginx # 修改 源码、编译参数 ... # 提交修改 dpkg-buildpackage commit # 编译 dpkg-buildpackage -us -uc # 清理 dpkg-buildpackage -rfakeroot -Tclean
Arch Linux 1、获取镜像 http://mirrors.163.com/archlinux/iso/latest/ 2、安装前的准备 准备安装介质 启动到 Live 环境 验证引导模式 连接到互联网 更新系统时间 硬盘分区 格式化分区 挂载分区 # 验证引导模式 root@archiso ~ # [ -d /sys/firmware/efi/efivars/ ] && echo "Uefi" || echo "Bios" Uefi 磁盘 Uefi 磁盘分区选 GPT Bios 磁盘分区选 MBR grub 引导 # 获取 IP root@archiso ~ # ip addr | awk '/inet / {print $2}' | grep -v "127.0.0.1/8" 10.52.17.32/24 root@archiso ~ # ping www.baidu.com -c 2 PING www.a.shifen.com (36.152.44.96) 56(84) bytes of data. 64 bytes from 36.152.44.96 (36.152.44.96): icmp_seq=1 ttl=57 time=6.32 ms 64 bytes from 36.152.44.96 (36.152.44.96): icmp_seq=2 ttl=57 time=6.75 ms --- www.a.shifen.com ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 5135ms rtt min/avg/max/mdev = 6.319/6.532/6.745/0.213 ms root@archiso ~ # timedatectl set-timezone Asia/Shanghai root@archiso ~ # timedatectl status Local time: Tue 2023-04-04 13:16:06 CST Universal time: Tue 2023-04-04 05:16:06 UTC RTC time: Tue 2023-04-04 05:16:06 Time zone: Asia/Shanghai (CST, +0800) System clock synchronized: yes NTP service: active RTC in local TZ: no {collapse} {collapse-item label="分区" close} root@archiso ~ # lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS loop0 7:0 0 687.9M 1 loop /run/archiso/airootfs sda 8:0 0 149.1G 0 disk ├─sda1 8:1 0 149G 0 part │ └─ventoy 254:0 0 809.3M 1 dm └─sda2 8:2 0 32M 0 part mmcblk0 179:0 0 115.3G 0 disk ├─mmcblk0p1 179:1 0 500M 0 part ├─mmcblk0p2 179:2 0 2G 0 part └─mmcblk0p3 179:3 0 112.8G 0 part mmcblk0boot0 179:8 0 4M 1 disk mmcblk0boot1 179:16 0 4M 1 disk root@archiso ~ # fdisk /dev/mmcblk0 Welcome to fdisk (util-linux 2.38.1). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Command (m for help): p Disk /dev/mmcblk0: 115.25 GiB, 123748745216 bytes, 241696768 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x4746e965 Device Boot Start End Sectors Size Id Type /dev/mmcblk0p1 2048 1026047 1024000 500M ef EFI (FAT-12/16/32) /dev/mmcblk0p2 1026048 5220351 4194304 2G 82 Linux swap / Solaris /dev/mmcblk0p3 5220352 241696767 236476416 112.8G 83 Linux Command (m for help): d Partition number (1-3, default 3): Partition 3 has been deleted. Command (m for help): d Partition number (1,2, default 2): Partition 2 has been deleted. Command (m for help): d Selected partition 1 Partition 1 has been deleted. Command (m for help): p Disk /dev/mmcblk0: 115.25 GiB, 123748745216 bytes, 241696768 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x4746e965 Command (m for help): n Partition type p primary (0 primary, 0 extended, 4 free) e extended (container for logical partitions) Select (default p): Using default response p. Partition number (1-4, default 1): First sector (2048-241696767, default 2048): Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-241696767, default 241696767): +1G Created a new partition 1 of type 'Linux' and of size 1 GiB. Partition #1 contains a vfat signature. Do you want to remove the signature? [Y]es/[N]o: y The signature will be removed by a write command. Command (m for help): n Partition type p primary (1 primary, 0 extended, 3 free) e extended (container for logical partitions) Select (default p): Using default response p. Partition number (2-4, default 2): First sector (2099200-241696767, default 2099200): Last sector, +/-sectors or +/-size{K,M,G,T,P} (2099200-241696767, default 241696767): +2G Created a new partition 2 of type 'Linux' and of size 2 GiB. Command (m for help): n Partition type p primary (2 primary, 0 extended, 2 free) e extended (container for logical partitions) Select (default p): Using default response p. Partition number (3,4, default 3): First sector (6293504-241696767, default 6293504): Last sector, +/-sectors or +/-size{K,M,G,T,P} (6293504-241696767, default 241696767): Created a new partition 3 of type 'Linux' and of size 112.2 GiB. Command (m for help): p Disk /dev/mmcblk0: 115.25 GiB, 123748745216 bytes, 241696768 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x4746e965 Device Boot Start End Sectors Size Id Type /dev/mmcblk0p1 2048 2099199 2097152 1G 83 Linux /dev/mmcblk0p2 2099200 6293503 4194304 2G 83 Linux /dev/mmcblk0p3 6293504 241696767 235403264 112.2G 83 Linux Filesystem/RAID signature on partition 1 will be wiped. Command (m for help): t Partition number (1-3, default 3): 1 Hex code or alias (type L to list all): L 00 Empty 27 Hidden NTFS Win 82 Linux swap / So c1 DRDOS/sec (FAT- 01 FAT12 39 Plan 9 83 Linux c4 DRDOS/sec (FAT- 02 XENIX root 3c PartitionMagic 84 OS/2 hidden or c6 DRDOS/sec (FAT- 03 XENIX usr 40 Venix 80286 85 Linux extended c7 Syrinx 04 FAT16 <32M 41 PPC PReP Boot 86 NTFS volume set da Non-FS data 05 Extended 42 SFS 87 NTFS volume set db CP/M / CTOS / . 06 FAT16 4d QNX4.x 88 Linux plaintext de Dell Utility 07 HPFS/NTFS/exFAT 4e QNX4.x 2nd part 8e Linux LVM df BootIt 08 AIX 4f QNX4.x 3rd part 93 Amoeba e1 DOS access 09 AIX bootable 50 OnTrack DM 94 Amoeba BBT e3 DOS R/O 0a OS/2 Boot Manag 51 OnTrack DM6 Aux 9f BSD/OS e4 SpeedStor 0b W95 FAT32 52 CP/M a0 IBM Thinkpad hi ea Linux extended 0c W95 FAT32 (LBA) 53 OnTrack DM6 Aux a5 FreeBSD eb BeOS fs 0e W95 FAT16 (LBA) 54 OnTrackDM6 a6 OpenBSD ee GPT 0f W95 Ext'd (LBA) 55 EZ-Drive a7 NeXTSTEP ef EFI (FAT-12/16/ 10 OPUS 56 Golden Bow a8 Darwin UFS f0 Linux/PA-RISC b 11 Hidden FAT12 5c Priam Edisk a9 NetBSD f1 SpeedStor 12 Compaq diagnost 61 SpeedStor ab Darwin boot f4 SpeedStor 14 Hidden FAT16 <3 63 GNU HURD or Sys af HFS / HFS+ f2 DOS secondary 16 Hidden FAT16 64 Novell Netware b7 BSDI fs f8 EBBR protective 17 Hidden HPFS/NTF 65 Novell Netware b8 BSDI swap fb VMware VMFS 18 AST SmartSleep 70 DiskSecure Mult bb Boot Wizard hid fc VMware VMKCORE 1b Hidden W95 FAT3 75 PC/IX bc Acronis FAT32 L fd Linux raid auto 1c Hidden W95 FAT3 80 Old Minix be Solaris boot fe LANstep 1e Hidden W95 FAT1 81 Minix / old Lin bf Solaris ff BBT 24 NEC DOS Aliases: linux - 83 swap - 82 extended - 05 uefi - EF raid - FD lvm - 8E linuxex - 85 Hex code or alias (type L to list all): ef Changed type of partition 'Linux' to 'EFI (FAT-12/16/32)'. Command (m for help): t Partition number (1-3, default 3): 2 Hex code or alias (type L to list all): 82 Changed type of partition 'Linux' to 'Linux swap / Solaris'. Command (m for help): p Disk /dev/mmcblk0: 115.25 GiB, 123748745216 bytes, 241696768 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x4746e965 Device Boot Start End Sectors Size Id Type /dev/mmcblk0p1 2048 2099199 2097152 1G ef EFI (FAT-12/16/32) /dev/mmcblk0p2 2099200 6293503 4194304 2G 82 Linux swap / Solaris /dev/mmcblk0p3 6293504 241696767 235403264 112.2G 83 Linux Filesystem/RAID signature on partition 1 will be wiped. Command (m for help): w The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks. root@archiso ~ # fdisk -l /dev/mmcblk0 Disk /dev/mmcblk0: 115.25 GiB, 123748745216 bytes, 241696768 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x4746e965 Device Boot Start End Sectors Size Id Type /dev/mmcblk0p1 2048 2099199 2097152 1G ef EFI (FAT-12/16/32) /dev/mmcblk0p2 2099200 6293503 4194304 2G 82 Linux swap / Solaris /dev/mmcblk0p3 6293504 241696767 235403264 112.2G 83 Linux root@archiso ~ # mkfs.ext4 /dev/mmcblk0p3 mke2fs 1.47.0 (5-Feb-2023) Discarding device blocks: done Creating filesystem with 29425408 4k blocks and 7356416 inodes Filesystem UUID: c7bfd5b1-7e6b-4ae5-b483-e1b4a2ed2674 Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424, 20480000, 23887872 Allocating group tables: done Writing inode tables: done Creating journal (131072 blocks): done Writing superblocks and filesystem accounting information: done root@archiso ~ # mkswap /dev/mmcblk0p2 Setting up swapspace version 1, size = 2 GiB (2147479552 bytes) no label, UUID=5c75e41d-ee5a-4e2f-9346-eafc20ae1b1a root@archiso ~ # mkfs.fat -F 32 /dev/mmcblk0p1 mkfs.fat 4.2 (2021-01-31) {/collapse-item} {/collapse} root@archiso ~ # mount /dev/mmcblk0p3 /mnt root@archiso ~ # mount --mkdir /dev/mmcblk0p1 /mnt/boot/efi root@archiso ~ # swapon /dev/mmcblk0p2 3、安装 配置镜像源 安装软件包 root@archiso ~ # nano /etc/pacman.d/mirrorlist # 第一行添加 Server = https://mirrors.tuna.tsinghua.edu.cn/archlinux/$repo/os/$arch root@archiso ~ # pacman -Syy :: Synchronizing package databases... core extra 153.9 KiB 719 KiB/s 00:00 [#########################################] 100% community 1746.2 KiB 13.4 MiB/s 00:00 [#########################################] 100% root@archiso ~ # pacman -S archlinux-keyring root@archiso ~ # pacstrap /mnt base base-devel linux-lts linux-firmware linux-lts-headers pacstrap /mnt base base-devel linux-lts linux-firmware linux-lts-headers 48.63s user 29.30s system 85% cpu 1:31.19 total root@archiso ~ # pacstrap /mnt networkmanager dhcpcd openssh vim git grub efibootmgr intel-ucode man-db man-pages ntfs-3g noto-fonts-cjk noto-fonts-emoji 4、安装后的配置 配置 Fstab Chroot 设置时区 设置区域语言 网络配置 & 主机名 root 密码 安装引导程序 重启 root@archiso ~ # genfstab -U /mnt >> /mnt/etc/fstab root@archiso ~ # cat /mnt/etc/fstab # Static information about the filesystems. # See fstab(5) for details. # <file system> <type> <options> <dump> <pass> # /dev/mmcblk0p3 UUID=c7bfd5b1-7e6b-4ae5-b483-e1b4a2ed2674 / ext4 rw,relatime 0 1 # /dev/mmcblk0p1 UUID=4973-14CE /boot vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro 0 2 # /dev/mmcblk0p2 UUID=5c75e41d-ee5a-4e2f-9346-eafc20ae1b1a none swap defaults 0 0 root@archiso ~ # arch-chroot /mnt [root@archiso /]# ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime [root@archiso /]# date Tue Apr 4 14:00:44 CST 2023 [root@archiso /]# hwclock --systohc [root@archiso /]# vim /etc/locale.gen # 171 en_US.UTF-8 UTF-8 # 496 zh_CN.UTF-8 UTF-8 [root@archiso /]# locale-gen Generating locales... en_US.UTF-8... done zh_CN.UTF-8... done Generation complete. [root@archiso /]# echo "Arch" > /etc/hostname [root@archiso /]# passwd New password: Retype new password: passwd: password updated successfully {tabs} {tabs-pane label="Uefi"} [root@archiso /]# grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB Installing for x86_64-efi platform. Installation finished. No error reported. [root@archiso /]# grub-mkconfig -o /boot/grub/grub.cfg {/tabs-pane} {tabs-pane label="Bios"} [root@archiso /]# grub-install # grub-install --target=i386-pc /dev/sda Installing for x86_64-efi platform. Installation finished. No error reported. [root@archiso /]# grub-mkconfig -o /boot/grub/grub.cfg {/tabs-pane} {/tabs} [root@archiso /]# useradd -m acha -G wheel [root@archiso /]# passwd acha New password: Retype new password: passwd: password updated successfully
Kickstart 自动装机 参考： Kickstart Installations :: CentOS Docs Site Kickstart 命令选项 * 示例 #version=DEVEL # System authorization information # 系统 身份验证 auth --enableshadow --passalgo=sha512 # Use CDROM installation media # 使用 光驱 执行安装 cdrom # Use graphical install # 使用 图形化 安装界面 graphical # Run the Setup Agent on first boot # 系统第一次引导时启动 初始化设置 # 设置语言、鼠标、键盘、root 密码、安全级别、时区以及默认网络配置 firstboot --enable --reconfig # 接受最终用户许可证协议 # eula --agreed # 忽略其他盘，指定使用 sda # ignoredisk --only-use=sda # Keyboard layouts # 使用 美式键盘 keyboard --vckeymap=us --xlayouts='us' # System language # 系统 默认语言 lang en_US.UTF-8 # Network information # 网络 信息 # 设置主机名 network --hostname=localhost.localdomain # IP 设置，需指定 device，否则会取消后续所有network指令 # network --bootproto=static --device=ens33 --ip=172.16.1.10 --netmask=255.255.255.0 --gateway=172.16.1.2 --nameserver=8.8.8.8 --ipv6=auto --activate # Root password # root 密码 rootpw --iscrypted $6$CRq8DBBEWuqc6LMC$IsuckHWPV8S3mpq0WfceGChzqA6nNVZZGni5oTgQ/tZisMqOrHlmGHqbZKCZchcmuFEBEF8OVT78qzZTiTrNK. user --name=acha --plaintext --password=q --groups=wheel # System services # 系统 服务 services --enabled="chronyd" # 禁用 firewalld & selinux firewall --disabled selinux --disabled # System timezone # 系统 时间 timezone Asia/Shanghai --utc --ntpservers=ntp.aliyun.com # System bootloader configuration # 启动 引导配置 | grub2-mkpasswd-pbkdf2 设置密码 # bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda --password=grub.pbkdf2.sha512.10000.6CCA5D020DF908F98F2F5DA077E18800D514B85BAAF2376812A62CF772803CB14D0A134DDFFA87E7D6B4509CEA9ADEAFACE98ACCF2028C7830583C51361F1F08.13A6610E8A0FBF7D0CAA7C80B4DEC4C4CC22F8BD8CCC669412A9F028B22F25E38BB8B89879B0A75F60D2D05417E9CCBA057C7AD18A75F8F32D768814B5416208 # Partition clearing information # 清除分区 # --all、清除所有分区、--drives= 指定清除硬盘、--none 不删除任何分区 # clearpart --drives=sda --initlabel # Disk partitioning information # part / --fstype="xfs" --ondisk=sda --size=17407 # part swap --fstype="swap" --ondisk=sda --size=2048 # part /boot --fstype="xfs" --ondisk=sda --size=1024 %include /tmp/part.cfg # 安装完重启 reboot --eject %packages @^minimal chrony %end %addon com_redhat_kdump --enable --reserve-mb='auto' %end %pre #!/bin/sh aa=$(whiptail --title "disk info" --nocancel --menu "Please select a disk device." 15 50 5 $(lsblk | grep -v 'loop\|sr\|zraw' |awk '/^[a-z]/ {printf $1" "$4" "}') 3>&1 1>&2 2>&3 >/dev/console) > /tmp/part.cfg echo "bootloader --append=\" crashkernel=auto\" --location=mbr --boot-drive=$aa --driveorder=$aa --iscrypted --password=grub.pbkdf2.sha512.10000.56A0BDCD566915642A113EA15395992ACB55225783A26E5C1AF7AF101651F60EAE52F869DCEF59A319C8A57EB0EFDD22C6D5D8D1046385C05879699CA0A33D06.2432DEC1D876C30F41C8B307CDEFF2F8D6072FD36D8D68D752F96DD9CD99AE126F2E87FD5C5DF59543391B8DE28F82A73D735BDD8863FD439E9BB2C96EC77A2C" >> /tmp/part.cfg echo "ignoredisk --only-use=$aa" >> /tmp/part.cfg echo "clearpart --drives=$aa --all" >> /tmp/part.cfg echo "part /boot --fstype=xfs --ondisk=$aa --size=1024" >> /tmp/part.cfg echo "part swap --fstype=swap --ondisk=$aa --size=2048" >> /tmp/part.cfg echo "part / --fstype=xfs --ondisk=$aa --grow --maxsize=51200" >> /tmp/part.cfg %end %anaconda pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty %end 用户认证 - auth 设置身份验证选项 --enableshadow 使用 用户密码 --passalgo=sha512 指定 SHA-512 哈希算法 例：auth --enableshadow --passalgo=sha512 - rootpw 设置 root 密码 rootpw [--iscrypted|--plaintext] [--lock] password --iscrypted 创建 加密的密码 --plaintext 纯文本 --lock 锁定 root 帐户 例：rootpw --iscrypted $6$CRq8DBBEWuqc6LMC$IsuckHWPV8S3mpq0WfceGChzqA6nNVZZGni5oTgQ/tZisMqOrHlmGHqbZKCZchcmuFEBEF8OVT78qzZTiTrNK. tip: 生成密码 python -c 'import crypt,getpass;pw=getpass.getpass();print(crypt.crypt(pw) \ if (pw==getpass.getpass("Confirm: ")) else exit())' - User 在系统上创建新用户 user --name=username [options] --name= 用户名称 --groups= 组名列表 --shell= shell 类型 --iscrypted 创建 加密的密码 --plaintext 纯文本 例: user --name=acha --plaintext --password=q --groups=wheel tip: 生成密码 python -c 'import crypt,getpass;pw=getpass.getpass();print(crypt.crypt(pw) \ if (pw==getpass.getpass("Confirm: ")) else exit())' 用户设置 - Keyboard 设置 键盘布局 --vckeymap 键映射 --xlayouts 键盘布局 例: keyboard --vckeymap=us --xlayouts='us' - lang 设置 默认语言 --addsupport= 添加对其他语言的支持 例: lang en_US.UTF-8 - timezone 设置 系统时区 timezone timezone [options] --utc 设置 utc 时区 --nontp 不启用 ntp --ntpservers= ntp 服务地址 例: timezone Asia/Shanghai --utc --ntpservers=ntp.aliyun.com 安装 - cdrom CDROM 例: cdrom - url 使用 FTP、HTTP 或 HTTPS 从远程服务器上的安装树进行安装 --url= 安装位置 例; url --url= 服务 - firewall 指定 已安装系统的防火墙配置 firewall --enabled|--disabled device [options] - selinux 设置 已安装系统上 SELinux 的状态 selinux [--disabled|--enforcing|--permissive] - services 修改 将在默认 systemd 目标下运行的默认服务集 services [--disabled=list] [--enabled=list] 引导参数 - firstboot 首次引导系统。启用，则必须安装初始安装包 --enable 启用 --disable 禁用 --reconfig 重新配置 例: firstboot --enable --reconfig - bootloader 指定应如何安装引导加载程序 --append= 指定其他内核参数 --boot-drive= 指定 引导加载程序 写入哪个驱动器 --leavebootorder CentOS 7 添加到引导加载程序 顶部 --driveorder= BIOS 引导顺序中排在第一位 --password= GRUB2 菜单密码 --iscrypted 加密的密码 --timeout= 等待时间 --default= 设置默认引导映像 --disabled 禁用引导加载程序安装 例: bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=$aa --driveorder=$aa --password=3214 tip: 生成 grub2 密码： grub2-mkpasswd-pbkdf2 磁盘 - ignoredisk 忽略指定的磁盘 ignoredisk --drives=drive1,drive2,... - clearpart 在创建新分区之前从系统中删除分区 --all 擦除系统中的所有分区 --drives= 清除分区的驱动器 --initlabel 通过为各自体系结构中已指定用于格式化的所有磁盘 --list= 指定要清除的分区 --linux 擦除所有 Linux 分区 --none 不删除任何分区 例: clearpart --drives=$aa --all - part 创建分区 --size= 设置 分区大小 --grow 自适应大小 --maxsize= 分区设置的最大分区大小 --fstype= 文件系统类型 --ondisk= 在磁盘上创建一个分区 例: part / --fstype=xfs --ondisk=$aa --grow --maxsize=51200 网络 - network 配置目标系统的网络信息 --activate 在安装环境中激活此设备 --bootproto 网络模式 --device= 指定网卡 --ip= IP地址 --netmask= 子网掩码 --gateway= 网关 --nameserver= dns解析 --onboot= 自启 --noipv6 禁用 ipv6 例: network --bootproto=static --device=ens33 --ip=172.16.1.10 --netmask=255.255.255.0 --gateway=172.16.1.2 --nameserver=8.8.8.8 -noipv6 --onboot=yes --activate 状态 - reboot 安装成功完成后重新启动 --eject 尝试在重新启动之前弹出可启动媒体 --kexec 将已安装的系统加载到内存中 例: reboot --eject - shutdown 安装成功完成后关闭系统 例: shutdown - halt 等待用户在重新启动之前按下某个键 例: halt - eula 接受许可协议 --agreed 接受最终用户许可协议 例: eula --agreed 软件包选择 %packages %end 选项 @^ 整个环境 @ 指定组 wget 软件包 - 排除软件包或组 参数 --default 安装默认软件包组 --excludedocs 不要安装软件包中的任何文档 --ignoremissing 忽略安装源中缺少的软件包、组和环境 --instLangs= 指定要安装的语言列表 --multilib 允许在 64 位系统中安装 32 位软件包 预安装脚本 %pre %end 参数 --interpreter= 指定不同的脚本语言 --erroronfail 显示错误并在脚本失败时暂停安装 --log= 将脚本的输出记录到指定的日志文件 例 #!/bin/sh hds="" mymedia="" for file in /proc/ide/h* do mymedia=`cat $file/media` if [ $mymedia == "disk" ] ; then hds="$hds `basename $file`" fi done set $hds numhd=`echo $#` drive1=`echo $hds | cut -d' ' -f1` drive2=`echo $hds | cut -d' ' -f2` #Write out partition scheme based on whether there are 1 or 2 hard drives if [ $numhd == "2" ] ; then #2 drives echo "#partitioning scheme generated in %pre for 2 drives" > /tmp/part-include echo "clearpart --all" >> /tmp/part-include echo "part /boot --fstype xfs --size 75 --ondisk hda" >> /tmp/part-include echo "part / --fstype xfs --size 1 --grow --ondisk hda" >> /tmp/part-include echo "part swap --recommended --ondisk $drive1" >> /tmp/part-include echo "part /home --fstype xfs --size 1 --grow --ondisk hdb" >> /tmp/part-include else #1 drive echo "#partitioning scheme generated in %pre for 1 drive" > /tmp/part-include echo "clearpart --all" >> /tmp/part-include echo "part /boot --fstype xfs --size 75" >> /tmp/part-include echo "part swap --recommended" >> /tmp/part-include echo "part / --fstype xfs --size 2048" >> /tmp/part-include echo "part /home --fstype xfs --size 2048 --grow" >> /tmp/part-include fi 安装后脚本 %post %end 参数 --interpreter= 指定不同的脚本语言 --nochroot 在 chroot 环境之外运行 --erroronfail 显示错误并在脚本失败时暂停安装 --log= 将脚本的输出记录到指定的日志文件中 例 %post --log=/var/log/post.log #!/bin/bash #change net device to ethx #sed -i 's/quiet"/quiet net.ifnames=0 biosdevname=0"/g' /etc/default/grub #grub2-mkconfig -o /boot/grub2/grub.cfg cd /etc/sysconfig/network-scripts before_network_script=$(ls ifcfg-*|grep -v lo|grep -v eth*) net_dev_num=$(ls ifcfg-*|grep -v lo|wc -l) rm -rf $before_network_script for ((i=0;i<$net_dev_num;i++)); do echo "TYPE=Ethernet BOOTPROTO=static DEVICE=eth$i ONBOOT=no DNS1= IPADDR= GATEWAY= NETMASK=" |tee > /etc/sysconfig/network-scripts/ifcfg-eth$i done #add pcadmin to sudoers echo "tmpos ALL=(ALL) ALL" >> /etc/sudoers # add tmpos to group users usermod -a -G users tmpos # kolla systemctl disable postfix systemctl disable NetworkManager systemctl enable docker systemctl enable ntpd.service mkdir -p /etc/systemd/system/docker.service.d tee /etc/systemd/system/docker.service.d/kolla.conf <<'EOF' [Service] MountFlags=shared EOF cp -r /usr/share/kolla-ansible/etc_examples/kolla /etc/kolla/ cp -r /usr/share/kystack /opt %end Anaconda 配置 设置密码策略 pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty 软件包 rpm -qa >> /root/install.log awk '{print $2}' /root/install.log | xargs -i cp /media/Packages/{}.rpm /root/PanIOS/Packages/ yum -y install --downloadonly --downloaddir= [root@localhost data]# cat exp.sh #!/bin/bash cat << EOF <group> <id>$0</id> <name>$0</name> <name xml:lang="en_US">$0</name> <description>$0 packages</description> <default>false</default> <uservisible>false</uservisible> <packagelist> EOF for i in $* ; do echo " <packagereq type="default">$i</packagereq>" done cat << EOF </packagelist> </group> EOF [root@localhost data]# sh exp.sh wget unzip lrzsz tree USEAGE: mv exp.sh [groupid] sh [groupid] [pkg]... 制作镜像 mkisofs -o ../autoinstall_centos_79.iso \ -b isolinux/isolinux.bin \ -c isolinux/boot.cat \ -no-emul-boot \ -boot-load-size 4 \ -boot-info-table \ -R -J -v -T ./
分析需要的文件 RPM包 容器镜像 pip 包 流程 1、配置完yum源，设置开启缓存。手动部署完，制作 repo 源 2、手动部署完，将所有容器打包 3、手动部署完，统计 python模块包 写到 requirements.txt，下载收集并编写安装脚本。 容器镜像 全部导出 docker save `docker images --format "{{.Repository}}:{{.Tag}}"` | gzip > kolla_centos_train_min.tar.gz 导入 docker load -i kolla_centos_train_min.tar.gz rpm 软件包 [root@kolla ~]# mkdir /repo [root@kolla ~]# cat /etc/yum.conf [main] cachedir=/repo keepcache=1 ... [root@kolla ~]# yum install -y createrepo [root@kolla ~]# cd /repo [root@kolla repo]# mkdir -p kolla_centos_train_rpm/Packages [root@kolla repo]# cp -ra */packages/* kolla_centos_train_rpm/Packages [root@kolla repo]# cd kolla_centos_train_rpm [root@kolla kolla_centos_train_rpm]# createrepo ./ [root@kolla kolla_centos_train_rpm]# ls Packages repodata [root@kolla kolla_centos_train_rpm]# cd /repo [root@kolla repo]# tar cfz kolla_centos_train_rpm.tar.gz kolla_centos_train_rpm pip 依赖包 [root@kolla kolla_centos_train_whl]# cat requirements.txt setuptools==22.0.5 pip==20.3.4 wheel kolla-ansible==9.1.0 [root@kolla kolla_centos_train_whl]# mkdir packages [root@kolla kolla_centos_train_whl]# pip download -d packages -r requirements.txt [root@kolla kolla_centos_train_whl]# cat install.sh #!/bin/bash pip install --no-index --find-links=./packages/ setuptools==22.0.5 pip install --no-index --find-links=./packages/ pip==20.3.4 pip install --no-index --find-links=./packages/ wheel pip install --no-index --find-links=./packages/ kolla-ansible==9.1.0 --ignore-installed PyYAML [root@kolla ~]# tar cfz kolla_centos_train_whl.tar.gz kolla_centos_train_whl/
Jenkins 迁移 [root@jenkins ~]# rpm -ql jenkins /etc/init.d/jenkins /etc/logrotate.d/jenkins /etc/sysconfig/jenkins /usr/bin/jenkins /usr/lib/systemd/system/jenkins.service /usr/sbin/rcjenkins /usr/share/java/jenkins.war /usr/share/jenkins /usr/share/jenkins/migrate /var/cache/jenkins /var/lib/jenkins /var/log/jenkins 备份 1、停止 jenkins [root@jenkins ~]# systemctl stop jenkins [root@jenkins ~]# ps -ef | grep jenkins root 1818 1679 0 10:40 pts/0 00:00:00 grep --color=auto jenkins 2、备份 [root@jenkins ~]# grep ^JENKINS_HOME /etc/sysconfig/jenkins JENKINS_HOME="/var/lib/jenkins" [root@jenkins ~]# cd /var/lib [root@jenkins lib]# tar cfz jenkins_home.tar.gz jenkins [root@jenkins lib]# du -sh jenkins_home.tar.gz 182M jenkins_home.tar.gz [root@jenkins lib]# mv jenkins_home.tar.gz /root/ [root@jenkins ~]# cp -a /usr/lib/systemd/system/jenkins.service . [root@jenkins ~]# cp -a /etc/sysconfig/jenkins . [root@jenkins ~]# tar cfz jenkins_backup.tar.gz jenkins* [root@jenkins ~]# ll total 553540 -rw-------. 1 root root 1456 Nov 8 09:06 anaconda-ks.cfg -rwxr-xr-x. 1 root root 1012 Nov 8 09:14 init.sh -rw-------. 1 root root 4034 Nov 8 09:19 jenkins -rw-r--r--. 1 root root 93270402 Nov 2 07:55 jenkins-2.376-1.1.noarch.rpm -rw-r--r-- 1 root root 283331868 Nov 21 10:49 jenkins_backup.tar.gz -rw-r--r-- 1 root root 190196115 Nov 21 10:41 jenkins_home.tar.gz -rw-r--r--. 1 root root 5627 Nov 8 13:39 jenkins.service [root@jenkins ~]# du -sh jenkins_backup.tar.gz 271M jenkins_backup.tar.gz [root@jenkins ~]# sz jenkins_backup.tar.gz rz zmodem trl+C ȡ 正在传输 jenkins_backup.tar.gz... 100% 276691 KB 17293 KB/ 00:00:16 0 还原 1、java 环境 [root@thinkpad-e490 ~]# yum install -y java-11-openjdk java-11-openjdk-devel [root@thinkpad-e490 ~]# java --version openjdk 11.0.17 2022-10-18 LTS OpenJDK Runtime Environment (Red_Hat-11.0.17.0.8-2.el7_9) (build 11.0.17+8-LTS) OpenJDK 64-Bit Server VM (Red_Hat-11.0.17.0.8-2.el7_9) (build 11.0.17+8-LTS, mixed mode, sharing) 2、还原 [root@thinkpad-e490 ~]# rz rz waiting to receive. zmodem trl+C ȡ 正在传输 jenkins_backup.tar.gz... 100% 276691 KB 39527 KB/ 00:00:07 0 [root@thinkpad-e490 ~]# tar xfz jenkins_backup.tar.gz [root@thinkpad-e490 ~]# ll total 553536 -rw-------. 1 root root 1542 Nov 16 17:47 anaconda-ks.cfg -rw------- 1 root root 4034 Nov 8 09:19 jenkins -rw-r--r-- 1 root root 93270402 Nov 2 07:55 jenkins-2.376-1.1.noarch.rpm -rw-r--r-- 1 root root 283331868 Nov 21 10:49 jenkins_backup.tar.gz -rw-r--r-- 1 root root 190196115 Nov 21 10:41 jenkins_home.tar.gz -rw-r--r-- 1 root root 5627 Nov 8 13:39 jenkins.service [root@thinkpad-e490 ~]# rpm -ivh jenkins-2.376-1.1.noarch.rpm warning: jenkins-2.376-1.1.noarch.rpm: Header V4 RSA/SHA512 Signature, key ID 45f2c3d5: NOKEY Preparing... ################################# [100%] Updating / installing... 1:jenkins-2.376-1.1 ################################# [100%] [root@thinkpad-e490 ~]# mv jenkins /etc/sysconfig/jenkins mv: overwrite ‘/etc/sysconfig/jenkins’? y [root@thinkpad-e490 ~]# mv jenkins.service /usr/lib/systemd/system/jenkins.service mv: overwrite ‘/usr/lib/systemd/system/jenkins.service’? y [root@thinkpad-e490 ~]# tar xfz jenkins_home.tar.gz -C /var/lib/ 3、启动 [root@thinkpad-e490 ~]# systemctl start jenkins [root@thinkpad-e490 ~]# systemctl status jenkins ● jenkins.service - Jenkins Continuous Integration Server Loaded: loaded (/usr/lib/systemd/system/jenkins.service; disabled; vendor preset: disabled) Active: active (running) since Mon 2022-11-21 10:57:43 CST; 1s ago Main PID: 1861 (java) CGroup: /system.slice/jenkins.service └─1861 /usr/bin/java -Djava.awt.headless=true -jar /usr/share/java/jenkins.war --webroot=%C/jenkins/war ... Nov 21 10:57:42 thinkpad-e490 jenkins[1861]: 2022-11-21 02:57:42.968+0000 [id=34] INFO hudson.sl...t sdk Nov 21 10:57:42 thinkpad-e490 jenkins[1861]: 2022-11-21 02:57:42.980+0000 [id=32] INFO jenkins.I...oaded Nov 21 10:57:42 thinkpad-e490 jenkins[1861]: 2022-11-21 02:57:42.982+0000 [id=32] INFO jenkins.I...apted Nov 21 10:57:43 thinkpad-e490 jenkins[1861]: 2022-11-21 02:57:43.019+0000 [id=33] INFO jenkins.I... jobs Nov 21 10:57:43 thinkpad-e490 jenkins[1861]: 2022-11-21 02:57:43.027+0000 [id=46] INFO jenkins.I...dated Nov 21 10:57:43 thinkpad-e490 jenkins[1861]: 2022-11-21 02:57:43.059+0000 [id=64] INFO hudson.ut...erver Nov 21 10:57:43 thinkpad-e490 jenkins[1861]: 2022-11-21 02:57:43.227+0000 [id=33] INFO o.j.main....46087 Nov 21 10:57:43 thinkpad-e490 jenkins[1861]: 2022-11-21 02:57:43.227+0000 [id=43] INFO jenkins.I...ation Nov 21 10:57:43 thinkpad-e490 jenkins[1861]: 2022-11-21 02:57:43.283+0000 [id=24] INFO hudson.li...nning Nov 21 10:57:43 thinkpad-e490 systemd[1]: Started Jenkins Continuous Integration Server. Hint: Some lines were ellipsized, use -l to show in full. [root@thinkpad-e490 ~]# ps -ef | grep jenkins root 1861 1 99 10:57 ? 00:00:44 /usr/bin/java -Djava.awt.headless=true -jar /usr/share/java/jenkins.war --webroot=%C/jenkins/war --httpPort=8080 root 2025 1539 0 10:57 pts/0 00:00:00 grep --color=auto jenkins [root@thinkpad-e490 ~]# free -h total used free shared buff/cache available Mem: 7.5G 896M 5.2G 9.4M 1.4G 6.4G Swap: 7.8G 0B 7.8G 4、访问
Typecho 1.2.0 部署 {bilibili bvid="BV15e411u7gH" page=""/} 环境 CentOS7.9 Nginx/1.20.1 PHP 7.2.34 mysql-5.7.37 初始化系统 curl -O file.youto.club/Script/init.sh sh init.sh blog [root@blog nginx]# cat /script/init.sh #!/usr/bin/bash echo "=-=-=- Action -=-=-=" hostnamectl set-hostname $1 echo "# ==> Hostname: " `hostname` systemctl stop firewalld && systemctl disable firewalld >/dev/null 2>&1 setenforce 0 >/dev/null 2>&1 sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config echo "# ==> Stop Firewalld && Selinux" mkdir /etc/yum.repos.d/bak -p mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo >/dev/null 2>&1 curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo >/dev/null 2>&1 yum repolist | grep repolist echo "# ==>repo" yum install -y lrzsz tree wget vim net-tools unzip bash-completion git >/dev/null 2>&1 sed -i "s/\#UseDNS no/UseDNS yes/g" /etc/ssh/sshd_config echo "# ==> SSH " echo "=-=-=- Done -=-=-=" 准备软件包 mysql-5.7.37-1.el7.x86_64.rpm.tar nginx-1.20.1.tar.gz typecho.zip mkdir /{repo,software,script} # MySQl wget http://file.youto.club/Repo/mysql-5.7.37-1.el7.x86_64.rpm.tar tar xf mysql-5.7.37-1.el7.x86_64.rpm.tar -c /repo ls /repo/mysql57_2009_repo/ vim /etc/yum.repos.d/mysql_local.repo yum repolist # PHP72 yum install -y http://rpms.remirepo.net/enterprise/remi-release-7.rpm yum install -y yum-utils yum-config-manager --enable remi-php72 # typecho wget https://github.com/typecho/typecho/releases/latest/download/typecho.zip mv typecho.zip /software/ [root@blog nginx]# cat /etc/yum.repos.d/mysql_local.repo [mysql57] name=mysql57 baseurl=file:///repo/mysql57_2009_repo/ gpgcheck=0 enabled=1 MySQL yum install -y mysql-server systemctl enable mysqld systemctl start mysqld grep pass /var/log/mysqld.log mysql -uroot -p [root@blog nginx]# mysql -uroot -p mysql> alter user user() identified by 'Admin@123'; Query OK, 0 rows affected (0.00 sec) mysql> create database typecho; Query OK, 1 row affected (0.00 sec) mysql> GRANT ALL ON typecho.* TO 'typecho'@'localhost' IDENTIFIED BY 'Abc@1234'; Query OK, 0 rows affected, 1 warning (0.00 sec) PHP yum install -y php72 php72 -v yum install -y php72-php-fpm php72-php-mbstring php72-php-mysqlnd systemctl enable php72-php-fpm.service systemctl start php72-php-fpm.service netstat -lntp rpm -ql php72-php-fpm vim /etc/opt/remi/php72/php-fpm.d/www.conf [root@blog nginx]# grep nginx /etc/opt/remi/php72/php-fpm.d/www.conf user = nginx group = nginx Nginx yum install -y nginx wget https://nginx.org/download/nginx-1.20.1.tar.gz mkdir /html unzip /software/typecho.zip cd /etc/nginx/ grep -Ev "#|^$" nginx.conf.default > nginx.conf vim nginx.conf mkdir -p /var/log/blog chown -R nginx.nginx /var/log/blog nginx -t chown -R nginx.nginx /html/ systemctl start nginx # cat /etc/nginx/nginx.conf worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; root /html; index index.html index.htm index.php; if (!-e $request_filename) { rewrite ^(.*)$ /index.php$1 last; } location ~ .*\.php(\/.*)*$ { include fastcgi.conf; fastcgi_pass 127.0.0.1:9000; } access_log /html/access.log combined; } } 访问
1+X 初级 by 王政(blog http://blog.youto.club) # 说明： 本次视频，只做文档演示，没有详细讲解 # 视频地址：https://www.bilibili.com/video/BV1hL411M72w 1+X 初级 环境准备 网络服务 本地YUM源管理 FTP安装使用 Samba管理 NFS 服务管理 主从数据库管理 部署WordPress应用 拓展 LVM 数据库管理 MariaDB管理 Openstack运维 OpenStack Keystone管理 OpenStack Glance管理 OpenStack Cinder管理 OpenStack Nova管理 OpenStack Swift管理 Docker Docker安装 Docker运维 Docker管理 Dockerfile编写 Dockerfile 编写 部署Swarm集群 环境准备 yum源 selinux & firewalld hostname hosts 网络服务 本地YUM源管理 使用VMWare软件启动提供的xserver1虚拟机（配置虚拟机xserver1的IP为192.168.100.11，主机名为xserver1），在虚拟机的/root目录下，存在一个CentOS-7-x86_64-DVD-1511.iso的镜像文件，使用这个镜像文件配置本地yum源，要求将这个镜像文件挂在/opt/centos目录，请问如何配置自己的local.repo文件，使得可以使用该镜像中的软件包，安装软件。请将local.repo文件的内容以文本形式提交到答题框。 [root@xserver1 ~]# mkdir /opt/centos [root@xserver1 ~]# mount -o loop CentOS-7-x86_64-DVD-1511.iso /opt/centos/ mount: /dev/loop0 is write-protected, mounting read-only [root@xserver1 ~]# rm -f /etc/yum.repos.d/* [root@xserver1 ~]# cat /etc/yum.repos.d/local.repo [centos] name=centos baseurl=file:///opt/centos gpgcheck=0 enabled=1 # 答题框 [root@xserver1 ~]# cat /etc/yum.repos.d/local.repo [centos] name=centos baseurl=file:///opt/centos gpgcheck=0 enabled=1 FTP安装使用 使用xserver1虚拟机，安装ftp服务，并配置ftp的共享目录为/opt。使用VMWare软件继续启动提供的xserver2虚拟机（配置虚拟机xserver2的IP为192.168.100.12，主机名为xserver2），并创建该虚拟机的yum源文件ftp.repo使用xserver1的ftp源（配置文件中的FTP地址使用主机名）。配置完成后，将xserver2节点的ftp.repo文件以文本形式提交到答题框。 yum install -y vsftpd echo "anon_root=/opt/" >> /etc/vsftpd/vsftpd.conf systemctl start vsftpd && systemctl enable vsftpd [root@xserver2 ~]# cat /etc/yum.repos.d/ftp.repo [centos] name=centos baseurl=ftp://xserver1/centos gpgcheck=0 enabled=1 # 答题框 [root@xserver2 ~]# cat /etc/yum.repos.d/ftp.repo [centos] name=centos baseurl=ftp://xserver1/centos gpgcheck=0 enabled=1 Samba管理 使用xserver1虚拟机，安装Samba服务所需要的软件包，将xserver1节点中的/opt/share目录使用Samba服务共享出来（目录不存在请自行创建）。操作完毕后，将xserver1节点Samba配置文件中的[share]段落和执行netstat -ntpl命令的返回结果以文本形式提交到答题框。 yum install -y samba vi /etc/samba/smb.conf # 添加 [share] comment = Share Directories path=/opt/share writable = yes systemctl restart smb # 答题框 [share] comment = Share Directories path=/opt/share writable = yes [root@xserver1 ~]# netstat -nltp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:139 0.0.0.0:* LISTEN 3527/smbd tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1429/sshd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1944/master tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN 3527/smbd tcp6 0 0 :::139 :::* LISTEN 3527/smbd tcp6 0 0 :::21 :::* LISTEN 3280/vsftpd tcp6 0 0 :::22 :::* LISTEN 1429/sshd tcp6 0 0 ::1:25 :::* LISTEN 1944/master tcp6 0 0 :::445 :::* LISTEN 3527/smbd NFS 服务管理 使用 xserver1、xserver2 虚拟机，安装 NFS 服务所需要的软件包，将 xserver1 节点中的/mnt/share 目录使用 NFS 服务共享出来（目录不存在请自行创建，要求可访问共享目录的网段为 192.168.100.0/24），接着在 xserver2 节点上，将 xserver1中共享的文件挂载到/mnt 目录下。操作完毕后，依次将 xserver1 节点上执行showmount -e ip 命令和 xserver2 节点上执行 df -h 命令的返回结果（简要）写到下方 # xserver1 yum search nfs yum install -y nfs-utils mkdir /mnt/share man exports vi /etc/exports # 添加 /mnt/share 192.168.100.0/24(rw,sync) systemctl start nfs-server rpcbind exportfs -r showmount -e 192.168.100.11 # xserver2 yum install -y nfs-utils mount 192.168.100.11:/mnt/share /mnt/ df -h # 答题框 [root@xserver1 ~]# showmount -e 192.168.100.11 Export list for 192.168.100.11: /mnt/share 192.168.100.0/24 [root@xserver2 ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/centos-root 36G 951M 35G 3% / devtmpfs 1.9G 0 1.9G 0% /dev tmpfs 1.9G 0 1.9G 0% /dev/shm tmpfs 1.9G 8.7M 1.9G 1% /run tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup /dev/sda1 497M 114M 384M 23% /boot tmpfs 378M 0 378M 0% /run/user/0 192.168.100.11:/mnt/share 36G 7.7G 28G 22% /mnt 主从数据库管理 在xserver1、xserver2上安装mariadb数据库，并配置为主从数据库（xserver1为主节点、xserver2为从节点），实现两个数据库的主从同步。配置完毕后，请在xserver2上的数据库中执行“show slave status \G”命令查询从节点复制状态，将查询到的结果以文本形式提交到答题框。 ## xserver1 yum install -y mariadb-server systemctl start mariadb mysql_secure_installation mysql -uroot -p000000 MariaDB [(none)]> GRANT ALL privileges ON *.* TO 'root'@'%' IDENTIFIED BY '000000'; MariaDB [(none)]> GRANT replication slave ON *.* TO 'user'@'xserver2' IDENTIFIED BY '000000'; vi /etc/my.cnf # 在第二行添加 log_bin=mysql-bin server_id=11 systemctl restart mariadb ## xserver2 yum install -y mariadb-server systemctl start mariadb mysql_secure_installation vi /etc/my.cnf # 在第二行添加 log_bin=mysql-bin server_id=12 systemctl restart mariadb mysql -uroot -p000000 MariaDB [(none)]> CHANGE MASTER TO MASTER_HOST='xserver1',MASTER_USER='user',MASTER_PASSWORD='000000'; MariaDB [(none)]> start slave; MariaDB [(none)]> show slave status \G # 答题框 MariaDB [(none)]> show slave status \G *************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: xserver1 Master_User: user Master_Port: 3306 Connect_Retry: 60 Master_Log_File: mysql-bin.000001 Read_Master_Log_Pos: 245 Relay_Log_File: mariadb-relay-bin.000003 Relay_Log_Pos: 529 Relay_Master_Log_File: mysql-bin.000001 Slave_IO_Running: Yes Slave_SQL_Running: Yes Replicate_Do_DB: Replicate_Ignore_DB: Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: Last_Errno: 0 Last_Error: Skip_Counter: 0 Exec_Master_Log_Pos: 245 Relay_Log_Space: 825 Until_Condition: None Until_Log_File: Until_Log_Pos: 0 Master_SSL_Allowed: No Master_SSL_CA_File: Master_SSL_CA_Path: Master_SSL_Cert: Master_SSL_Cipher: Master_SSL_Key: Seconds_Behind_Master: 0 Master_SSL_Verify_Server_Cert: No Last_IO_Errno: 0 Last_IO_Error: Last_SQL_Errno: 0 Last_SQL_Error: Replicate_Ignore_Server_Ids: Master_Server_Id: 11 1 row in set (0.00 sec) 部署WordPress应用 使用xserver1节点，基于lnmp环境，部署WordPress应用（WordPress源码包在/root目录下）。应用部署完毕后，设置WordPress的站点标题为自己的姓名（例：名字叫张三，则设置站点标题为张三的BLOG），设置完毕后登录WordPresss首页。最后将命令curl ip（ip为wordpress的首页ip）的返回结果以文本形式提交到答题框。 # xserver1 vi /etc/yum.repos.d/local.repo i # 添加 [lnmp] name=lnmp baseurl=file:///root/lnmp gpgcheck=0 enabled=1 yum repolist yum install -y nginx php php-fpm php-mysql vi /etc/php-fpm.d/www.conf # 修改 39 user = nginx 41 group = nginx vi /etc/nginx/conf.d/default.conf # 修改 10 index index.php index.html index.htm; 30 location ~ \.php$ { 31 root /usr/share/nginx/html; 32 fastcgi_pass 127.0.0.1:9000; 33 fastcgi_index index.php; 34 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 35 include fastcgi_params; 36 } systemctl start nginx php-fpm [root@xserver1 ~]# mysql -uroot -p000000 MariaDB [(none)]> create database wordpress; rm -f /usr/share/nginx/html/* yum install -y unzip unzip wordpress-4.7.3-zh_CN.zip cp -r wordpress/* /usr/share/nginx/html/ ls /usr/share/nginx/html/ chown -R nginx.nginx /usr/share/nginx/html/ cp /usr/share/nginx/html/wp-config-sample.php /usr/share/nginx/html/wp-config.php vi /usr/share/nginx/html/wp-config.php # 修改 23 define('DB_NAME', 'wordpress'); 26 define('DB_USER', 'root'); 29 define('DB_PASSWORD', '000000'); # 使用浏览访问 IP，设置标题 数字表示行号 tip: 在 vi中 :set nu 显示行号 拓展 LVM # 解题步骤： 1. 添加硬盘，并分区 2. 创建 PV 3. 创建 VG 4. 创建 LV 5. 格式化，挂载 使用xserver1虚拟机，使用VMWare软件自行添加一块大小为20G的硬盘，使用fdisk命令对该硬盘进形分区，要求分出三个大小为5G的分区。使用这三个分区，创建名xcloudvg的卷组。然后创建名xcloudlv的逻辑卷，大小为12G，再创建完之后，使用命令将逻辑卷大小缩小2G，然后查看逻辑卷信息。将上述所有操作命令和返回结果以文本形式提交到答题框。 [root@xserver2 ~]# lsblk [root@xserver2 ~]# fdisk /dev/sdb # n 默认回车 大小设置：+5G 重复三次 [root@xserver2 ~]# pvcreate /dev/sdb[1-3] [root@xserver2 ~]# vgcreate xcloudvg /dev/sdb[1-3] [root@xserver2 ~]# lvcreate -L 12G -n xcloudlv xcloudvg [root@xserver2 ~]# lvreduce -L -2G /dev/mapper/xcloudvg-xcloudlv [root@xserver2 ~]# lvdisplay 使用VMware软件和提供的CentOS-7-x86_64-DVD-1511.iso创建虚拟机，自行配置好网络并多添加一块大小为20G的硬盘，使用fdisk命令对该硬盘进形分区，要求分出三个大小为5G的分区。使用这三个分区，创建名xcloudvg的卷组。然后创建名xcloudlv的逻辑卷，大小为12G，最后用xfs文件系统对逻辑卷进行格式化并挂载到/mnt目录下。将上述所有操作命令和返回结果以文本形式提交到答题框。 [root@xserver2 ~]# lsblk [root@xserver2 ~]# fdisk /dev/sdb # n 默认回车 大小设置：+5G 重复三次 [root@xserver2 ~]# pvcreate /dev/sdb1 /dev/sdb2 /dev/sdb3 [root@xserver2 ~]# vgcreate xcloudvg /dev/sdb[1-3] [root@xserver2 ~]# lvcreate -L 12G -n xcloudlv xcloudvg [root@xserver2 ~]# mkfs.xfs /dev/xcloudvg/xcloudlv [root@xserver2 ~]# mkdir /data [root@xserver2 ~]# mount -o loop /dev/xcloudvg/xcloudlv /mnt [root@xserver2 ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/centos-root 36G 872M 35G 3% / devtmpfs 1.9G 0 1.9G 0% /dev tmpfs 1.9G 0 1.9G 0% /dev/shm tmpfs 1.9G 8.6M 1.9G 1% /run tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup /dev/sda1 497M 114M 384M 23% /boot tmpfs 378M 0 378M 0% /run/user/0 /dev/loop0 12G 33M 12G 1% /mnt 使用xserver1虚拟机，使用VMWare软件自行添加一块大小为20G的硬盘，使用fdisk命令对该硬盘进形分区，要求分出两个大小为5G的分区。使用两个分区，创建名xcloudvg的卷组并指定PE大小为16 MB。将执行vgdisplay命令的返回结果以文本形式提交到答题框。 [root@xserver1 ~]# fdisk /dev/sdb # n 默认回车 大小设置：+5G 重复三次 [root@xserver1 ~]# pvcreate /dev/sdb1 /dev/sdb2 [root@xserver1 ~]# vgcreate xcloudvg -s 16 /dev/sdb1 /dev/sdb2 [root@xserver1 ~]# vgdisplay 数据库管理 使用提供的“all-in-one”虚拟机，进入数据库。 （1）创建本地用户examuser，密码为000000； （2）查询mysql数据库中的user表的host，user，password字段；（3）赋予这个用户对所有数据库拥有“查询”“删除”“更新”“创建”的本地权限。依次将操作命令和返回结果以文本形式提交到答题框。 [root@xserver1 ~]# mysql -uroot -p000000 MariaDB [mysql]> create user examuser@localhost identified by '000000'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> use mysql MariaDB [mysql]> select host,user,password from user; +-----------+----------+-------------------------------------------+ | host | user | password | +-----------+----------+-------------------------------------------+ | localhost | root | *032197AE5731D4664921A6CCAC7CFCE6A0698693 | | xserver1 | root | *032197AE5731D4664921A6CCAC7CFCE6A0698693 | | 127.0.0.1 | root | *032197AE5731D4664921A6CCAC7CFCE6A0698693 | | ::1 | root | *032197AE5731D4664921A6CCAC7CFCE6A0698693 | | % | root | *032197AE5731D4664921A6CCAC7CFCE6A0698693 | | xserver2 | user | *032197AE5731D4664921A6CCAC7CFCE6A0698693 | | localhost | examuser | *032197AE5731D4664921A6CCAC7CFCE6A0698693 | +-----------+----------+-------------------------------------------+ 7 rows in set (0.00 sec) MariaDB [mysql]> grant SELECT,DELETE,UPDATE,CREATE on *.* to examuser@localhost; Query OK, 0 rows affected (0.00 sec) MariaDB管理 使用VMware软件和提供的CentOS-7-x86_64-DVD-1511.iso创建虚拟机，自行配置好网络和YUM源，安装mariadb数据库，安装完毕后登数据库，查询当前系统的时间和用户。依次将操作命令和返回结果以文本形式提交到答题框。（数据库用户名root，密码000000；关于数据库的命令均使用小写） [root@xserver1 ~]# mysql -uroot -p000000 MariaDB [(none)]> select user() ,now(); +----------------+---------------------+ | user() | now() | +----------------+---------------------+ | root@localhost | 2021-11-17 15:05:08 | +----------------+---------------------+ 1 row in set (0.00 sec) Openstack运维 OpenStack Keystone管理 使用提供的“all-in-one”虚拟机，创建用户testuser，密码为xiandian，将testuser用户分配给admin项目，赋予用户admin的权限。依次将操作命令和查询结果以文本形式提交到答题框。 [root@controller ~]# openstack user create --password xiandian --project admin --domain xiandian testuser +--------------------+----------------------------------+ | Field | Value | +--------------------+----------------------------------+ | default_project_id | f9ff39ba9daa4e5a8fee1fc50e2d2b34 | | domain_id | 9321f21a94ef4f85993e92a228892418 | | enabled | True | | id | 806b2c56147e41699ddd89af955a6f20 | | name | testuser | +--------------------+----------------------------------+ OpenStack Glance管理 使用VMWare软件启动提供的opensatckallinone镜像，自行检查openstack中各服务的状态，若有问题自行排查。在xserver1节点的/root目录下存在一个cirros-0.3.4-x86_64-disk.img镜像；使用glance命令将镜像上传，并命名为mycirros，最后将glance image-show id命令的返回结果以文本形式提交到答题框。 [root@controller ~]# scp 192.168.100.11:/root/cirros-0.3.4-x86_64-disk.img . [root@controller ~]# glance image-create --name mycirros --disk-format qcow2 --container-format bare --progress < cirros-0.3.4-x86_64-disk.img [=============================>] 100% +------------------+--------------------------------------+ | Property | Value | +------------------+--------------------------------------+ | checksum | ee1eca47dc88f4879d8a229cc70a07c6 | | container_format | bare | | created_at | 2021-11-24T15:54:45Z | | disk_format | qcow2 | | id | 45d98d72-b23f-464d-b66e-13f154eed216 | | min_disk | 0 | | min_ram | 0 | | name | mycirros | | owner | f9ff39ba9daa4e5a8fee1fc50e2d2b34 | | protected | False | | size | 13287936 | | status | active | | tags | [] | | updated_at | 2021-11-24T15:54:45Z | | virtual_size | None | | visibility | private | +------------------+--------------------------------------+ [root@controller ~]# glance image-show 45d98d72-b23f-464d-b66e-13f154eed216 +------------------+--------------------------------------+ | Property | Value | +------------------+--------------------------------------+ | checksum | ee1eca47dc88f4879d8a229cc70a07c6 | | container_format | bare | | created_at | 2021-11-24T15:54:45Z | | disk_format | qcow2 | | id | 45d98d72-b23f-464d-b66e-13f154eed216 | | min_disk | 0 | | min_ram | 0 | | name | mycirros | | owner | f9ff39ba9daa4e5a8fee1fc50e2d2b34 | | protected | False | | size | 13287936 | | status | active | | tags | [] | | updated_at | 2021-11-24T15:54:45Z | | virtual_size | None | | visibility | private | +------------------+--------------------------------------+ OpenStack Cinder管理 使用VMWare软件启动提供的opensatckallinone镜像，自行检查openstack中各服务的状态，若有问题自行排查。使用Cinder服务，创建名为“ lvm”的卷类型，然后创建一块带“lvm” 标识的云硬盘，名称为 BlockVloume，大小为 2G，查询该云硬盘详细信息。完成后，将cinder show BlockVloume命令的返回结果以文本形式提交到答题框。 [root@controller ~]# cinder type-create lvm +--------------------------------------+------+-------------+-----------+ | ID | Name | Description | Is_Public | +--------------------------------------+------+-------------+-----------+ | caad5c75-59e3-4167-ad15-19e9f27cee6f | lvm | - | True | +--------------------------------------+------+-------------+-----------+ [root@controller ~]# cinder create --name BlockVloume --volume-type lvm 2 +--------------------------------+--------------------------------------+ | Property | Value | +--------------------------------+--------------------------------------+ | attachments | [] | | availability_zone | nova | | bootable | false | | consistencygroup_id | None | | created_at | 2021-11-24T15:57:22.000000 | | description | None | | encrypted | False | | id | d013e4b2-b0b8-41b4-95e3-2bd47f3431fa | | metadata | {} | | migration_status | None | | multiattach | False | | name | BlockVloume | | os-vol-host-attr:host | None | | os-vol-mig-status-attr:migstat | None | | os-vol-mig-status-attr:name_id | None | | os-vol-tenant-attr:tenant_id | f9ff39ba9daa4e5a8fee1fc50e2d2b34 | | replication_status | disabled | | size | 2 | | snapshot_id | None | | source_volid | None | | status | creating | | updated_at | None | | user_id | 0befa70f767848e39df8224107b71858 | | volume_type | lvm | +--------------------------------+--------------------------------------+ [root@controller ~]# cinder show d013e4b2-b0b8-41b4-95e3-2bd47f3431fa +--------------------------------+--------------------------------------+ | Property | Value | +--------------------------------+--------------------------------------+ | attachments | [] | | availability_zone | nova | | bootable | false | | consistencygroup_id | None | | created_at | 2021-11-24T15:57:22.000000 | | description | None | | encrypted | False | | id | d013e4b2-b0b8-41b4-95e3-2bd47f3431fa | | metadata | {} | | migration_status | None | | multiattach | False | | name | BlockVloume | | os-vol-host-attr:host | controller@lvm#LVM | | os-vol-mig-status-attr:migstat | None | | os-vol-mig-status-attr:name_id | None | | os-vol-tenant-attr:tenant_id | f9ff39ba9daa4e5a8fee1fc50e2d2b34 | | replication_status | disabled | | size | 2 | | snapshot_id | None | | source_volid | None | | status | available | | updated_at | 2021-11-24T15:57:23.000000 | | user_id | 0befa70f767848e39df8224107b71858 | | volume_type | lvm | +--------------------------------+--------------------------------------+ OpenStack Nova管理 使用提供的“all-in-one”虚拟机，通过nova的相关命令创建名为exam，ID为1234，内存为1024M，硬盘为20G，虚拟内核数量为2的云主机类型，查看exam的详细信息。依次将操作命令及返回结果以文本形式提交到答题框。 [root@controller ~]# nova flavor-create exam 1234 1024 20 2 +------+------+-----------+------+-----------+------+-------+-------------+-----------+ | ID | Name | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public | +------+------+-----------+------+-----------+------+-------+-------------+-----------+ | 1234 | exam | 1024 | 20 | 0 | | 2 | 1.0 | True | +------+------+-----------+------+-----------+------+-------+-------------+-----------+ [root@controller ~]# nova flavor-show exam +----------------------------+-------+ | Property | Value | +----------------------------+-------+ | OS-FLV-DISABLED:disabled | False | | OS-FLV-EXT-DATA:ephemeral | 0 | | disk | 20 | | extra_specs | {} | | id | 1234 | | name | exam | | os-flavor-access:is_public | True | | ram | 1024 | | rxtx_factor | 1.0 | | swap | | | vcpus | 2 | +----------------------------+-------+ OpenStack Nova管理 使用VMWare软件启动提供的opensatckallinone镜像，自行检查openstack中各服务的状态，若有问题自行排查。使用nova相关命令，查询nova所有的监控列表，并查看ID为1的监控主机的详细信息，将操作命令和返回结果以文本形式提交到答题框。 [root@controller ~]# nova hypervisor-list +----+---------------------+-------+---------+ | ID | Hypervisor hostname | State | Status | +----+---------------------+-------+---------+ | 1 | controller | up | enabled | +----+---------------------+-------+---------+ [root@controller ~]# nova hypervisor-show 1 +---------------------------+------------------------------------------+ | Property | Value | +---------------------------+------------------------------------------+ | cpu_info_arch | x86_64 | | cpu_info_features | ["smap", "avx", "clflush", "sep", | | | "syscall", "vme", "invpcid", "tsc", | | | "fsgsbase", "xsave", "pge", "vmx", | | | "erms", "cmov", "smep", "pcid", "pat", | | | "lm", "msr", "adx", "3dnowprefetch", | | | "nx", "fxsr", "sse4.1", "pae", "sse4.2", | | | "pclmuldq", "fma", "tsc-deadline", | | | "mmx", "osxsave", "cx8", "mce", "de", | | | "rdtscp", "ht", "pse", "lahf_lm", "abm", | | | "rdseed", "popcnt", "mca", "pdpe1gb", | | | "apic", "sse", "f16c", "mpx", "invtsc", | | | "pni", "aes", "avx2", "sse2", "ss", | | | "hypervisor", "bmi1", "bmi2", "ssse3", | | | "fpu", "cx16", "pse36", "mtrr", "movbe", | | | "rdrand", "x2apic"] | | cpu_info_model | Broadwell-noTSX | | cpu_info_topology_cells | 1 | | cpu_info_topology_cores | 2 | | cpu_info_topology_sockets | 1 | | cpu_info_topology_threads | 1 | | cpu_info_vendor | Intel | | current_workload | 0 | | disk_available_least | 31 | | free_disk_gb | 34 | | free_ram_mb | 7296 | | host_ip | 192.168.100.10 | | hypervisor_hostname | controller | | hypervisor_type | QEMU | | hypervisor_version | 2003000 | | id | 1 | | local_gb | 34 | | local_gb_used | 0 | | memory_mb | 7808 | | memory_mb_used | 512 | | running_vms | 0 | | service_disabled_reason | None | | service_host | controller | | service_id | 6 | | state | up | | status | enabled | | vcpus | 2 | | vcpus_used | 0 | +---------------------------+------------------------------------------+ OpenStack Swift管理 使用VMWare软件启动提供的opensatckallinone镜像，自行检查openstack中各服务的状态，若有问题自行排查。使用swift相关命令，创建一个名叫examcontainer的容器，然后往这个容器中上传一个test.txt的文件（文件可以自行创建），上传完毕后，使用命令查看容器，将操作命令和返回结果以文本形式提交到答题框。(40)分 [root@controller ~]# swift post examcontainer [root@controller ~]# touch test.txt [root@controller ~]# swift upload examcontainer test.txt test.txt [root@controller ~]# swift list examcontainer [root@controller ~]# swift stat examcontainer Docker Docker安装 使用xserver1节点，自行配置YUM源，安装docker服务（需要用到的包为xserver1节点/root目录下的Docker.tar.gz）。安装完服务后，将registry_latest.tar上传到xserver1节点中并配置为私有仓库。要求启动registry容器时，将内部保存文件的目录映射到外部的/opt/registry目录，将内部的5000端口映射到外部5000端口。依次将启动registry容器的命令及返回结果、执行docker info命令的返回结果以文本形式提交到答题框。 [root@xserver1 ~]# tar xfv Docker.tar.gz [root@xserver1 ~]# vi /etc/yum.repos.d/local.repo # 添加 [docker] name=docker baseurl=file:///root/Docker gpgcheck=0 enabled=1 [root@xserver1 ~]# yum repolist [root@xserver1 ~]# yum install -y docker-ce [root@xserver1 ~]# systemctl daemon-reload [root@xserver1 ~]# systemctl start docker [root@xserver1 ~]# ./image.sh [root@xserver1 ~]# vi /etc/docker/daemon.json # 添加 { "insecure-registries": ["192.168.100.11:5000"] } [root@xserver1 ~]# systemctl restart docker [root@xserver1 ~]# docker run -d --restart=always -v /opt/registry/:/var/lib/registry -p 5000:5000 registry:latest 950319053db0f90eef33b33ce3bc76a93d3b6cf4b17c27b532d23e8aa9ef7bb9 [root@xserver1 ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 950319053db0 registry:latest "/entrypoint.sh /etc…" 19 seconds ago Up 18 seconds 0.0.0.0:5000->5000/tcp xenodochial_johnson [root@xserver1 ~]# docker info # 答题框 [root@xserver1 ~]# docker info Containers: 1 Running: 0 Paused: 0 Stopped: 1 Images: 11 Server Version: 18.09.6 Storage Driver: devicemapper Pool Name: docker-253:0-67486317-pool Pool Blocksize: 65.54kB Base Device Size: 10.74GB Backing Filesystem: xfs Udev Sync Supported: true Data file: /dev/loop1 Metadata file: /dev/loop2 Data loop file: /var/lib/docker/devicemapper/devicemapper/data Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata Data Space Used: 1.339GB Data Space Total: 107.4GB Data Space Available: 26.1GB Metadata Space Used: 2.077MB Metadata Space Total: 2.147GB Metadata Space Available: 2.145GB Thin Pool Minimum Free Space: 10.74GB Deferred Removal Enabled: true Deferred Deletion Enabled: true Deferred Deleted Device Count: 0 Library Version: 1.02.107-RHEL7 (2015-10-14) Logging Driver: json-file Cgroup Driver: cgroupfs Plugins: Volume: local Network: bridge host macvlan null overlay Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog Swarm: inactive Runtimes: runc Default Runtime: runc Init Binary: docker-init containerd version: b34a5c8af56e510852c35414db4c1f4fa6172339 runc version: 3e425f80a8c931f88e6d94a8c831b9d5aa481657 init version: fec3683 Security Options: seccomp Profile: default Kernel Version: 3.10.0-327.el7.x86_64 Operating System: CentOS Linux 7 (Core) OSType: linux Architecture: x86_64 CPUs: 2 Total Memory: 3.688GiB Name: xserver1 ID: VXSJ:7YFV:GWBV:2E3E:LAIM:EQ36:MRCD:Q6BG:IRBS:HJXU:K4ZD:E377 Docker Root Dir: /var/lib/docker Debug Mode (client): false Debug Mode (server): false Registry: https://index.docker.io/v1/ Labels: Experimental: false Insecure Registries: 127.0.0.0/8 Live Restore Enabled: false Product License: Community Engine WARNING: bridge-nf-call-iptables is disabled WARNING: bridge-nf-call-ip6tables is disabled WARNING: the devicemapper storage-driver is deprecated, and will be removed in a future release. WARNING: devicemapper: usage of loopback devices is strongly discouraged for production use. Use `--storage-opt dm.thinpooldev` to specify a custom block storage device. [root@xserver1 ~]# docker run -d -v /opt/registry:/var/lib/registry -p 5000:5000 registry:latest b45c91876af54542dbc15706b7cb037e5b716068f7d33bba42df1f874d3d6bbf Docker运维 使用xserver1节点，上传nginx_latest.tar到xserver1节点中，然后将该镜像打标签，上传至私有仓库。使用xserver2节点，自行安装docker服务，配置xserver2节点使用xserver1的私有仓库，配置完毕后，在xserver2节点拉取nginx_latest.tar镜像。最后将在xserver2上执行docker images命令返回的结果以文本形式提交到答题框。 [root@xserver1 ~]# cd images [root@xserver1 images]# docker load -i nginx_latest.tar Loaded image: nginx:latest [root@xserver1 images]# docker tag nginx:latest 192.168.100.11:5000/nginx:latest [root@xserver1 images]# docker push 192.168.100.11:5000/nginx:latest The push refers to repository [192.168.100.11:5000/nginx] a89b8f05da3a: Pushed 6eaad811af02: Pushed b67d19e65ef6: Pushed latest: digest: sha256:f56b43e9913cef097f246d65119df4eda1d61670f7f2ab720831a01f66f6ff9c size: 948 [root@xserver1 ~]# cp -r Docker /opt/ [root@xserver2 ~]# vi /etc/yum.repos.d/ftp.repo # 添加 [docker] name=docker baseurl=ftp://xserver1/Docker gpgcheck=0 enabled=1 [root@xserver2 ~]# yum repolist [root@xserver2 ~]# yum install -y docker-ce [root@xserver2 ~]#systemctl daemon-reload [root@xserver2 ~]# systemctl start docker [root@xserver2 ~]# vi /etc/docker/daemon.json # 添加 { "insecure-registries": ["192.168.100.11:5000"] } [root@xserver2 ~]# systemctl restart docker [root@xserver2 ~]# docker pull 192.168.100.11:5000/nginx:latest [root@xserver2 ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE 192.168.100.11:5000/nginx latest 540a289bab6c 2 years ago 126MB Docker管理 假设当前存在docker镜像tomcat:latest，现在将tomcat镜像导出，导出名称为tomcat_images.tar，放在/media目录下，将以上操作命令填入答题框。 [root@xserver2 ~]# docker tag 192.168.100.11:5000/nginx:latest tomcat:latest [root@xserver2 ~]# docker save tomcat:latest > /media/tomcat_images.tar Dockerfile编写 使用xserver1节点，新建httpd目录，然后编写Dockerfile文件，要求如下：1)使用centos:latest镜像作为基础镜像；2)作者为xiandian；3)Dockerfile要求删除镜像的yum源，使用当前系统的local.repo源文件；4)安装http服务；5)暴露80端口。编写完毕后，构建的镜像名字叫httpd:v1.0的镜像。完成后将Dockerfile文件和镜像列表信息以文本形式提交到答题框。 [root@xserver1 ~]# mkdir httpd [root@xserver1 ~]# cd httpd/ [root@xserver1 httpd]# vi Dockerfile FROM centos:latest MAINTAINER xiandian RUN rm -f /etc/yum.repos.d/* COPY local.repo /etc/yum.repos.d/ RUN yum install -y httpd EXPOSE 80 [root@xserver1 httpd]# cat local.repo [centos] name=centos baseurl=ftp://192.168.100.11/centos gpgcheck=0 enabled=1 [root@xserver1 httpd]# docker build -t httpd:v1.0 . [root@xserver1 httpd]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE httpd v1 4ff5ef091914 19 seconds ago 220MB Dockerfile 编写 使用 xserver1 节点，新建目录 centos-jdk，将提供的 jdk-8u141-linux-x64.tar.gz 复制新建的目录，然后编辑 Dockerfile 文件，文件要求如下： 1.使用 centos:latest 基础镜像； 2.指定作者为 xiandian； 3.新建文件夹/usr/local/java 用于存放 jdk 文件； 4.将 JDK 文件复制到镜像内创建的目录并自动解压； 5.创建软连接：ln -s /usr/local/java/jdk1.8.0_141 /usr/local/java/jdk； 6.设置环境变量如下 ENV JAVA_HOME /usr/local/java/jdk ENV JRE_HOME ${JAVA_HOME}/jre ENV CLASSPATH .:${JAVA_HOME}/lib:${JRE_HOME}/lib ENV PATH ${JAVA_HOME}/bin:$PATH 编写完毕后，构建名为 centos-jdk 的镜像，构建成功后，查看镜像列表。 最后将 Dockerfile 的内容、构建镜像的操作命令、查看镜像列表的命令和返回的（简要）写到下方。 [root@xserver1 ~]# mkdir centos-jdk [root@xserver1 ~]# cd centos-jdk/ [root@xserver1 centos-jdk]# cat Dockerfile FROM centos:latest MAINTAINER xiandian WORKDIR /usr/local/java ADD jdk-8u141-linux-x64.tar.gz /usr/local/java RUN ln -s /usr/local/java/jdk1.8.0_141 /usr/local/java/jdk ENV JAVA_HOME /usr/local/java/jdk ENV JRE_HOME ${JAVA_HOME}/jre ENV CLASSPATH .:${JAVA_HOME}/lib:${JRE_HOME}/lib ENV PATH ${JAVA_HOME}/bin:$PATH [root@xserver1 centos-jdk]# cp /root/jdk/jdk-8u141-linux-x64.tar.gz . [root@xserver1 centos-jdk]# docker build -t centos-jdk:v1 . Sending build context to Docker daemon 185.5MB Step 1/9 : FROM centos:latest ---> 0f3e07c0138f Step 2/9 : MAINTAINER xiandian ---> Using cache ---> 380ab4775829 Step 3/9 : WORKDIR /usr/local/java ---> Running in 3d042489bc79 Removing intermediate container 3d042489bc79 ---> 0ca117e514c2 Step 4/9 : ADD jdk-8u141-linux-x64.tar.gz /usr/local/java ---> a46b588b978d Step 5/9 : RUN ln -s /usr/local/java/jdk1.8.0_141 /usr/local/java/jdk ---> Running in 5a6643a9a5cb Removing intermediate container 5a6643a9a5cb ---> 0bcbb2fbe73f Step 6/9 : ENV JAVA_HOME /usr/local/java/jdk ---> Running in 7522f805f7d4 Removing intermediate container 7522f805f7d4 ---> 3d366a42f998 Step 7/9 : ENV JRE_HOME ${JAVA_HOME}/jre ---> Running in b550575dc17e Removing intermediate container b550575dc17e ---> e0df108c1aed Step 8/9 : ENV CLASSPATH .:${JAVA_HOME}/lib:${JRE_HOME}/lib ---> Running in 1b439c9f4e25 Removing intermediate container 1b439c9f4e25 ---> bb89ab740e4e Step 9/9 : ENV PATH ${JAVA_HOME}/bin:$PATH ---> Running in d18c59ac844d Removing intermediate container d18c59ac844d ---> 59d4683996a7 Successfully built 59d4683996a7 Successfully tagged centos-jdk:v1 [root@xserver1 centos-jdk]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE centos-jdk v1 3ca44b341427 7 seconds ago 596MB 部署Swarm集群 使用xserver1、xserver2节点，自行配置好网络，安装好docker-ce。部署Swarm集群，并安装Portainer图形化管理工具，部署完成后，使用浏览器登录ip:9000界面，进入Swarm控制台。将curl swarm ip:9000返回的结果以文本形式提交到答题框。 [root@xserver1 ~]# docker swarm init --advertise-addr 192.168.100.11 Swarm initialized: current node (z9kmpvwdd1mcytddlr7qxfqz3) is now a manager. To add a worker to this swarm, run the following command: docker swarm join --token SWMTKN-1-31hn156p86fr6eo720rq9mqafckpw1who0i39dxv9m3tbpjd0l-86zun6fgtb3b56iguf91luoge 192.168.100.11:2377 To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions. [root@xserver2 ~]# docker swarm join --token SWMTKN-1-31hn156p86fr6eo720rq9mqafckpw1who0i39dxv9m3tbpjd0l-86zun6fgtb3b56iguf91luoge 192.168.100.11:2377 This node joined a swarm as a worker. [root@xserver1 centos-jdk]# docker node ls ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION 80cisraj17qq1tuawca29a8b1 * xserver1 Ready Active Leader 18.09.6 dsot82834vazufdo3x9y79lgj xserver2 Ready Active 18.09.6 [root@xserver1 ~]# docker tag 4cda95efb0e4 portainer/portainer:latest [root@xserver1 ~]# docker service create \ --name portainer \ --publish 9000:9000 \ --replicas=1 \ --constraint 'node.role == manager' \ --mount type=bind,src=//var/run/docker.sock,dst=/var/run/docker.sock \ --mount type=volume,src=portainer_data,dst=/data \ portainer/portainer -H unix:///var/run/docker.sock # 访问浏览器 访问IP:9000，设置密码
Nginx浏览目录 添加 ngx-fancyindex 模块 # 检查当前 nginx 版本 [root@ftp-server ~]# nginx -v nginx version: nginx/1.20.1 # 选择相应的版本 http://nginx.org/download/ wget http://nginx.org/download/nginx-1.20.1.tar.gz tar -xf nginx-1.20.1.tar.gz cd nginx-1.20.1 # 下载第三方模块 wget https://github.com/aperezdc/ngx-fancyindex/releases/download/v0.5.1/ngx-fancyindex-0.5.1.tar.xz tar -xf ngx-fancyindex-0.5.1.tar.xz # 安装编译工具 yum install -y gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel # 查询nginx 参数 [root@ftp-server nginx-1.20.1]# nginx -V nginx version: nginx/1.20.1 built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) built with OpenSSL 1.0.2k-fips 26 Jan 2017 TLS SNI support enabled configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module # 生成makefile文件 ./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --add-module=./ngx-fancyindex-0.5.1 # 编译&安装 make && make install # 查询模块 [root@ftp-server nginx-1.20.1]# nginx -V nginx version: nginx/1.20.1 built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) built with OpenSSL 1.0.2k-fips 26 Jan 2017 TLS SNI support enabled configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --add-module=./ngx-fancyindex-0.5.1 修改 nginx 配置文件 [root@ftp-server ~]# more /etc/nginx/nginx.conf worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name localhost; index index.html index.htm; charset utf-8,gbk; location / { root /data/downloads; fancyindex on; fancyindex_exact_size off; fancyindex_name_length 200; fancyindex_localtime on; fancyindex_time_format "%Y-%b-%d %H:%M"; fancyindex_ignore "fancyindex"; fancyindex_header "/fancyindex/header.html"; fancyindex_footer "/fancyindex/footer.html"; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } } 添加主题 仓库地址 https://github.com/TheInsomniac/Nginx-Fancyindex-Theme https://github.com/Naereen/Nginx-Fancyindex-Theme https://github.com/fraoustin/Nginx-Fancyindex-Theme https://github.com/alehaa/nginx-fancyindex-flat-theme # 下载相关代码放置 网页目录 [root@ftp-server ~]# tree -L 1 /data/downloads/fancyindex /data/downloads/fancyindex ├── clipboard.min.js ├── dialog-polyfill.css ├── dialog-polyfill.js ├── fancyindex.css ├── fancyindex.js ├── font ├── footer.html ├── header.html ├── images ├── material-icons.css ├── mdl ├── README.md └── roboto.css 效果 参考 Nginx 目录浏览基础与进阶