設為首頁

收藏本站

導覽首頁 | 新登場    ◇聯盟溫泉 | 民宿 | 人力銀行 | 女性 |

類型:Linux_article

遠端安裝升級CentOS How to Install CentOS Remotely
Anaconda安裝在遠程服務器上安裝或更新操作系統,可以大大簡化程序。

The recently posted article describes how to remotely reinstall Debian Linux. In this post I’d like to share a quick and easy way to remotely install CentOS or Fedora. Anaconda installer can considerably simplify the procedure of installing or updating the operating system on a remote server.

Here is a quotation from the web page of the project where the anaconda options we’ll use are described:

anaconda is a fairly sophisticated installer. It supports installation from local and remote sources such as CDs and DVDs, images stored on a hard drive, NFS, HTTP, and FTP. Installation can be scripted with kickstart to provide a fully unattended installation that can be duplicated on scores of machines. It can also be run over VNC on headless machines.


Anaconda 是一個多元化的安裝程序。它支持從本地和遠程的來源,如CD和DVD,硬盤驅動器上存儲的圖像,NFS,HTTP和FTP的安裝。它也可以通過VNC運行無頭機器上。

Everything described below also fits for any Linux distribution package which uses grub to boot. Examples from the article were tested on grub 0.97, but grub2 can be used as well after making minor changes. Besides, I used this method when I replaced FreeBSD with Linux, after installing grub as a loader instead of regular Boot Manager.
grub2可以用作更改的輔助。

Preparation involves four steps:
準備工作涉及到的四個步驟
Determining network settings of the server;
Loading images for the selected OS;
Preparing the configuration and adding it to grub.conf;
Server restart and connection to it through VNC.


Determining network settings of the server
確定服務器的網絡設置
You will need the gateway address, as well as server’s and DNS IP addresses. You also will need MAC address of the main network card. It is essential to specify the latter, because if the server has two network cards, it is likely that the installer will choose the wrong one. To determine the network settings, you can use the following commands:


ifconfig
ip route show
cat /etc/sysconfig/network-scripts/ifcfg-eth0
cat /etc/sysconfig/network
cat /etc/resolv.conf

in our case they are the following:

Ip 172.17.17.232
Gateway 172.17.17.1
DNS 172.17.17.1
MAC 52:54:00:4a:25:b5


Loading images
CentOS and Fedora use different images to boot the installer. You should pick the right images, depending on what distribution package you’re going to install. In addition, if are going to install a 32-bit version, you should replace x86_64 in url with i386.

Images for centos 5.6 (x86_64):


Images for fedora 15 (x86_64):



Preparing the configuration and adding it to grub.conf
Specify the gateway address[b], [b]server’s and DNS IP addresses you saved earlier, as well as the URL where the installer will download rpm packages from. Also, specify optional parameters like absence of a monitor, selection of the particular network card, and a password for vnc.

If /boot partition isn’t the first one on the disk, correct the line root(hd0,0), so that it corresponds to the number of the partition.

Now add these lines to grub.conf
for Centos 5.6:

title Remote Install
root (hd0,0)
kernel /vmlinuz_remote lang=en_US keymap=us method=http://mirrors.supportex.net/centos/5.6/os/x86_64/ vnc vncpassword=SuperSecret ip=172.17.17.232 netmask=255.255.255.0 gateway=172.17.17.1 dns=172.17.17.1 noselinux ksdevice=52:54:00:4a:25:b5 headless xfs panic=120
initrd /initrd_remote.img

or for fedora 15:

title Remote Install
root (hd0,0)
kernel /vmlinuz_remote lang=en_US keymap=us method=http://download.fedora.redhat.com/pub/fedora/linux/releases/15/Fedora/x86_64/os/ vnc vncpassword=SuperSecret ip=172.17.17.232 netmask=255.255.255.0 gateway=172.17.17.1 dns=172.17.17.1 noselinux ksdevice=52:54:00:4a:25:b5 headless xfs panic=120
initrd /initrd_remote.img

It is assumed that this configuration is the second item in the menu. You’ve specified that grub should make one attempt to load it. If something goes wrong, you’ll go back to the pre-set distribution after a restart, in 120 seconds.

[root@localhost ~]# echo 'savedefault --default=1 --once' | grub --batch

You can read about boot options of anaconda in more detail here http://fedoraproject.org/wiki/Anaconda/Options

Server restart and connection to it through VNC
Reboot the server and wait until it begins to respond to ping. Additional packages will take some time to load, then it will be possible to connect through VNC. If the network isn’t fast enough, it may take about 20-30 minutes.

Now connect to the server and do the same as on the local console: vncviewer 172.17.17.232:1
If you’re working from Windows, you can use TightVNC.

Tips
A VNC server starts without keep-alive, so if you are connected through nat, there is a chance to lose a session and no longer recover it due to unactivity. You’d better disconnect from vnc and then connect again, if VNC console isn’t going to be used for a long time.

You needn’t format boot section as ext4, though both Fedora and Centos offer it by default. Sometimes, installed operating system doesn’t load from this section. It happens extremely rarely, but it’s better not to run the risk.

If Fedora is installed in minimum configuration, ‘network’ service turns out to be not activated. It can be fixed by adding sshd and sshpw=password to anaconda settings, specifying a password for ssh. Access the remote server through ssh and activate ‘network’ service after the interactive installation is completed and before the installer is restarted:

# chroot /mnt/sysimage
# chkconfig network on
# exit

104休閒信箱 2.3.0 © 104mm.com 2001 - 2018. 您尚未登錄
Page generated in 0.01183701 seconds with 3 Queries