| Both sides previous revisionPrevious revisionNext revision | Previous revision |
| en:faq:how_to_migrate_astercc_system [2015/12/05 06:56] – [Database Backup] liuxl | en:faq:how_to_migrate_astercc_system [2015/12/06 09:48] (current) – [Fourth:Copy(or Overwrite) the Config Files of System] liuxl |
|---|
| {{:en:faq:backup_plans_2.png?750|}} | {{:en:faq:backup_plans_2.png?750|}} |
| |
| 备份完成后,在[添加备份计划]页面,会出现刚才备份的信息,可以对其进行[编辑]和[删除]操作 | After you finished backup,you can "Edit" or "Delete" the plan which has been added on this page. |
| |
| {{:en:faq:backup_plans_3.png?750|}} | {{:en:faq:backup_plans_3.png?750|}} |
| |
| |
| === 用代码实现数据库的备份 === | === Backup the Database on Background === |
| |
| 首先登录服务器:<code> ssh root@192.168.1.146 </code> 然后再到mysql目录下,ls一下可以看到有个名叫“astercc10”的目录,这就是数据库。 转到mysql目录的命令:<code> cd /var/lib/mysql </code> 再执行数据库备份命令:<code> mysqldump -uroot -p astercc10 > astercc20150302.sql </code> 最后输入数据库密码,即可进行数据库备份。 假若不想单独输入密码,直接将密码放到备份命令里,可执行备份命令:<code> mysqldump -uroot -pastercc astercc10 > astercc20150302.sql </code> | First,log in server via ssh: |
| |
| | <code> ssh root@192.168.1.146 </code> |
| |
| 说明: | Then enter /var/lib/mysql directory,you can find a database file named "astercc10" |
| |
| 1.在登录自己本机服务器的数据库时,假如出现 “ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' ”,则需要加上 -h127.0.0.1,即:<code> mysqldump -h127.0.0.1 -uroot -pastercc astercc10 > astercc20150302.sql </code> | <code> cd /var/lib/mysql && ls </code> |
| | |
| | Execute command below,start the backup of database after inputing password: |
| | <code> mysqldump -uroot -p astercc10 > astercc20150302.sql </code> |
| | |
| | |
| | |
| | Exception: |
| | |
| | 1.You should add "-h127.0.0.1" if " ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' " when you login msyql,eg: |
| | <code> mysqldump -h127.0.0.1 -uroot -pastercc astercc10 > astercc20150302.sql </code> |
| |
| {{:zh:常见问题及解答:本机服务器dns系统有问题.png?750|}} | {{:zh:常见问题及解答:本机服务器dns系统有问题.png?750|}} |
| |
| 2.假如在 cd /var/lib/mysql 时权限不够可以修改权限:<code> sudo chmod 755 mysql </code> 查看具体有哪些权限:<code> ll |grep mysql </code> | 2.If there is "bash:cd:/var/lib/mysql/:Permission denied" when you execute "cd /var/lib/mysql",you can check and change privilege of mysql: |
| | |
| | <code> ll |grep mysql </code> |
| | |
| | <code> sudo chmod 755 mysql </code> |
| |
| {{:zh:常见问题及解答:权限不够修改权限.png?750|}} | {{:zh:常见问题及解答:权限不够修改权限.png?750|}} |
| |
| 3.在 mysqldump -h127.0.0.1 -u root -p astercc10 > astercc20150302.sql 数据备份命令中,astercc10:是数据库的名字,astercc20150302.sql:是数据库备份文件 | |
| |
| | ==== Database Recovery ==== |
| |
| | Log in 192.168.1.175,you can find the backup file named "BF" under /tmp/backup directory: |
| |
| ==== 数据库恢复 ==== | <code> ssh dev03@192.168.1.175 </code> |
| |
| 登录175服务器,在 /tmp/backup 下找到刚才备份的文件:BF。命令:<code> ssh dev03@192.168.1.175 </code> 然后再转到backup目录下<code> cd /tmp/backup </code> 然后 ls 一下即可查看到备份好的文件最下面绿框中的即是。 | <code> cd /tmp/backup && ls </code> |
| |
| {{:zh:常见问题及解答:备份文件1_1_1.png?900|}} | {{:zh:常见问题及解答:备份文件1_1_1.png?900|}} |
| |
| | and copy it to / directory on 192.168.1.146 server,execute command below on 192.168.1.175: |
| |
| 并将其复制到新的服务器146上的根目录(/)下面,命令:<code> scp -r BF.19.2015-02-28-16-08 root@192.168.1.146:/ </code> 输入146服务器的密码,待右侧全为100%了,也就复制完毕了。 | <code> scp -r BF.19.2015-02-28-16-08 root@192.168.1.146:/ </code> |
| | |
| | It it finished until progress rate turn to 100% on the right,as is shown below: |
| |
| {{:zh:常见问题及解答:备份文件1_1_2.png?545|}}{{:zh:常见问题及解答:备份文件1_1_3.png?240|}} | {{:zh:常见问题及解答:备份文件1_1_2.png?545|}}{{:zh:常见问题及解答:备份文件1_1_3.png?240|}} |
| |
| 假如出现warning,如下图。需要执行命令,并删除里面相应信息,输入YES即可。<code> vim ~/.ssh/known_hosts </code> 或者执行下面红框里的内容,如: ssh-keygen -f "/home/dev03/.ssh/known_hosts" -R 192.168.1.146 | If it appears warnings as following,you can delete the corresponding contents under ~/.ssh/known_hosts directory. |
| | |
| | <code> vim ~/.ssh/known_hosts </code> |
| | |
| | Or execute commands below: |
| | |
| | <code> ssh-keygen -f "/home/dev03/.ssh/known_hosts" -R 192.168.1.146 </code> |
| |
| {{:zh:常见问题及解答:warning01.png?850|}} | {{:zh:常见问题及解答:warning01.png?850|}} |
| |
| | Login 192.168.1.146 server: |
| | |
| | <code> ssh root@192.168.1.146 </code> |
| | |
| | and decompress the .tar.gz archive via executing commands below: |
| | |
| | <code> tar -xzvf archive_name.tar.gz </code> |
| | |
| | Import the bakckup file of database: |
| | |
| | <code> mysql -u root -p astercc10 < archive_name.sql </code> |
| |
| 登录146服务器:<code> ssh root@192.168.1.146</code> 再找到刚才复制的备份文件并将其解压缩,其中对于.tar.gz类文件解压,命令如下,其中XXXX是压缩文件的名:<code> tar -xzvf XXXX.tar.gz </code> 然后将解压出来的数据库备份文件 导入数据库:<code> mysql -u root -p astercc10 < XXXX.sql</code> 此处XXXX为:astercc10,如下图。最后输入新服务器数据库的密码,默认的是:astercc。其中astercc10是146新服务器上的数据库名字,astercc10.sql是解压出来的数据库备份文件,这样一来,数据库就被迁移导入了。 | <note tip> **Note**:The default archive name is "astercc10". At last,input the password of root in mysql. You can see the information of mysql in /etc/astercc.conf. The "astercc10" is the database name on the new server,archive_name.sql unzip from backup file. </note> |
| |
| {{:zh:常见问题及解答:备份文件1_1_5.png?850|}} | {{:zh:常见问题及解答:备份文件1_1_5.png?850|}} |
| |
| 到这一步,还没有完全结束,假如老服务器数据库没使用默认的数据库信息,则 需要对新服务器配置文件进行3处手动修改: | If the database on the old server use non-default information,we should revise the database information of new server,as follows: |
| |
| 1.对astercc.conf->[database]中的相应信息进行修改,比如:dbname、password等等 <code> vim /opt/asterisk/scripts/astercc/astercc.conf </code> | 1.Information in /etc/astercc.conf->[database],eg:dbname,password,etc |
| |
| 2.对astercc.conf->[statistics]中的相应信息进行修改,比如:dbname、password等等 <code> vim /opt/asterisk/scripts/astercc/astercc.conf </code> | <code> vim /opt/asterisk/scripts/astercc/astercc.conf </code> |
| |
| 3.对database.php 最后面的 class DATABASE_CONFIG 中 default下的password、database等进行修改 <code> vim /var/www/html/asterCC/app/config/database.php </code> | 2.Information in /etc/astercc.conf->[statistics],eg:dbname,password,etc |
| |
| | <code> vim /opt/asterisk/scripts/astercc/astercc.conf </code> |
| |
| | 3.At the end of /var/www/html/asterCC/app/config/database.php->[class DATABASE_CONFIG]-> [var $default = array],password,database,prefix,etc |
| |
| ===== Fourth:复制(覆盖)系统配置文件 ===== | <code> vim /var/www/html/asterCC/app/config/database.php </code> |
| 首先,我们在备份时选择了很多系统文件,即在[系统设置]->[备份计划管理]->[添加/编辑 备份计划]->[高级资料]->[备份内容] | |
| |
| {{:zh:常见问题及解答:系统文件备份2.png?850|}} | |
| |
| 备份好的系统配置文件是可以查看到的(黄框内的文件),我们将其解压(以 "_etc_" 开头的压缩包为例): | |
| | ===== Fourth:Copy(or Overwrite) the Config Files of System ===== |
| | |
| | We selected many system file when backup,the list in [System]->[Backup Plans]->[Add Backupplan]->[Advanced]->[Backupfile] |
| | |
| | {{:en:faq:backup_plans_2.png?750|}} |
| | |
| | You can see the backup file of system config files (marked by yellow rectangle),we can unzip the .tar package execute below commands: |
| |
| {{:zh:常见问题及解答:备份的配置文件.png?850|}} | {{:zh:常见问题及解答:备份的配置文件.png?850|}} |
| |
| 解压命令:<code> tar -xzvf XXXXX.tar.gz </code> 将三条记录都解压,会出现一个叫 etc 的文件夹,解压完后有四个文件夹,将其四个及其目录下的所有文件夹、文件复制到新的服务器“相应”位置, 即: | Decompress commands: |
| | |
| | <code> tar -xzvf XXXXX.tar.gz </code> |
| | |
| | Decompress all archive,then copy(or mv) all files and directories under original location correspondingly, i.e.: |
| <code> | <code> |
| \cp -rpf /BF.19.2015-02-28-16-08/etc/* /etc | \cp -rpf /BF.19.2015-02-28-16-08/etc/* /etc |
| </code> | </code> |
| |
| 需要说明的是:\cp是在复制时,不提示覆盖信息用的,-r是有关目录的操作,-p是除复制源文件的内容外,还将把其修改时间和访问权限也复制到新文件中,-f是强行操作 慎重使用。 | Note:When use "\cp" (not cp) command to copy(or overwrite),there is no any overwrite information. -r:not only copy files,but also directories. -f:force |
| |
| {{:zh:常见问题及解答:备份文件1_1_6.png?850|}} | {{:zh:常见问题及解答:备份文件1_1_6.png?850|}} |
| |
| |
| === 用代码实现即时性系统配置文件的转移(覆盖) === | === Copy(or Overwrite) the Config Files of System on Background === |
| 首先登录登录原来服务器(192.168.1.175),找到[系统设置]->[备份计划管理]->[添加/编辑 备份计划]->[高级资料]->[备份内容]下备份的文件及目录。 | |
| | First,login the 192.168.1.175 server,you can see the backup files under [System]->[Backup Plans]->[Add Backupplan]->[Advanced]->[Backupfile] directory. |
| |
| <code> | <code> |