Project-level server data migration process

Project-level server data migration process

Created: 2022/09/24

Update time: 2022/09/24

Editor: Xu Junjie

Project-level server data migration process

The following operations are aimed at the hardware server hosted by the mobile computer room as the final migration target, other servers are of reference value

“`text

183.213.16.9

dtsite

qwer4321asdf

“`

1. Necessary copy of directory

Note: There may be omissions and confirmations in some contents, please add them yourself.

  1. copy database data

“`text

Backup

pg_dump -h 127.0.0.1 -p {database port} -U odoo |gzip > ./dbdata_{project name}.gz

Upload to the hardware server /home/dtsite/aliyun3/dbData/directory

scp -P 22 ./dbdata_{project name}.gz [email protected]:/home/dtsite/aliyun3/dbData/

“`

  1. Copy project directory

“`cmd

tar -czvf project_aliyun4.tar.gz /opt/project

Upload to target server

scp -P 22 ./project_aliyun4.tar.gz [email protected]:/opt

“`

  1. Copy iothttp3 and upload to the target server

“`cmd

cd /opt

Copy iothttp3

cp -r iothttp3 iothttp3_aliyun4

Delete unnecessary files

rm -rf ./iothttp4_aliyun3/venv ./iothttp3_aliyun4/*.log

./iothttp3_aliyun4/test ./iothttp3_aliyun4/__pycache__

Package

tar -czvf iothttp3_aliyun4.tar.gz iothttp3_aliyun4

Upload to target server

scp -P 22 ./iothttp3_aliyun4.tar.gz [email protected]:/opt

“`

  1. Copy the supervisor configuration file

“`

scp -P 22 /etc/supervisor/conf.d/iothttp3.conf [email protected]:/home/dtsite/supervisorConfigBak/iothttp3_aliyun4.conf

“`

  1. Copy the docker image file

The docker save command packages the following images, and then loads them using docker load on the target server

“`

47.104.8.212:8000/postgres 11

47.104.8.212:8000/dtsitev6

47.104.8.212:8000/dtsite/frontend-v4

47.104.8.212:8000/postgres 10

“`

2. Project deployment

Migrate the backup project data directory

Example: Migrating country-quality project data into the /opt/projects directory

“`cmd

cp -r /home/dtsite/aliyun3/optProjects/Dtcloud_guojiazl /opt/projects

“`

Use serverOM to automatically deploy projects

The following content is based on the following hardware server as an example, and other servers are for reference only.

  1. Add server parameters

