ForemanTips

System

Install Ubuntu 18.04, 4 Core/ 4G memory, 50 G disk.

Install with basic sshd support.

/images/2019_03_14_15_20_12_676x259.jpg

Network planning:
10.192.189.0/24, no dhcp.

Network

Configure the networking via following commands:

# vim /etc/netplan/01-netcfg.yaml
network:
  version: 2
  renderer: networkd
  ethernets:
    enp1s0:
      dhcp4: no
      addresses: [10.192.189.2/24]
      gateway4: 10.192.189.1
      nameservers:
        addresses: [223.5.5.5,180.76.76.76]

# netplan --debug apply
# systemctl disable systemd-resolved.service
# systemctl stop systemd-resolved.service
# rm -f /etc/resolv.conf 
# echo nameserver 223.5.5.5>/etc/resolv.conf

Configure the hostname:

# sudo hostnamectl set-hostname foreman.fuck.com
# echo "10.192.189.2 foreman.fuck.com" | sudo tee -a /etc/hosts

Install foreman

Install foreman via following commands:

......

Refers to:

https://computingforgeeks.com/how-to-install-foreman-on-ubuntu-18-04-lts-bionic-beaver/

UsbNetworkCard

Using systemd-networkd for configurating the usb network card,

# vim /etc/systemd/nework/10-ethusb1.link
[Match]
MACAddress=00:xx:xx:.....

[Link]
Description=USB to Ethernet Adapter
Name=ethusb1

Then configurating the ethusb1 ip address:

# vim /etc/systemd/network/10-ethusb1.network 
[Match]
Name=ethusb1

[Network]
Address=192.168.0.33

Reboot the computer then you could see the ethusb1 available.

MegaCliForPartition

目的

分区,以便虚拟化场合.

硬件:24块硬盘,前两块做成系统盘,其他的则是单独配置:

/images/2019_03_11_09_13_41_447x495.jpg

查看现有分区

使用以下命令查看当前分区的情况:

# ./MegaCli64 -PDList -aAll | more

注意记录下有关磁盘情形,如:

/images/2019_03_11_09_20_11_473x516.jpg

Slot Number应该是升序的,0-23是SATA盘,38/39是SAS盘,记录下这一组数值,因为后面我们会针对这些值来分区。Slot Number是0

查看raid信息:

# ./MegaCli64 -LDInfo -Lall -aAll

/images/2019_03_11_09_47_56_721x783.jpg

除了virtual driver 0, 其他的都需要被删除。

貌似是有问题的,先装proxmox再操作。

Raid卡配置

F2, 弹出配置:

/images/2019_03_11_10_01_08_684x418.jpg

Delete Drive Group:

/images/2019_03_11_10_01_32_466x309.jpg

最后情况:

/images/2019_03_11_10_03_06_597x376.jpg

分区

脚本如下, 4组,而后为热备4个:

./MegaCli64 -CfgLdAdd -r5 [0:0,0:1,0:2,0:3,0:4] WB Direct -a0
./MegaCli64 -CfgLdAdd -r5 [0:5,0:6,0:7,0:8,0:9] WB Direct -a0
./MegaCli64 -CfgLdAdd -r5 [0:10,0:11,0:12,0:13,0:14] WB Direct -a0
./MegaCli64 -CfgLdAdd -r5 [0:15,0:16,0:17,0:18,0:19] WB Direct -a0
./MegaCli64 -PDHSP -Set [-EnclAffinity] [-nonRevertible] -PhysDrv[0:20] -a0
./MegaCli64 -PDHSP -Set [-EnclAffinity] [-nonRevertible] -PhysDrv[0:21] -a0
./MegaCli64 -PDHSP -Set [-EnclAffinity] [-nonRevertible] -PhysDrv[0:22] -a0
./MegaCli64 -PDHSP -Set [-EnclAffinity] [-nonRevertible] -PhysDrv[0:23] -a0

BootUpSequence

服务器配置:

/images/2019_03_08_10_46_27_657x334.jpg

按del键进入BIOS,更改启动顺序:

/images/2019_03_08_10_46_52_404x161.jpg

插入ISO盘:

/images/2019_03_08_10_47_11_600x196.jpg

选择English,进入安装界面:

/images/2019_03_08_10_47_37_437x464.jpg

手动分区:

/images/2019_03_08_10_48_04_651x401.jpg

