我遇到了一个关于自动服务器安装的问题。
这是我的env: Server: CentOS7.6 x86_64(一个kvm系统) Node1: no system Node2: no system
我想自动安装Ubuntu-20.04.3服务器系统。
关于Server1,我安装了tftpd、dhcpd、httpd。像这样的配置:
# tftpd
# cat /etc/xinetd.d/tftp
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /var/lib/tftpboot
disable = yes
per_source = 11
cps = 100 2
flags = IPv4
}
# dhcpd
# cat /etc/dhcp/dhcpd.conf
ddns-update-style none;
subnet 10.10.8.0 netmask 255.255.252.0 {
option routers 10.10.11.254;
option domain-name-servers 10.10.9.250;
option subnet-mask 255.255.252.0;
range dynamic-bootp 10.10.11.10 10.10.11.220;
default-lease-time 21600;
max-lease-time 43200;
next-server 10.10.11.245;
filename "pxelinux.0";
}
# httpd
# cat /etc/httpd/conf.d/tftp.conf
Options +FollowSymLinks +Indexes
Require all granted
Alias /tftp /var/lib/tftpboot/var/lib/tftpboot中的文件
# ll /var/lib/tftpboot/
总用量 1328744
drwxrwxrwx 2 root root 22 12月 8 18:40 grub
-rwxrwxrwx 1 root root 86017541 11月 25 17:40 initrd
-rwxrwxrwx 1 root root 31 11月 25 17:45 meta-data
-rwxrwxrwx 1 root root 336 12月 8 20:03 network.sh
-rwxrwxrwx 1 root root 1435512 4月 16 2020 pxelinux.0
-rwxrwxrwx 1 root root 1261371392 8月 24 17:09 ubuntu-20.04.3-live-server-amd64.iso
-rwxrwxrwx 1 root root 1353 12月 8 20:03 ubuntu_init.sh
-rwxrwxrwx 1 root root 2856 12月 8 20:17 user-data
-rwxrwxrwx 1 root root 11772160 11月 25 17:40 vmlinuzgrub.cfg
# cat grub/grub.cfg
default=autoinstall
timeout=5
timeout_style=menu
set menu_color_normal=white/black
set menu_color_highlight=black/light-gray
menuentry "Focal Live Installer - automated" --id=autoinstall {
echo "Loading Kernel...1111"
linux /vmlinuz root=/dev/ram0 ramdisk_size=1500000 root=/dev/ram0 ramdisk_size=1500000 ip=dhcp url=http://10.10.11.245/tftp/ubuntu-20.04.3-live-server-amd64.iso autoinstall ds=nocloud-net\;s=http://10.10.11.245/tftp/ ---
echo "Loading Ram Disk...111"
initrd /initrd
}
menuentry "Focal Live Installer" --id=install {
echo "Loading Kernel...22"
linux /vmlinuz root=/dev/ram0 ramdisk_size=1500000 ramdisk_size=1500000 ip=dhcp url=http://10.10.11.245/tftp/ubuntu-20.04.3-live-server-amd64.iso
echo "Loading Ram Disk...22"
initrd /initrd
}元数据
# cat meta-data
instance-id: focal-autoinstall用户数据
# cat user-data
#cloud-config
autoinstall:
apt:
geoip: true
preserve_sources_list: false
primary:
- arches: [amd64, i386]
uri: http://mirrors.aliyun.com/ubuntu
- arches: [default]
uri: http://ports.ubuntu.com/ubuntu-ports
user-data:
timezone: Asia/Shanghai
disable_root: false
chpasswd:
list: |
root:$6$YMYlEcE71$/bcl2qd2rSYePvOkmgAyQR/h/
identity: {hostname: 111, password: $6$ereNXNuj9WVUt77B$.dbpuHaLernNl6qq6r14meIk1W5VAyaMV9.,
realname: 11, username: 11}
keyboard: {layout: us, toggle: null, variant: ''}
locale: en_US.UTF-8
network:
ethernets:
eno12399:
critical: true
dhcp-identifier: mac
dhcp4: true
nameservers:
addresses: [10.10.9.250]
eno12409: {dhcp4: true}
eno12419: {dhcp4: true}
eno12429: {dhcp4: true}
eno8303: {dhcp4: true}
eno8403: {dhcp4: true}
version: 2
proxy: http://mirrors.aliyun.com/ubuntu
ssh:
allow-pw: true
authorized-keys: []
install-server: true
storage:
grub:
reorder_uefi: False
config:
- {ptable: gpt, path: /dev/sda, wipe: superblock-recursive, preserve: false, name: '', grub_device: false,
type: disk, id: disk-sda}
- {device: disk-sda, size: 536870912, wipe: superblock, flag: boot, number: 1,
preserve: false, grub_device: true, type: partition, id: partition-2}
- {fstype: fat32, volume: partition-2, preserve: false, type: format, id: format-2}
- {device: disk-sda, size: -1, wipe: superblock, flag: '', number: 2,
preserve: false, grub_device: false, type: partition, id: partition-3}
- {fstype: xfs, volume: partition-3, preserve: false, type: format, id: format-3}
- {path: /, device: format-3, type: mount, id: mount-3}
- {path: /boot/efi, device: format-2, type: mount, id: mount-2}
updates: security
packages:
- linux-generic
- net-tools
late-commands:
- curtin in-target --target=/target -- /usr/bin/wget -P /root/ http://10.10.11.245/tftp/ubuntu_init.sh
- curtin in-target --target=/target -- /usr/bin/wget -P /root/ http://10.10.11.245/tftp/network.sh
- curtin in-target --target=/target -- /usr/bin/bash /root/ubuntu_init.sh
#- curtin in-target --target=/target -- sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config && systemctl restart sshd
#- curtin in-target --target=/target -- systemctl stop ufw.service && systemctl disable ufw.service
#- curtin in-target --target=/target -- echo -e "NTP=ntp1.aliyun.com\nFallbackNTP=ntp.ubuntu.com" >> /etc/systemd/timesyncd.conf && systemctl restart systemd-timesyncd
version: 1Ubuntu_init.sh
#!/bin/bash
sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
systemctl restart sshd
systemctl stop ufw.service
systemctl disable ufw.service
#
echo -e "NTP=ntp1.aliyun.com\nFallbackNTP=ntp.ubuntu.com" >> /etc/systemd/timesyncd.conf
systemctl restart systemd-timesyncd
#
cat >> /etc/security/limits.conf << EOF
* soft nofile 655350
* hard nofile 655350
* soft nproc 655350
* hard nproc 655350
root soft nofile 655350
root hard nofile 655350
root soft nproc 655350
root hard nproc 655350
EOF
########################################
cp /etc/sysctl.conf /etc/sysctl.conf.bak
cat > /etc/sysctl.conf << EOF
vm.swappiness = 0
kernel.sysrq = 1
net.ipv4.neigh.default.gc_stale_time = 120
net.ipv4.conf.all.rp_filter = 0
net.ipv4.conf.default.rp_filter = 0
net.ipv4.conf.default.arp_announce = 2
net.ipv4.conf.lo.arp_announce = 2
net.ipv4.conf.all.arp_announce = 2
net.ipv4.tcp_max_tw_buckets = 5000
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_max_syn_backlog = 1024
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_slow_start_after_idle = 0
EOF
/sbin/sysctl -p当我在戴尔、R750或其他开放的UEFI服务服务器机器上运行pxe时,自动安装。tftp,dhcpd,httpd都可以。但是当服务器执行像wget或curl这样的“迟命令”时,就会报告一个错误。其他bash命令可以执行无错误,如echo、sed、systemctl start service等。
当自动安装错误时,请报告一个错误并破坏此系统安装。我使用wget可以从httpd服务器和exectue下载bash文件。
图片:误差pic
如果您缓慢地打开错误图片,下面是错误文本描述:
start: subiquity/Late/run/command_0: curtin in-target --target=/target -- /usr/bin/wget -P /root/ http://10.10.11.245/tftp/ubuntu_init.sh
start: subiquity/Meta/status_GET
finish: subiquity/Late/run/command_0: Command '['system-cat', '--level-prefix=false', '--identifier=subiquity_log.3140', 'sh', 'c', 'curtin in-target --target=/target --/usr/bin/wget -P /root/ http://10.10.11.245/tftp/ubuntu_init.sh']' returned non-zero exit status 8.ip a httpd日志
10.10.11.94 - - [13/Dec/2021:15:58:40 +0800] "GET /tftp/ubuntu-20.04.3-live-server-amd64.iso HTTP/1.1" 200 1261371392 "-" "Wget"
10.10.11.94 - - [13/Dec/2021:15:59:01 +0800] "GET /tftp/ubuntu-20.04.3-live-server-amd64.iso HTTP/1.1" 200 1261371392 "-" "Cloud-Init/21.2-3-g899bfaa9-0ubuntu2~20.04.1"
10.10.11.94 - - [13/Dec/2021:15:59:13 +0800] "GET /tftp/ubuntu-20.04.3-live-server-amd64.iso HTTP/1.1" 200 1261371392 "-" "Cloud-Init/21.2-3-g899bfaa9-0ubuntu2~20.04.1"
10.10.11.94 - - [13/Dec/2021:15:59:25 +0800] "GET /tftp/meta-data HTTP/1.1" 200 31 "-" "Cloud-Init/21.2-3-g899bfaa9-0ubuntu2~20.04.1"
10.10.11.94 - - [13/Dec/2021:15:59:25 +0800] "GET /tftp/user-data HTTP/1.1" 200 2772 "-" "Cloud-Init/21.2-3-g899bfaa9-0ubuntu2~20.04.1"
10.10.11.94 - - [13/Dec/2021:15:59:25 +0800] "GET /tftp/vendor-data HTTP/1.1" 404 214 "-" "Cloud-Init/21.2-3-g899bfaa9-0ubuntu2~20.04.1"
10.10.11.94 - - [13/Dec/2021:15:59:26 +0800] "GET /tftp/vendor-data HTTP/1.1" 404 214 "-" "Cloud-Init/21.2-3-g899bfaa9-0ubuntu2~20.04.1"
10.10.11.94 - - [13/Dec/2021:15:59:27 +0800] "GET /tftp/vendor-data HTTP/1.1" 404 214 "-" "Cloud-Init/21.2-3-g899bfaa9-0ubuntu2~20.04.1"
10.10.11.94 - - [13/Dec/2021:15:59:28 +0800] "GET /tftp/vendor-data HTTP/1.1" 404 214 "-" "Cloud-Init/21.2-3-g899bfaa9-0ubuntu2~20.04.1"
10.10.11.94 - - [13/Dec/2021:15:59:29 +0800] "GET /tftp/vendor-data HTTP/1.1" 404 214 "-" "Cloud-Init/21.2-3-g899bfaa9-0ubuntu2~20.04.1"
10.10.11.94 - - [13/Dec/2021:15:59:30 +0800] "GET /tftp/vendor-data HTTP/1.1" 404 214 "-" "Cloud-Init/21.2-3-g899bfaa9-0ubuntu2~20.04.1"
10.10.11.94 - - [13/Dec/2021:15:59:31 +0800] "GET /tftp/vendor-data HTTP/1.1" 404 214 "-" "Cloud-Init/21.2-3-g899bfaa9-0ubuntu2~20.04.1"
10.10.11.94 - - [13/Dec/2021:15:59:32 +0800] "GET /tftp/vendor-data HTTP/1.1" 404 214 "-" "Cloud-Init/21.2-3-g899bfaa9-0ubuntu2~20.04.1"
10.10.11.94 - - [13/Dec/2021:15:59:33 +0800] "GET /tftp/vendor-data HTTP/1.1" 404 214 "-" "Cloud-Init/21.2-3-g899bfaa9-0ubuntu2~20.04.1"
10.10.11.94 - - [13/Dec/2021:15:59:34 +0800] "GET /tftp/vendor-data HTTP/1.1" 404 214 "-" "Cloud-Init/21.2-3-g899bfaa9-0ubuntu2~20.04.1"
10.10.11.94 - - [13/Dec/2021:15:59:35 +0800] "GET /tftp/vendor-data HTTP/1.1" 404 214 "-" "Cloud-Init/21.2-3-g899bfaa9-0ubuntu2~20.04.1"I手动执行它,没有错误。
如果有人知道如何解决这个问题,或者和我的问题一样,请给我发信息,谢谢。
如果我没有说清楚,你可以指出。
发布于 2021-12-15 23:05:07
您的问题可能是由proxy配置引起的。
proxy: http://mirrors.aliyun.com/ubuntu我发现如果您指定一个代理,那么所有的web流量都将使用该代理。下载脚本的wget尝试是通过代理发送的,失败了。
使用proxy的方式之一是将环境变量http_proxy和https_proxy设置为安装程序环境中的proxy值。在发出web请求时,wget使用这些环境变量来确定代理。下面是一些简单的命令行,您可以在安装程序环境shell (实际上是任何Linux系统)中进行验证。
这应该可以工作,因为没有设置代理。
http_proxy= wget http://10.10.11.245/tftp/ubuntu_init.sh这应该与您的日志显示的8返回代码一起出错并退出。
http_proxy=http://mirrors.aliyun.com/ubuntu wget http://10.10.11.245/tftp/ubuntu_init.sh
echo $?选项
以下是解决此问题的几种可用方法。
proxy。early_commands似乎不受proxy的影响,因此可以下载脚本。 early-commands:
- /usr/bin/wget -P /run/ http://10.10.11.245/tftp/ubuntu_init.shlate-commands中取消相关的环境变量。每个命令都必须这样做。 late-commands:
- http_proxy= curtin in-target --target /target -- /usr/bin/wget -P /root/ http://10.10.11.245/tftp/ubuntu_init.sh<#>说明
我使用Ubuntu 20.04.3安装程序(subiquity 21.08.2)进行了测试。
https://askubuntu.com/questions/1380674
复制相似问题