I have to change IP numbers across a number of virtual and physical machines because of network center move. This has to be done before network startup, of course. I'm thinking about the best method to do this. Where should I include/init this script? Or would it rather make more sense to do this on the last shutdown? Changes largely involve removing old files and putting new files in place (resolv.conf, hosts, sysconfig/network + network-scripts, firewall, postfix, httpd etc.). The only other change besides replacing files would be changing the IP address in a webcontrol interface in a MySQL table, so this part has to be done after MySQL startup. Could be run-once or have to disable manually after successful startup. Thanks, Kai
Kai Schaetzl wrote:> Changes largely involve removing old files and putting new files in place > (resolv.conf, hosts, sysconfig/network + network-scripts, firewall, > postfix, httpd etc.). The only other change besides replacing files would > be changing the IP address in a webcontrol interface in a MySQL table, so > this part has to be done after MySQL startup.If I needed to do this, I would start by making a tarball of all files that need to changed. Then I would edit the files as needed and make a tarball of the new version. Next I would write two scripts, one to enable the new settings and one to restore the old settings. At the end of each script restart network services. Then create an at job to enable the new settings at now+2min and another to restore the former settings at now+7min. In two minutes you should be able to ssh to the host and cancel the second at job. If anything goes wrong, just wait 5 minutes and old network settings are back. c
Kai Schaetzl wrote:> I have to change IP numbers across a number of virtual and physical > machines because of network center move. This has to be done before > network startup, of course. I'm thinking about the best method to do this. > Where should I include/init this script? Or would it rather make more > sense to do this on the last shutdown?I just noticed that this is a one-time occurrence after the move to a new network. In this case there is no need to schedule the at job. Just make a backup of files you are changing, then make the changes. They will not take effect immediately unless you restart any of the services. (So don't restart an services or reboot the server prior to the move.) Plan a time to make the changes prior to shutting down at the old data center. They should come up correctly in the new environment. c
Kai Schaetzl wrote:> I have to change IP numbers across a number of virtual and physical > machines because of network center move. This has to be done before > network startup, of course. I'm thinking about the best method to do this. > Where should I include/init this script? Or would it rather make more > sense to do this on the last shutdown? > > Changes largely involve removing old files and putting new files in place > (resolv.conf, hosts, sysconfig/network + network-scripts, firewall, > postfix, httpd etc.). The only other change besides replacing files would > be changing the IP address in a webcontrol interface in a MySQL table, so > this part has to be done after MySQL startup. > > Could be run-once or have to disable manually after successful startup. >There are several possibilities (this *is* *Nix, after all), but several questions first: aren't you using dhcp to give them IPs? Won't the dhcp client rewrite resolv.conf? For the other stuff, if it needs to run once, why not have the script looking for a lock file, and if it's not there run, ending by creating the lock file. Then, after everything's up and wonderfully correct, you can run a script everywhere that, if it finds the lockfile, deletes both that, and the script? mark
On 9/20/2013 5:31 AM, Kai Schaetzl wrote:> I have to change IP numbers across a number of virtual and physical > machines because of network center move. This has to be done before > network startup, of course. I'm thinking about the best method to do this. > Where should I include/init this script? Or would it rather make more > sense to do this on the last shutdown?reconfigure the servers to use dhcp and configure the hosts via reservations on the dhcp servers. new location on a new subnet would have require reservations, reboot and voila! DNS should be taking care of any application stuff (when the servers are moved, their entries are updated on the DNS servers) -- john r pierce 37N 122W somewhere on the middle of the left coast
Reindl Harald wrote on Fri, 20 Sep 2013 14:32:46 +0200:> /etc/rc.d/rc.localThanks for all the answers. First, I omitted to explicitely state that these are web servers. There is no dhcp, only one or, in a few cases, a few IP static IP addresses. Mostly Centos 5. Changing the data is *not* the problem. As already said this will mostly be done by replacing config files (cp -a, not mv, this assures it can be done even more than once without a problem, replacement operations in files always ask for trouble if something non-standard happens, not to mention one has to code this - it's easier just to provide the correct new files), and by reading in a sql command that replaces an IP address in some tables. The big question is when and how to do this. rc.local seems to be a good place for reading in the sql command. But it doesn't seem to be a good place for all the other commands, especially the initial network setup. It's executed *after* all ini stuff is done, e.g. all daemons and network are started. Problem is that some network services may hang the whole machine for a minute or longer if they cannot establish networking (which would be the case with wrong data either for the ifcfg files or the config file of the daemon). At the moment I know of only one daemon which behaves this way (bigsister), but I may have forgotten about others. I don't want to wait until the timeout kicks in, the init continues and rc.local eventually issues a service network restart. So, I would rather do all the "replace file" operations before any of that init stuff gets done. Is this possible without much ado? Or should I rather do the "replace file" operations at shutdown (how, when?) and execute only the sql command from rc.local? Google suggests a file /etc/rc.shutdown (or rc.local.shutdown?) which, if I understand correctly, would be carried out after the init stuff for the shutdown (rc0) has been done. Kai