ç°¡åï¼ãããã®VPSã«coreOSãã¤ã³ã¹ãã¼ã«ããæ¹æ³
ãããã®VPSãå¥ç´ç´å¾ã®ç¶æ ãã10ã15åç¨åº¦ã§ã¤ã³ã¹ãã¼ã«ãå®äºãã¾ãã
SSHã§æºåãã
SSHã§ãã°ã¤ã³ãã¦ã¤ã³ã¹ãã¼ã«ã«å¿
è¦ãªãã¡ã¤ã«ãåéãã¾ãã
sshãªãã³ãã¼ï¼ãã¼ã¹ãã§ããã®ã§ããã®å¾ã®ã³ã³ã½ã¼ã«æä½ã§æãæããããã«ãã®æ®µéã§åºæ¥ãã ãçºãã¦ããã¾ãã
cloud-init
ã¾ã åå¼·ä¸ãªã®ã§æä½éã®è¨å®ã ããã¦ãã¾ãã
static.networkã®[Match]ã§æ©ãã§ãæ¹ãå¤ãã§ããeth*ã¯éæ¨å¥¨ã¿ãããªã®ã§MACAddressã§è¯ãã®ã§ã¯ã¨æã£ã¦ã¾ããæ©ç¨®ã«ä¾åããè¨å®ã¯çããããé£ããã§ããâã¢ããã¤ã¹ãå¾ ã¡ãã¦ããã¾ã
mkdir -p /tmp/work export VPS_IP=160.16.83.xx # VPSã®IPã¢ãã¬ã¹ export VPS_GATEWAY=160.16.82.1 # VPSã®GATEWAYã¢ãã¬ã¹ export VPS_DNS1=210.188.224.10 # ãã©ã¤ããªDNS export VPS_DNS2=210.188.224.11 # ã»ã«ã³ããªDNS export VPS_MAC=9C:A3:BA:01:CD:F1 # MACã¢ãã¬ã¹ export NTP_SERVER=ntp1.sakura.ad.jp # sakura以å¤ãªãntp.nict.jpãä¾¿å© export ETCD_HOST=`curl -s https://discovery.etcd.io/new` # ãã£ã¹ã«ããªã¼ç¨ã¢ãã¬ã¹ãçºè¡ãã cat > /tmp/work/cloud-config << EOT #cloud-config hostname: $HOSTNAME coreos: # etcd: # discovery: $ETCD_HOST # peer-addr: $VPS_IP:7001 units: # - name: etcd.service # command: start # - name: fleet.service # command: start - name: docker.service command: start - name: timezone.service command: start content: | [Unit] Description=set the timezone [Service] Type=oneshot ExecStart=/usr/bin/timedatectl set-timezone Asia/Tokyo RemainAfterExit=yes - name: swap.service command: start content: | [Unit] Description=Turn on swap [Service] Type=oneshot Environment="SWAPFILE=/swapfile" Environment="SWAPSIZE=1GiB" RemainAfterExit=true ExecStartPre=/usr/bin/sh -c '/usr/bin/fallocate -l \${SWAPSIZE} \${SWAPFILE} && chmod 0600 \${SWAPFILE} && /usr/sbin/mkswap \${SWAPFILE}' ExecStartPre=/usr/sbin/losetup -f \${SWAPFILE} ExecStart=/usr/bin/sh -c "/sbin/swapon \$(/usr/sbin/losetup -j \${SWAPFILE} | /usr/bin/cut -d : -f 1)" ExecStop=/usr/bin/sh -c "/sbin/swapoff \$(/usr/sbin/losetup -j \${SWAPFILE} | /usr/bin/cut -d : -f 1)" ExecStopPost=/usr/bin/sh -c "/usr/sbin/losetup -d \$(/usr/sbin/losetup -j \${SWAPFILE} | /usr/bin/cut -d : -f 1)" [Install] WantedBy=multi-user.target - name: static.network content: | [Match] MACAddress=$VPS_MAC [Network] Address=$VPS_IP/23 Gateway=$VPS_GATEWAY DNS=$VPS_DNS1 DNS=$VPS_DNS2 write_files: - path: /etc/ntp.conf content: | server $NTP_SERVER restrict $NTP_SERVER kod nomodify notrap nopeer noquery restrict default ignore restrict 127.0.0.1 ssh_authorized_keys: - ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEA5BqkP+ToroYtzOhnZ2aOJj8WqUpRcQRy/D2ojlPsQutM9Pqfo3qI+75iLpTAAkt+X0RlSBNFLfLsDgfV45IWS/5jv7CKLF/AAIU8Ke5wKVXZrC1LkZ7HfnluALhepUkeB3ilrhFQS+qeS8LHw2s2C2Ig/bGj8lXuEyt93aSREIU= [email protected] EOT
â»å ¬ééµã¯èªåã®ã«æ¸ãå¤ãã¦ãã ããã
ãã¡ã¤ã«ã®åé
installerã®ä¸ã§å¼ã°ããã³ãã³ããè¨å®ãã¡ã¤ã«ãæºåãã¾ãã
(ã³ã³ã½ã¼ã«ã§viã¨ãé¢åèãã®ã§åºæ¥ãã ããã®æ®µéã§ç¨æãã¾ããã)
cp /sbin/{blockdev,wipefs,blkid} /tmp/work/ cp /bin/{mktemp,sed,grep,bash,lsblk,env,mkdir,rm,mount,umount,echo,cp} /tmp/work/ cp /usr/bin/{tee,wget,gpg,bzip2,which} /tmp/work/ (cd /tmp/work && ln -f bzip2 bunzip2) echo 'nameserver 8.8.8.8' > /tmp/work/resolv.conf
coreos-install
coreOSã®ã¤ã³ã¹ãã¼ã©ã¼æ¬ä½ããã¦ã³ãã¼ããã¦ä»ã®ãã¡ã¤ã«ã¨å
±ã«ã¢ã¼ã«ã¤ããã¾ãã
ä¸è¦ãã¡ã¤ã«ã¯åé¤ãã¦ããã¾ãããã
wget -O /tmp/work/coreos-install https://raw.githubusercontent.com/coreos/init/master/bin/coreos-install (cd /tmp/work && tar cf /work.tar ./) rm -rf /tmp/work/ sync
VNCã³ã³ã½ã¼ã«ãç«ã¡ä¸ãã
ã³ã³ããã¼ã«ããã«ããã«ã¹ã¿ã OSã¤ã³ã¹ãã¼ã«ãé¸æãã¦ãCentOS7 x86_64ããã¤ã³ã¹ãã¼ã«ããVNCã³ã³ã½ã¼ã«ãç«ã¡ä¸ãã¾ãã
(/dev/vdaã解æ¾ããç¶æ
ã§ã·ã§ã«ã使ãããã ããªã®ã§äºææ§ã®ããOSãªããªãã§ããã¾ãã¾ãã)
ãRescue a CentOS systemããé¸æ
coreOSãinstallãã
ãã°ããããã¨ã·ã§ã«ãç«ã¡ãããã¾ãã®ã§ã¾ãã¯å ã»ã©ä½æããwork.tarãåãåºãã¾ãã
mkdir -p /mnt/root mount /dev/vda3 /mnt/root tar xf /mnt/root/work.tar -C /tmp umount /mnt/root
coreOSã®installä¸ã«ãããã¯ã¼ã¯ãå¿ è¦ã«ãªãã®ã§ãããã¯ã¼ã¯ãæå¹ã«ãã¾ãã
ifconfig eth0 160.16.83.xx(IPã¢ãã¬ã¹)/23 route add default gw 160.16.xx.1(ã²ã¼ãã¦ã§ã¤) cp /tmp/resolv.conf /etc/
ãcoreos-installããå®è¡ãã¾ãã
export PATH=$PATH:/tmp/ bash /tmp/coreos-install -d /dev/vda -C stable -c /tmp/cloud-config
ãSuccess! CoreOS stable current is installed on /dev/vdaãã¨è¡¨ç¤ºããããã·ã£ãããã¦ã³ããã³ã³ããã¼ã«ããã«ããèµ·åãã¾ãã
(rebootã ã¨ã«ã¹ã¿ã OSã¤ã³ã¹ãã¼ã«ãçµãããªãã®ã§ã·ã£ãããã¦ã³ãå¿
è¦ã§ã)