Open [serverOM](http://183.213.16.9:9005/zyf/python_iot-data-testing), add new server parameters in the server configuration file server_info.ini, `Note that the root user is required`

![[Pasted image 20220921114918.png]]

Example:

“`text

[hardware server]

ssh connection parameters

sshparams = {‘host’: ‘183.213.16.xx’, ‘port’: 22, ‘user’: ‘root’, ‘password’: ‘xxx’}

Module directory location of server odoo

appaddonspath = /opt/projects/source/dtsite_addons

Server collection service location

iotserverpath=”/opt/iothttp3″

Project template directory location

projecttemplatepath=”/opt/projects/source/projectTemplate”

The maximum number of projects created by the server

maxProjectNumber=50

“`

  1. First create a database break point here

After creating the database, you need to import the data first. Otherwise the database is automatically initialized by odoo

![[Pasted image 20220924111820.png]]

  1. Execute the create project script

– Modify the startup parameters and use the debug command to start

![[Pasted image 20220924112256.png]]

– Enter `no` at the first prompt

![[Pasted image 20220924112228.png]]

– After the breakpoint is triggered, the server console enters the following command to import the data into the database

View the project database port (take the guojiazl project as an example)

![[Pasted image 20220924112535.png]]

Import Data

“`cmd

gunzip -c /home/dtsite/dbData/dbdata_{project name}.gz |psql -h 127.0.0.1 -p {new database port} -U odoo odoo

“`

  1. Continue to execute the deployment script

Enter done directly in the prompt below to complete it directly, and don’t worry about the error.

![[Pasted image 20220924113037.png]]

  1. Add gateway and modify configuration parameters

– Log in to [Server Gateway KONGA](http://183.213.16.9:9003/#!/services), refer to the project parameters in project_info.ini, and add the port (odoo, big screen, and iot collection services must be configured) ;

– Then modify the following parameter value to be consistent with the address configured in [KONGA](), for later large-screen code update

![[Pasted image 20220924120826.png]]

Parameter Description:

“`text

odoo_site: odoo external network request address

frontend_site: large screen external network request address

iot_site: iothttp3 external network request address

kongagateway_odoo: the odoo gateway route set in KONGA

kongagateway_frontend: The gateway route of the big screen set in KONGA

“`

  1. Update the big screen address

Test odoo and big screen

Test odoo

– Log in to [Server Browser](http://183.213.16.9:9010/), and try to access **intranet** (192.168.32.91). `Be careful not to use the external network to access odoo, otherwise you will not be able to access it. Subsequent operations on odoo are performed using [server browser]`

Solutions for odoo-related problems

  1. **Access odoo white screen**

**This problem is generally caused by the backup project directory not being copied to the /opt/projects directory**. If you confirm that the copy is successful or not, please perform the following operations.

“`text

Method 1

Modify configuration file

docker exec -it dtsite_{{project name}} bash

echo “ODOO_HTTP_SOCKET_TIMEOUT=30” >> /etc/odoo/odoo.conf

Exit and restart

ctrl + D

docker restart dtsite_{{project name}}

Check whether the startup is successful

docker logs -f dtsite_{{project name}}

, if still not working, use method two

Execute the following command in the database

DELETE FROM ir_attachment WHERE url LIKE ‘/web/content/%’;

Restart the database

docker restart db_{{project name}}

“`

  1. odoo cannot be accessed, the page reports an error

**This situation is generally due to the lack of necessary python modules in the container**, use `docker logs -f {container name}` to view the error content to solve it. The installation method of the missing module is listed below, please check other problems by yourself

“`exec

Enter container

docker exec -it dtsite_{{project name}} bash

Install missing python modules

pip3 install ws4py pdfkit python-dateutil

Exit and restart

ctrl + D

docker restart dtsite_{{project name}}

Check whether the startup is successful

docker logs -f dtsite_{{project name}}

“`

Test the big screen

Try to access the big screen through a local browser. Note that if the large screen cannot be accessed. Execute the update screen script in serverOM.

![[Pasted image 20220921174302.png]]

If it still cannot be accessed, press F12 in the browser to check whether the request address is correct.

Deploy redis

– Tips: When deploying, please follow the deployment specifications of the old server for the port used

“`text

Assuming that the same starting port is 8020, the ports of each project service are as follows

Database: 8020

odoo: 8021

Large screen: 8022

iot: 8023

redis: 8024

“`

– Redis can be deployed directly through docker, which is fast

“`cmd

docker run –name redis_{{project abbreviation}} -p {{redis port}}:6379 -d redis redis-server –requirepass zhsz

“`

Deploy iothttp3

1. First configuration and installation dependencies

slightly. . .

2. Modify the iothttp3 project configuration on the server

Enter iothttp3/conf/{{project short name}}

“`cmd

Enter directory

cd /opt/iothttp3/conf/{project name}

Modify conf.py

vim ./conf.py

Modify lanuch

vim ./launch

“`

– Parameters that need to be modified in config.py

![[Pasted image 20220924105345.png]]

– Modify the startup port in launch

![[Pasted image 20220924105425.png]]

3. Check supervisor configuration

– iothttp3 uses supervisor to monitor, and the startup command is added to the /etc/supervisor/conf.d directory. If you need to modify, refer to the configuration file in the old server.

– After modification, the command to reload the configuration file is `supervisorctl reload`

4. Start iothttp3

– Open [Server Browser](http://183.213.16.9:9010/) to visit http://183.213.16.9:9010/ and start the corresponding iothttp3

![[Pasted image 20220924105844.png]]

  • Check the log log.

Click tail -f stdout to view the log to ensure that there is an error

![[Pasted image 20220924110433.png]]

Configure konga gateway

Contact the hardware manufacturer to modify the iot collection service address

Author: Wu Taiqiang