跳转至内容
  • 版块
  • 标签
  • 热门
  • 用户
  • 群组
皮肤
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • 默认(Flatly)
  • 不使用皮肤
折叠

Odoo 中文社区

  1. 主页
  2. 版块
  3. Odoo 安装指南
  4. Linux下OpenERP7备份、恢复数据库将不再支持md5验证方式

Linux下OpenERP7备份、恢复数据库将不再支持md5验证方式

已定时 已固定 已锁定 已移动 Odoo 安装指南
3 帖子 2 发布者 6.0k 浏览
  • 从旧到新
  • 从新到旧
  • 最多赞同
登录后回复
此主题已被删除。只有拥有主题管理权限的用户可以查看。
  • JoshuaJ 离线
    JoshuaJ 离线
    Joshua 管理员
    写于 最后由 编辑
    #1

    转载自: http://cn.openerp.cn/openerp_postgresql_authentication/

    OpenERP 使用的是PostgreSQL数据库,一般我们下载DEB包来安装或者按照官方的 http://doc.openerp.com/v6.1/install/linux/postgres/index.html ,linux下一般会通过一个叫OpenERP(当然也可以改成别的名字)的用户来运行OpenERP(这种连接数据库的方法就是peer认证)。在Windows下我们一般会通过数据库的用户名密码来连接数据库。
    以前我们想运行多个OpenERP实例,例如5.0, 6.0, 7.0一般会通过修改每个实例对应的配置文件的数据库名和密码来实现。

    db_name = openerp<br />db_password = postgres
    


    然后再修改pg_hba.conf ,把验证方式由peer改为md5。
    注:一般db_port不需要设置,否则postgresql会使用ip地址来连接,导致peer失效
    [quote]md5 :要求客户端提供一个 MD5 加密的口令进行认证

    peer:从操作系统中获取用户名,并检查它是否符合要求的数据库用户名。这是只适用于本地连接。[/quote]

    #local&nbsp;  all&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  all&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  peer
    


    由peer认证改为md5

    local&nbsp;  all&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  all&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  md5
    


    这是以前的做法,但是随着7.0的到来,openerp对于数据库安全性的要求提高了,现在如果还是通过md5来验证数据库,将不能再在openerp web上备份/恢复数据。(目前只是linux版本,windows暂时没有影响)。因为7.0安装模块更容易,甚至可以在<a title="Apps" href="http://v6apps.openerp.com/" target="_blank">apps</a>上直接安装。
    在代码里面体现为

    <br />&nbsp; &nbsp; @contextlib.contextmanager<br />&nbsp; &nbsp; def _set_pg_password_in_environment(self):<br />&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot; On Win32, pg_dump (and pg_restore) require that<br />&nbsp; &nbsp; &nbsp; &nbsp; :envvar:`PGPASSWORD` be set<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; This context management method handles setting<br />&nbsp; &nbsp; &nbsp; &nbsp; :envvar:`PGPASSWORD` iif win32 and the envvar is not already<br />&nbsp; &nbsp; &nbsp; &nbsp; set, and removing it afterwards.<br />&nbsp; &nbsp; &nbsp; &nbsp; &quot;&quot;&quot;<br />&nbsp; &nbsp; &nbsp; &nbsp; if os.name != &#039;nt&#039; or os.environ.get(&#039;PGPASSWORD&#039;):<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; yield<br />&nbsp; &nbsp; &nbsp; &nbsp; else:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; os.environ&#91;&#039;PGPASSWORD&#039;] = tools.config&#91;&#039;db_password&#039;]<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; try:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; yield<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; finally:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; del os.environ&#91;&#039;PGPASSWORD&#039;]
    


    这段代码与之前的区别在于现在在linux下将不再从配置文件里面读取密码。
    建议大家还是通过peer认证来连接OpenERP。关于postgresql各种认证方式可以访问 http://www.postgresql.org/docs/9.1/static/auth-pg-hba-conf.html

    【上海先安科技】(joshua AT openerp.cn),欢迎关注公众号:openerp_cn

    1 条回复 最后回复
    0
    • C 离线
      C 离线
      ccdos
      写于 最后由 编辑
      #2

      如果是确实要 备份数据,还自己在系统中 定时直接备份数据库为妥

      如果是转移数据,才从 web 做备份

      1 条回复 最后回复
      0

      • 登录

      • 没有帐号? 注册

      • 登录或注册以进行搜索。
      • 第一个帖子
        最后一个帖子
      0
      • 版块
      • 标签
      • 热门
      • 用户
      • 群组