原有分区, sda:

/images/2019_03_08_10_48_24_498x336.jpg

删除后创建逻辑卷:

/images/2019_03_08_10_48_52_527x249.jpg

/images/2019_03_08_10_48_04_651x401.jpg

原有分区, sda:

/images/2019_03_08_10_48_24_498x336.jpg

删除后创建逻辑卷:

/images/2019_03_08_10_48_52_527x249.jpg

挂载到根分区:

/images/2019_03_08_10_49_53_625x256.jpg

磁盘布局最后检查:

/images/2019_03_08_10_50_08_528x210.jpg

Install continue。。。。

Grub配置,手动选择/dev/sda:

/images/2019_03_08_10_50_41_565x297.jpg

重新启动,弹出光盘:

![/images/2019_03_08_10_51_09_450x162.jpg](/images/2019_03_08_10_51_09 Install continue。。。。

Grub配置,手动选择/dev/sda:

/images/2019_03_08_10_50_41_565x297.jpg

重新启动,弹出光盘:

/images/2019_03_08_10_51_09_450x162.jpg

System boot:

/images/2019_03_08_10_51_36_583x410.jpg

BuildingPWKCD

MakeISO Server

Configure via:

# apt-get update -y 
# apt-get install -y vim openssh-server

Install cubic via:

# apt-add-repository ppa:cubic-wizard/release
# apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 6494C6D6997C215E
# apt-get update -y && apt-get install -y cubic

cubic make iso

Start cubic via:

/images/2019_02_20_16_20_41_429x333.jpg

Create the iso project folder:

# mkdir ~/isoproject

Slect the original disk image to customize:

/images/2019_02_20_16_28_24_516x413.jpg

Cubic will copy the content from the origin folder to remote folder, this will takes for some time:

/images/2019_02_20_16_29_11_495x357.jpg

In chroot terminal you could custom the cd:

/images/2019_02_20_16_32_14_516x207.jpg

CD customize

Install docker/docker-compose

# vim /etc/apt/sources.list(Changes to 163.com)
# apt-get install -y python-pip && pip install docker-compose
# ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
# apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common

# curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

# apt-key fingerprint 0EBFCD88
# add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
# apt-get install docker-ce docker-ce-cli containerd.io
# docker version

The current Version is :

/images/2019_02_20_16_52_47_505x133.jpg

Cause we are under chroot, we don’t have server running.

We fetch the pwk ready machine’s /var/lib/docker, transfer them into our chroot env:

/images/2019_02_20_17_06_27_549x122.jpg

We also need golang for running the pwk environment:

# apt-get install -y golang
# vim /root/.bashrc

Transfer the golang environment from the pwk ready machine:

# ls /root
 go/ Code/

systemd file:

root@test-Standard-PC-Q35-ICH9-2009:/etc/systemd/system# cat mynginx.service 
[Unit]
Description=mynginx
Requires=docker.service
After=docker.service

[Service]
Restart=always
ExecStart=/usr/bin/docker start -a docker-nginx
ExecStop=/usr/bin/docker stop -t 2 docker-nginx

[Install]
WantedBy=multi-user.target

root@test-Standard-PC-Q35-ICH9-2009:/etc/systemd/system# cat playwithdockerblog.service 
[Unit]
Description=playwithdockerblog
After=docker.service
Requires=docker.service

[Service]
ExecStart=/usr/bin/docker-compose -f /root/Code/play-with-kubernetes.github.io/docker-compose.yml up -d

[Install]
WantedBy=multi-user.target
root@test-Standard-PC-Q35-ICH9-2009:/etc/systemd/system# cat playwithdocker.service 
[Unit]
Description=playwithdocker
After=docker.service
Requires=docker.service

[Service]
Environment=GOPATH=/root/go/
WorkingDirectory=/root/go/src/github.com/play-with-docker/play-with-docker
Type=idle
# Remove old container items
ExecStartPre=/usr/bin/docker-compose -f /root/go/src/github.com/play-with-docker/play-with-docker/docker-compose.yml down
# Compose up
ExecStart=/usr/bin/docker-compose -f /root/go/src/github.com/play-with-docker/play-with-docker/docker-compose.yml up -d

[Install]
WantedBy=multi-user.target

ToBeContinue, later I will change the static website content, and k8s image offline, then do the iso-build.