This documentation is for a release that is no longer maintained
See documentation for the latest supported version 3 or the latest supported version 4.Este conteúdo não está disponível no idioma selecionado.
Chapter 3. Restoring OpenShift Container Platform components
3.1. Overview Copiar o linkLink copiado para a área de transferência!
In OpenShift Container Platform, you can restore your cluster and its components by recreating cluster elements, including nodes and applications, from separate storage.
To restore a cluster, you must first back it up.
The following process describes a generic way of restoring applications and the OpenShift Container Platform cluster. It cannot take into account custom requirements. You might need to take additional actions to restore your cluster.
3.2. Restoring a cluster Copiar o linkLink copiado para a área de transferência!
To restore a cluster, first reinstall OpenShift Container Platform.
Procedure
- Reinstall OpenShift Container Platform in the same way that you originally installed OpenShift Container Platform.
- Run all of your custom post-installation steps, such as changing services outside of the control of OpenShift Container Platform or installing extra services like monitoring agents.
3.3. Restoring a master host backup Copiar o linkLink copiado para a área de transferência!
After creating a backup of important master host files, if they become corrupted or accidentally removed, you can restore the files by copying the files back to master, ensuring they contain the proper content, and restarting the affected services.
Procedure
Restore the
/etc/origin/master/master-config.yamlfile:MYBACKUPDIR=*/backup/$(hostname)/$(date +%Y%m%d)* cp /etc/origin/master/master-config.yaml /etc/origin/master/master-config.yaml.old cp /backup/$(hostname)/$(date +%Y%m%d)/origin/master/master-config.yaml /etc/origin/master/master-config.yaml master-restart api master-restart controllers
# MYBACKUPDIR=*/backup/$(hostname)/$(date +%Y%m%d)* # cp /etc/origin/master/master-config.yaml /etc/origin/master/master-config.yaml.old # cp /backup/$(hostname)/$(date +%Y%m%d)/origin/master/master-config.yaml /etc/origin/master/master-config.yaml # master-restart api # master-restart controllersCopy to Clipboard Copied! Toggle word wrap Toggle overflow WarningRestarting the master services can lead to downtime. However, you can remove the master host from the highly available load balancer pool, then perform the restore operation. Once the service has been properly restored, you can add the master host back to the load balancer pool.
NotePerform a full reboot of the affected instance to restore the
iptablesconfiguration.If you cannot restart OpenShift Container Platform because packages are missing, reinstall the packages.
Get the list of the current installed packages:
rpm -qa | sort > /tmp/current_packages.txt
$ rpm -qa | sort > /tmp/current_packages.txtCopy to Clipboard Copied! Toggle word wrap Toggle overflow View the differences between the package lists:
diff /tmp/current_packages.txt ${MYBACKUPDIR}/packages.txt ansible-2.4.0.0-5.el7.noarch$ diff /tmp/current_packages.txt ${MYBACKUPDIR}/packages.txt > ansible-2.4.0.0-5.el7.noarchCopy to Clipboard Copied! Toggle word wrap Toggle overflow Reinstall the missing packages:
yum reinstall -y <packages>
# yum reinstall -y <packages>1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Replace
<packages>with the packages that are different between the package lists.
Restore a system certificate by copying the certificate to the
/etc/pki/ca-trust/source/anchors/directory and execute theupdate-ca-trust:MYBACKUPDIR=*/backup/$(hostname)/$(date +%Y%m%d)* sudo cp ${MYBACKUPDIR}/external_certificates/my_company.crt /etc/pki/ca-trust/source/anchors/ sudo update-ca-trust$ MYBACKUPDIR=*/backup/$(hostname)/$(date +%Y%m%d)* $ sudo cp ${MYBACKUPDIR}/external_certificates/my_company.crt /etc/pki/ca-trust/source/anchors/ $ sudo update-ca-trustCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteAlways ensure the user ID and group ID are restored when the files are copied back, as well as the
SELinuxcontext.
3.4. Restoring a node host backup Copiar o linkLink copiado para a área de transferência!
After creating a backup of important node host files, if they become corrupted or accidentally removed, you can restore the file by copying back the file, ensuring it contains the proper content and restart the affected services.
Procedure
Restore the
/etc/origin/node/node-config.yamlfile:MYBACKUPDIR=/backup/$(hostname)/$(date +%Y%m%d) cp /etc/origin/node/node-config.yaml /etc/origin/node/node-config.yaml.old cp /backup/$(hostname)/$(date +%Y%m%d)/etc/origin/node/node-config.yaml /etc/origin/node/node-config.yaml reboot
# MYBACKUPDIR=/backup/$(hostname)/$(date +%Y%m%d) # cp /etc/origin/node/node-config.yaml /etc/origin/node/node-config.yaml.old # cp /backup/$(hostname)/$(date +%Y%m%d)/etc/origin/node/node-config.yaml /etc/origin/node/node-config.yaml # rebootCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Restarting the services can lead to downtime. See Node maintenance, for tips on how to ease the process.
Perform a full reboot of the affected instance to restore the iptables configuration.
If you cannot restart OpenShift Container Platform because packages are missing, reinstall the packages.
Get the list of the current installed packages:
rpm -qa | sort > /tmp/current_packages.txt
$ rpm -qa | sort > /tmp/current_packages.txtCopy to Clipboard Copied! Toggle word wrap Toggle overflow View the differences between the package lists:
diff /tmp/current_packages.txt ${MYBACKUPDIR}/packages.txt ansible-2.4.0.0-5.el7.noarch$ diff /tmp/current_packages.txt ${MYBACKUPDIR}/packages.txt > ansible-2.4.0.0-5.el7.noarchCopy to Clipboard Copied! Toggle word wrap Toggle overflow Reinstall the missing packages:
yum reinstall -y <packages>
# yum reinstall -y <packages>1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Replace
<packages>with the packages that are different between the package lists.
Restore a system certificate by copying the certificate to the
/etc/pki/ca-trust/source/anchors/directory and execute theupdate-ca-trust:MYBACKUPDIR=*/backup/$(hostname)/$(date +%Y%m%d)* sudo cp ${MYBACKUPDIR}/etc/pki/ca-trust/source/anchors/my_company.crt /etc/pki/ca-trust/source/anchors/ sudo update-ca-trust$ MYBACKUPDIR=*/backup/$(hostname)/$(date +%Y%m%d)* $ sudo cp ${MYBACKUPDIR}/etc/pki/ca-trust/source/anchors/my_company.crt /etc/pki/ca-trust/source/anchors/ $ sudo update-ca-trustCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteAlways ensure proper user ID and group ID are restored when the files are copied back, as well as the
SELinuxcontext.
3.5. Restoring etcd Copiar o linkLink copiado para a área de transferência!
The restore procedure for etcd configuration files replaces the appropriate files, then restarts the service or static pod.
If an etcd host has become corrupted and the /etc/etcd/etcd.conf file is lost, restore it using:
ssh master-0 cp /backup/yesterday/master-0-files/etcd.conf /etc/etcd/etcd.conf restorecon -Rv /etc/etcd/etcd.conf systemctl restart etcd.service
$ ssh master-0
# cp /backup/yesterday/master-0-files/etcd.conf /etc/etcd/etcd.conf
# restorecon -Rv /etc/etcd/etcd.conf
# systemctl restart etcd.service
In this example, the backup file is stored in the /backup/yesterday/master-0-files/etcd.conf path where it can be used as an external NFS share, S3 bucket, or other storage solution.
If you run etcd as a static pod, follow only the steps in that section. If you run etcd as a separate service on either master or standalone nodes, follow the steps to restore v2 or v3 data as required.
3.5.1. Restoring etcd v2 & v3 data Copiar o linkLink copiado para a área de transferência!
The following process restores healthy data files and starts the etcd cluster as a single node, then adds the rest of the nodes if an etcd cluster is required.
Procedure
Stop all etcd services by removing the etcd pod definition and rebooting the host:
mkdir -p /etc/origin/node/pods-stopped mv /etc/origin/node/pods/* /etc/origin/node/pods-stopped/ reboot
# mkdir -p /etc/origin/node/pods-stopped # mv /etc/origin/node/pods/* /etc/origin/node/pods-stopped/ # rebootCopy to Clipboard Copied! Toggle word wrap Toggle overflow To ensure the proper backup is restored, delete the etcd directories:
To back up the current etcd data before you delete the directory, run the following command:
mv /var/lib/etcd /var/lib/etcd.old mkdir /var/lib/etcd restorecon -Rv /var/lib/etcd/
# mv /var/lib/etcd /var/lib/etcd.old # mkdir /var/lib/etcd # restorecon -Rv /var/lib/etcd/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Or, to delete the directory and the etcd, data, run the following command:
rm -Rf /var/lib/etcd/*
# rm -Rf /var/lib/etcd/*Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteIn an all-in-one cluster, the etcd data directory is located in the
/var/lib/origin/openshift.local.etcddirectory.
Restore a healthy backup data file to each of the etcd nodes. Perform this step on all etcd hosts, including master hosts collocated with etcd.
cp -R /backup/etcd-xxx/* /var/lib/etcd/ mv /var/lib/etcd/db /var/lib/etcd/member/snap/db chcon -R --reference /backup/etcd-xxx/* /var/lib/etcd/
# cp -R /backup/etcd-xxx/* /var/lib/etcd/ # mv /var/lib/etcd/db /var/lib/etcd/member/snap/db # chcon -R --reference /backup/etcd-xxx/* /var/lib/etcd/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Run the etcd service on each host, forcing a new cluster.
This creates a custom file for the etcd service, which overwrites the execution command adding the
--force-new-clusteroption:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Check for error messages:
master-logs etcd etcd
$ master-logs etcd etcdCopy to Clipboard Copied! Toggle word wrap Toggle overflow Check for health status:
etcdctl2 cluster-health
# etcdctl2 cluster-health member 5ee217d17301 is healthy: got healthy result from https://192.168.55.8:2379 cluster is healthyCopy to Clipboard Copied! Toggle word wrap Toggle overflow Restart the etcd service in cluster mode:
rm -f /etc/systemd/system/etcd.service.d/temp.conf systemctl daemon-reload master-restart etcd
# rm -f /etc/systemd/system/etcd.service.d/temp.conf # systemctl daemon-reload # master-restart etcdCopy to Clipboard Copied! Toggle word wrap Toggle overflow Check for health status and member list:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - After the first instance is running, you can restore the rest of your etcd servers.
3.5.1.1. Fix the peerURLS parameter Copiar o linkLink copiado para a área de transferência!
After restoring the data and creating a new cluster, the peerURLs parameter shows localhost instead of the IP where etcd is listening for peer communication:
etcdctl2 member list
# etcdctl2 member list
5ee217d17301: name=master-0.example.com peerURLs=http://*localhost*:2380 clientURLs=https://192.168.55.8:2379 isLeader=true
3.5.1.1.1. Procedure Copiar o linkLink copiado para a área de transferência!
Get the member ID using
etcdctl member list:`etcdctl member list`
`etcdctl member list`Copy to Clipboard Copied! Toggle word wrap Toggle overflow Get the IP where etcd listens for peer communication:
ss -l4n | grep 2380
$ ss -l4n | grep 2380Copy to Clipboard Copied! Toggle word wrap Toggle overflow Update the member information with that IP:
etcdctl2 member update 5ee217d17301 https://192.168.55.8:2380
# etcdctl2 member update 5ee217d17301 https://192.168.55.8:2380 Updated member with ID 5ee217d17301 in clusterCopy to Clipboard Copied! Toggle word wrap Toggle overflow To verify, check that the IP is in the member list:
etcdctl2 member list
$ etcdctl2 member list 5ee217d17301: name=master-0.example.com peerURLs=https://*192.168.55.8*:2380 clientURLs=https://192.168.55.8:2379 isLeader=trueCopy to Clipboard Copied! Toggle word wrap Toggle overflow
3.5.2. Restoring etcd v3 snapshot Copiar o linkLink copiado para a área de transferência!
The restore procedure for v3 data is similar to the restore procedure for the v2 data.
Snapshot integrity may be optionally verified at restore time. If the snapshot is taken with etcdctl snapshot save, it will have an integrity hash that is checked by etcdctl snapshot restore. If the snapshot is copied from the data directory, there is no integrity hash and it will only restore by using --skip-hash-check.
The procedure to restore the data must be performed on a single etcd host. You can then add the rest of the nodes to the cluster.
Procedure
Stop all etcd services by removing the etcd pod definition and rebooting the host:
mkdir -p /etc/origin/node/pods-stopped mv /etc/origin/node/pods/* /etc/origin/node/pods-stopped/ reboot
# mkdir -p /etc/origin/node/pods-stopped # mv /etc/origin/node/pods/* /etc/origin/node/pods-stopped/ # rebootCopy to Clipboard Copied! Toggle word wrap Toggle overflow Clear all old data, because
etcdctlrecreates it in the node where the restore procedure is going to be performed:rm -Rf /var/lib/etcd
# rm -Rf /var/lib/etcdCopy to Clipboard Copied! Toggle word wrap Toggle overflow Run the
snapshot restorecommand, substituting the values from the/etc/etcd/etcd.conffile:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Restore permissions and
selinuxcontext to the restored files:restorecon -Rv /var/lib/etcd
# restorecon -Rv /var/lib/etcdCopy to Clipboard Copied! Toggle word wrap Toggle overflow Start the etcd service:
systemctl start etcd
# systemctl start etcdCopy to Clipboard Copied! Toggle word wrap Toggle overflow Check for any error messages:
master-logs etcd etcd
# master-logs etcd etcdCopy to Clipboard Copied! Toggle word wrap Toggle overflow
3.5.3. Restoring etcd on a static pod Copiar o linkLink copiado para a área de transferência!
Before restoring etcd on a static pod:
etcdctlbinaries must be available or, in containerized installations, therhel7/etcdcontainer must be available.You can obtain etcd by running the following commands:
git clone https://github.com/coreos/etcd.git cd etcd ./build
$ git clone https://github.com/coreos/etcd.git $ cd etcd $ ./buildCopy to Clipboard Copied! Toggle word wrap Toggle overflow
To restore etcd on a static pod:
If the pod is running, stop the etcd pod by moving the pod manifest YAML file to another directory:
mv /etc/origin/node/pods/etcd.yaml .
$ mv /etc/origin/node/pods/etcd.yaml .Copy to Clipboard Copied! Toggle word wrap Toggle overflow Clear all old data:
rm -rf /var/lib/etcd
$ rm -rf /var/lib/etcdCopy to Clipboard Copied! Toggle word wrap Toggle overflow You use the etcdctl to recreate the data in the node where you restore the pod.
Restore the etcd snapshot to the mount path for the etcd pod:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Obtain the values for your cluster from the $/backup_files/etcd.conf file.
Set required permissions and selinux context on the data directory:
restorecon -Rv /var/lib/etcd/
$ restorecon -Rv /var/lib/etcd/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Restart the etcd pod by moving the pod manifest YAML file to the required directory:
mv etcd.yaml /etc/origin/node/pods/.
$ mv etcd.yaml /etc/origin/node/pods/.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
3.6. Adding an etcd node Copiar o linkLink copiado para a área de transferência!
After you restore etcd, you can add more etcd nodes to the cluster. You can either add an etcd host by using an Ansible playbook or by manual steps.
3.6.1. Adding a new etcd host using Ansible Copiar o linkLink copiado para a área de transferência!
Procedure
In the Ansible inventory file, create a new group named
[new_etcd]and add the new host. Then, add thenew_etcdgroup as a child of the[OSEv3]group:Copy to Clipboard Copied! Toggle word wrap Toggle overflow From the host that installed OpenShift Container Platform and hosts the Ansible inventory file, run the etcd
scaleupplaybook:ansible-playbook /usr/share/ansible/openshift-ansible/playbooks/openshift-etcd/scaleup.yml
$ ansible-playbook /usr/share/ansible/openshift-ansible/playbooks/openshift-etcd/scaleup.ymlCopy to Clipboard Copied! Toggle word wrap Toggle overflow After the playbook runs, modify the inventory file to reflect the current status by moving the new etcd host from the
[new_etcd]group to the[etcd]group:Copy to Clipboard Copied! Toggle word wrap Toggle overflow If you use Flannel, modify the
flanneldservice configuration on every OpenShift Container Platform host, located at/etc/sysconfig/flanneld, to include the new etcd host:FLANNEL_ETCD_ENDPOINTS=https://master-0.example.com:2379,https://master-1.example.com:2379,https://master-2.example.com:2379,https://etcd0.example.com:2379
FLANNEL_ETCD_ENDPOINTS=https://master-0.example.com:2379,https://master-1.example.com:2379,https://master-2.example.com:2379,https://etcd0.example.com:2379Copy to Clipboard Copied! Toggle word wrap Toggle overflow Restart the
flanneldservice:systemctl restart flanneld.service
# systemctl restart flanneld.serviceCopy to Clipboard Copied! Toggle word wrap Toggle overflow
3.6.2. Manually adding a new etcd host Copiar o linkLink copiado para a área de transferência!
If you do not run etcd as static pods on master nodes, you might need to add another etcd host.
Procedure
Modify the current etcd cluster
To create the etcd certificates, run the openssl command, replacing the values with those from your environment.
Create some environment variables:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThe custom
opensslextensions used asetcd_v3_ca_*include the $SAN environment variable assubjectAltName. See/etc/etcd/ca/openssl.cnffor more information.Create the directory to store the configuration and certificates:
mkdir -p ${PREFIX}# mkdir -p ${PREFIX}Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the server certificate request and sign it: (server.csr and server.crt)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the peer certificate request and sign it: (peer.csr and peer.crt)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Copy the current etcd configuration and
ca.crtfiles from the current node as examples to modify later:cp /etc/etcd/etcd.conf ${PREFIX} cp /etc/etcd/ca.crt ${PREFIX}# cp /etc/etcd/etcd.conf ${PREFIX} # cp /etc/etcd/ca.crt ${PREFIX}Copy to Clipboard Copied! Toggle word wrap Toggle overflow While still on the surviving etcd host, add the new host to the cluster. To add additional etcd members to the cluster, you must first adjust the default localhost peer in the
peerURLsvalue for the first member:Get the member ID for the first member using the
member listcommand:etcdctl --cert-file=/etc/etcd/peer.crt \ --key-file=/etc/etcd/peer.key \ --ca-file=/etc/etcd/ca.crt \ --peers="https://172.18.1.18:2379,https://172.18.9.202:2379,https://172.18.0.75:2379" \ member list# etcdctl --cert-file=/etc/etcd/peer.crt \ --key-file=/etc/etcd/peer.key \ --ca-file=/etc/etcd/ca.crt \ --peers="https://172.18.1.18:2379,https://172.18.9.202:2379,https://172.18.0.75:2379" \1 member listCopy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Ensure that you specify the URLs of only active etcd members in the
--peersparameter value.
Obtain the IP address where etcd listens for cluster peers:
ss -l4n | grep 2380
$ ss -l4n | grep 2380Copy to Clipboard Copied! Toggle word wrap Toggle overflow Update the value of
peerURLsusing theetcdctl member updatecommand by passing the member ID and IP address obtained from the previous steps:etcdctl --cert-file=/etc/etcd/peer.crt \ --key-file=/etc/etcd/peer.key \ --ca-file=/etc/etcd/ca.crt \ --peers="https://172.18.1.18:2379,https://172.18.9.202:2379,https://172.18.0.75:2379" \ member update 511b7fb6cc0001 https://172.18.1.18:2380# etcdctl --cert-file=/etc/etcd/peer.crt \ --key-file=/etc/etcd/peer.key \ --ca-file=/etc/etcd/ca.crt \ --peers="https://172.18.1.18:2379,https://172.18.9.202:2379,https://172.18.0.75:2379" \ member update 511b7fb6cc0001 https://172.18.1.18:2380Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Re-run the
member listcommand and ensure the peer URLs no longer include localhost.
Add the new host to the etcd cluster. Note that the new host is not yet configured, so the status stays as
unstarteduntil the you configure the new host.WarningYou must add each member and bring it online one at a time. When you add each additional member to the cluster, you must adjust the
peerURLslist for the current peers. ThepeerURLslist grows by one for each member added. Theetcdctl member addcommand outputs the values that you must set in the etcd.conf file as you add each member, as described in the following instructions.Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- In this line,
10.3.9.222is a label for the etcd member. You can specify the host name, IP address, or a simple name.
Update the sample
${PREFIX}/etcd.conffile.Replace the following values with the values generated in the previous step:
- ETCD_NAME
- ETCD_INITIAL_CLUSTER
- ETCD_INITIAL_CLUSTER_STATE
Modify the following variables with the new host IP from the output of the previous step. You can use
${NEW_ETCD_IP}as the value.ETCD_LISTEN_PEER_URLS ETCD_LISTEN_CLIENT_URLS ETCD_INITIAL_ADVERTISE_PEER_URLS ETCD_ADVERTISE_CLIENT_URLS
ETCD_LISTEN_PEER_URLS ETCD_LISTEN_CLIENT_URLS ETCD_INITIAL_ADVERTISE_PEER_URLS ETCD_ADVERTISE_CLIENT_URLSCopy to Clipboard Copied! Toggle word wrap Toggle overflow - If you previously used the member system as an etcd node, you must overwrite the current values in the /etc/etcd/etcd.conf file.
Check the file for syntax errors or missing IP addresses, otherwise the etcd service might fail:
vi ${PREFIX}/etcd.conf# vi ${PREFIX}/etcd.confCopy to Clipboard Copied! Toggle word wrap Toggle overflow
-
On the node that hosts the installation files, update the
[etcd]hosts group in the /etc/ansible/hosts inventory file. Remove the old etcd hosts and add the new ones. Create a
tgzfile that contains the certificates, the sample configuration file, and thecaand copy it to the new host:tar -czvf /etc/etcd/generated_certs/${CN}.tgz -C ${PREFIX} . scp /etc/etcd/generated_certs/${CN}.tgz ${CN}:/tmp/# tar -czvf /etc/etcd/generated_certs/${CN}.tgz -C ${PREFIX} . # scp /etc/etcd/generated_certs/${CN}.tgz ${CN}:/tmp/Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Modify the new etcd host
Install
iptables-servicesto provide iptables utilities to open the required ports for etcd:yum install -y iptables-services
# yum install -y iptables-servicesCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create the
OS_FIREWALL_ALLOWfirewall rules to allow etcd to communicate:- Port 2379/tcp for clients
Port 2380/tcp for peer communication
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteIn this example, a new chain
OS_FIREWALL_ALLOWis created, which is the standard naming the OpenShift Container Platform installer uses for firewall rules.WarningIf the environment is hosted in an IaaS environment, modify the security groups for the instance to allow incoming traffic to those ports as well.
Install etcd:
yum install -y etcd
# yum install -y etcdCopy to Clipboard Copied! Toggle word wrap Toggle overflow Ensure version
etcd-2.3.7-4.el7.x86_64or greater is installed,Ensure the etcd service is not running by removing the etcd pod definition:
mkdir -p /etc/origin/node/pods-stopped mv /etc/origin/node/pods/* /etc/origin/node/pods-stopped/
# mkdir -p /etc/origin/node/pods-stopped # mv /etc/origin/node/pods/* /etc/origin/node/pods-stopped/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Remove any etcd configuration and data:
rm -Rf /etc/etcd/* rm -Rf /var/lib/etcd/*
# rm -Rf /etc/etcd/* # rm -Rf /var/lib/etcd/*Copy to Clipboard Copied! Toggle word wrap Toggle overflow Extract the certificates and configuration files:
tar xzvf /tmp/etcd0.example.com.tgz -C /etc/etcd/
# tar xzvf /tmp/etcd0.example.com.tgz -C /etc/etcd/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Start etcd on the new host:
systemctl enable etcd --now
# systemctl enable etcd --nowCopy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that the host is part of the cluster and the current cluster health:
If you use the v2 etcd api, run the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow If you use the v3 etcd api, run the following command:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Modify each OpenShift Container Platform master
Modify the master configuration in the
etcClientInfosection of the/etc/origin/master/master-config.yamlfile on every master. Add the new etcd host to the list of the etcd servers OpenShift Container Platform uses to store the data, and remove any failed etcd hosts:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Restart the master API service:
On every master:
master-restart api master-restart controllers
# master-restart api # master-restart controllersCopy to Clipboard Copied! Toggle word wrap Toggle overflow WarningThe number of etcd nodes must be odd, so you must add at least two hosts.
If you use Flannel, modify the
flanneldservice configuration located at/etc/sysconfig/flanneldon every OpenShift Container Platform host to include the new etcd host:FLANNEL_ETCD_ENDPOINTS=https://master-0.example.com:2379,https://master-1.example.com:2379,https://master-2.example.com:2379,https://etcd0.example.com:2379
FLANNEL_ETCD_ENDPOINTS=https://master-0.example.com:2379,https://master-1.example.com:2379,https://master-2.example.com:2379,https://etcd0.example.com:2379Copy to Clipboard Copied! Toggle word wrap Toggle overflow Restart the
flanneldservice:systemctl restart flanneld.service
# systemctl restart flanneld.serviceCopy to Clipboard Copied! Toggle word wrap Toggle overflow
3.7. Bringing OpenShift Container Platform services back online Copiar o linkLink copiado para a área de transferência!
After you finish your changes, bring OpenShift Container Platform back online.
Procedure
On each OpenShift Container Platform master, restore your master and node configuration from backup and enable and restart all relevant services:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow On each OpenShift Container Platform node, update the node configuration maps as needed, and enable and restart the atomic-openshift-node service:
cp /etc/origin/node/node-config.yaml.<timestamp> /etc/origin/node/node-config.yaml systemctl enable atomic-openshift-node systemctl start atomic-openshift-node
# cp /etc/origin/node/node-config.yaml.<timestamp> /etc/origin/node/node-config.yaml # systemctl enable atomic-openshift-node # systemctl start atomic-openshift-nodeCopy to Clipboard Copied! Toggle word wrap Toggle overflow
3.8. Restoring a project Copiar o linkLink copiado para a área de transferência!
To restore a project, create the new project, then restore any exported files by running oc create -f pods.json. However, restoring a project from scratch requires a specific order because some objects depend on others. For example, you must create the configmaps before you create any pods.
Procedure
If the project was exported as a single file, import it by running the following commands:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow WarningSome resources, such as pods and default service accounts, can fail to be created.
3.9. Restoring application data Copiar o linkLink copiado para a área de transferência!
You can restore application data by using the oc rsync command, assuming rsync is installed within the container image. The Red Hat rhel7 base image contains rsync. Therefore, all images that are based on rhel7 contain it as well. See Troubleshooting and Debugging CLI Operations - rsync.
This is a generic restoration of application data and does not take into account application-specific backup procedures, for example, special export and import procedures for database systems.
Other means of restoration might exist depending on the type of the persistent volume you use, for example, Cinder, NFS, or Gluster.
Procedure
Example of restoring a Jenkins deployment’s application data
Verify the backup:
ls -la /tmp/jenkins-backup/
$ ls -la /tmp/jenkins-backup/ total 8 drwxrwxr-x. 3 user user 20 Sep 6 11:14 . drwxrwxrwt. 17 root root 4096 Sep 6 11:16 .. drwxrwsrwx. 12 user user 4096 Sep 6 11:14 jenkinsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Use the
oc rsynctool to copy the data into the running pod:oc rsync /tmp/jenkins-backup/jenkins jenkins-1-37nux:/var/lib
$ oc rsync /tmp/jenkins-backup/jenkins jenkins-1-37nux:/var/libCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteDepending on the application, you may be required to restart the application.
Optionally, restart the application with new data:
oc delete pod jenkins-1-37nux
$ oc delete pod jenkins-1-37nuxCopy to Clipboard Copied! Toggle word wrap Toggle overflow Alternatively, you can scale down the deployment to 0, and then up again:
oc scale --replicas=0 dc/jenkins oc scale --replicas=1 dc/jenkins
$ oc scale --replicas=0 dc/jenkins $ oc scale --replicas=1 dc/jenkinsCopy to Clipboard Copied! Toggle word wrap Toggle overflow
3.10. Restoring Persistent Volume Claims Copiar o linkLink copiado para a área de transferência!
This topic describes two methods for restoring data. The first involves deleting the file, then placing the file back in the expected location. The second example shows migrating persistent volume claims. The migration would occur in the event that the storage needs to be moved or in a disaster scenario when the backend storage no longer exists.
Check with the restore procedures for the specific application on any steps required to restore data to the application.
3.10.1. Restoring files to an existing PVC Copiar o linkLink copiado para a área de transferência!
Procedure
Delete the file:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Replace the file from the server that contains the rsync backup of the files that were in the pvc:
oc rsync uploaded demo-2-fxx6d:/opt/app-root/src/
$ oc rsync uploaded demo-2-fxx6d:/opt/app-root/src/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Validate that the file is back on the pod by using
oc rshto connect to the pod and view the contents of the directory:oc rsh demo-2-fxx6d
$ oc rsh demo-2-fxx6d sh-4.2$ *ls /opt/app-root/src/uploaded/* lost+found ocp_sop.txtCopy to Clipboard Copied! Toggle word wrap Toggle overflow
3.10.2. Restoring data to a new PVC Copiar o linkLink copiado para a área de transferência!
The following steps assume that a new pvc has been created.
Procedure
Overwrite the currently defined
claim-name:oc volume dc/demo --add --name=persistent-volume \ --type=persistentVolumeClaim --claim-name=filestore \ --mount-path=/opt/app-root/src/uploaded --overwrite
$ oc volume dc/demo --add --name=persistent-volume \ --type=persistentVolumeClaim --claim-name=filestore \ --mount-path=/opt/app-root/src/uploaded --overwriteCopy to Clipboard Copied! Toggle word wrap Toggle overflow Validate that the pod is using the new PVC:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Now that the deployement configuration uses the new
pvc, runoc rsyncto place the files onto the newpvc:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Validate that the file is back on the pod by using
oc rshto connect to the pod and view the contents of the directory:oc rsh demo-3-2b8gs
$ oc rsh demo-3-2b8gs sh-4.2$ ls /opt/app-root/src/uploaded/ lost+found ocp_sop.txtCopy to Clipboard Copied! Toggle word wrap Toggle overflow