环境迁移

  有时我们需要把一个环境从一个单板迁移到另一个单板,这时就需要进行环境的复制:

  1、备份原环境。用tar命令将整个环境的家目录打包备份,即使不进行环境迁移,定期备份环境也是一个好习惯,当有一天环境意外崩溃或者升级包被替换错了,直接用备份环境还原就可以挽救。

  2、创建新环境。首先需要在root用户下,先创用户组和用户,然后改用户密码,最后切换到新用户下:

[root@test11 ~]# groupadd wlfgroup
[root@test11 ~]# useradd wlf -m -d /home/wlf -g wlfgroup -s /bin/bash
[root@test11 ~]# passwd wlf
Changing password for user wlf.
New password: 
BAD PASSWORD: The password is shorter than 8 characters
Retype new password: 
passwd: all authentication tokens updated successfully.
[root@test11 ~]# su - wlf
[wlf@test11 ~]$ 

 

  3、迁移原环境。将备份包通过ftp传到新环境,直接在家目录下解压,然后让jdk加入环境变量以便tomcat容器可以启动:

[wlf@test11 ~]$ cd ~
[wlf@test11 ~]$ vi .bashc

  在打开的文件中:

# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=

# User specific aliases and functions
~
~

 

  追加如下这一句:

export PATH=$PATH:~wlf/jdk/bin

 

  让新环境变量生效:

source .bashrc

 

  4、修改tomcat下server. xml文件的端口或者数据库实例,启动容器,打完收工。

posted on 2017-02-23 09:24  不想下火车的人  阅读(310)  评论(0编辑  收藏  举报

导航