1. 程式人生 > >CentOS 6.5 Python+PostGreSql環境搭建(openerp 7.0)

CentOS 6.5 Python+PostGreSql環境搭建(openerp 7.0)

正式站點伺服器更換,現在需要把原本執行在Ubuntu上的開源ERP軟體openerp 7.0遷移到新的CentOS 6.5的伺服器上。

第一次在生產環境上配置Linux,學習到好多東西,記錄一下,方便以後會用到(比如.net core)。 

同時也分享一下遷移過程中學到的東西。需要有Linux基本操作基礎。

常用

yum命令是在Fedora和RedHat以及SUSE中基於rpm的軟體包管理器,它可以使系統管理人員互動和自動化地更細與管理RPM軟體包,能夠從指定的伺服器自動下載RPM包並且安裝,可以自動處理依賴性關係,並且一次安裝所有依賴的軟體包,無須繁瑣地一次次下載、安裝。

yum詳解

yum install 包名

yum remove 包名

Ubuntu

apt-get install 

wget命令 可以把網路地址中的檔案下載到當前目錄中

wget https://pypi.python.org/packages/90/bf/9da959928a4f212c56e0b31299ef1d28e3b2457b484cb9dfc8df23258235/aetros-0.14.2.tar.gz

還有兩個解壓命令

tar xzvf 壓縮包名 解壓路徑(不填則解壓到當前目錄)

tar xzvf aetros-0.14.2.tar.gz 

unzip 需要先安裝 yum -y install wget unzip

unzip 包名字


安裝openerp 的Python環境

yum -y install python-psycopg2 python-lxml PyXML python-setuptools libxslt-python pytz \
python-matplotlib python-babel python-mako python-dateutil python-psycopg2 \
pychart pydot python-reportlab python-devel python-imaging python-vobject \


hippo-canvas-python mx python-gdata python-ldap python-openid \
python-werkzeug python-vatnumber pygtk2 glade3 pydot python-dateutil \
python-matplotlib pygtk2 glade3 pydot python-dateutil python-matplotlib \
python python-devel python-psutil python-docutils make\
automake gcc gcc-c++ kernel-devel byacc flashplugin-nonfree poppler-utils pywebdav

安裝PIP   PyPA推薦的安裝Python軟體包的工具

安裝pip
$ curl -O http://pypi.python.org/packages/source/d/distribute/distribute-0.6.45.tar.gz
$ tar -xzvf distribute-0.6.45.tar.gz
$ cd distribute-0.6.45
$ sudo python setup.py install
$ sudo easy_install pip

安裝完成之後可以使用

pip install Python軟體包

pip uninstall Python軟體包

easy_install  包名

某些包找不到的話需要下載後手動安裝

推薦的下載地址

https://pypi.python.org/pypi

https://pypi.python.org/simple/

解壓並進入安裝目錄後

python setup.py install 執行安裝

安裝PostgreSQL

yum -y install postgresql92-libs postgresql92-server postgresql92

初始化PostgreSQL資料庫

service postgresql-9.2 initdb
chkconfig postgresql-9.2 on
service postgresql-9.2 start
su - postgres -c "createuser --superuser openerp"

PostgreSQL的備份和還原

  1. 切換到資料庫使用者: sudo su - postgres
  2. 備份資料: pg_dump testdb > testdb.out

利用備份檔案,恢復資料庫:
  1. 切換到資料庫使用者: sudo su - postgres
  2. 停止openerp: service openerp stop
  3. 刪除舊的資料庫:dropdb testdb
  4. 新建資料庫,並關聯到openerp使用者:createdb -O openerp  testdb
  5. 匯入之前備份過的資料:psql -d testdb -f testdb.out

從中發現的問題

1 安裝openerp時 提示Python包版本號不對或引用不存在

反覆使用pip install yun install easy_install  和手動下載安裝


2 Ubuntu中的postgresql啟動配置和CentOS不一致。這導致openerp 需要

/var/run/postgresql/.s.PGSQL.5432而Linux命令列需要/tmp/.s.PGSQL.5432

不然報錯: [歸檔 (db)] 與資料庫 "Test" 聯接失敗: 無法聯接到伺服器: 沒有那個檔案或目錄

伺服器是否在本地執行並且在 Unix 域套接字"/tmp/.s.PGSQL.5432"上準備接受聯接?

目前想讓openerp執行起來需要改動/var/lib/pgsql/9.2/data/postgresql.conf

unix_socket_directory = ' /var/run/postgresql ' # (改動需要重啟資料庫) service postgresql9.2 restart 想從命令列操作資料庫需要註釋這一行.

導致問題是要麼openerp報錯.要麼命令列報錯

目前沒有找到解決辦法。


參照

openerp資料備份與恢復 

http://blog.csdn.net/huguohuan/article/details/38362567

openerp 7.0 centos 一鍵安裝 shell 

http://www.codeweblog.com/openerp-7-0-centos-%E4%B8%80%E9%94%AE%E5%AE%89%E8%A3%85-shell-%E8%BD%AC%E8%87%AAopenerp%E8%AE%BA%E5%9D%9B/

openerp7.0官方教程(for ubuntu) 

https://doc.odoo.com/7.0/install/linux/postgres/

openerp備份恢復資料庫 master password 

http://blog.csdn.net/uhml/article/details/51731004?locationNum=3&fps=1