简体   繁体   中英

Not able to connect postgresql with odoo

I configured odoo in aws ec2 and connecting Postgresql from rds when I run the command ./odoo-bin --config=/etc/odoo.conf and try to access from a browser, I'm getting the following error:

ERROR odoo_db odoo.modules.loading: Database odoo_db not initialized, you can force it with `-i base` 

File "/opt/odoo/odoo/odoo/modules/registry.py", line 176, in __getitem__
    return self.models[model_name]
KeyError: 'ir.http' - - -

and also I'm getting this error as well:

STATEMENT:  SELECT latest_version FROM ir_module_module WHERE name='base'
ERROR odoo_db odoo.sql_db: bad query: SELECT latest_version FROM ir_module_module WHERE name='base'
ERROR: relation "ir_module_module" does not exist

In command line run:

 ./odoo-bin --addons-path=addons --database=odoo  --db_user=odoo --db_password=odoo  --db_host=localhost --db_port=5432 -i INIT

explicitly give db name, user and password, "-i INIT" option initialises the odoo database

The first glance issue is though the DB has created in Postgres but it has not the required odoo related setup records ie base setup. You can verify by directly accessing the DB and see the number of tables or browsing some tables.

It happens sometimes that you create the DB [specifically giving similar DB names as you have already created before and deleted later [its dropped from PG but still has traces in session or DB location path], it will not get initialized properly.

Solution:

  1. Create sample DB with different name initial 4 characters different completely and check
  2. Initialize the DB from odoo.conf file add db_name = < Your DB Name > {for experiment purpose put completely different name} and restart odoo services and check

Hope it will help. Njoy troubleshooting!

First do what @FaisalAnsari says in here (what I reference below):

*

Go to RDS and create a database in PostgreSQL and configure the server.conf file as the given below.

 ;This is the password that allows database operations: ;admin_passwd = admin db_host = rds_endpoint (after creating database you will get rds_endpoint) db_port = False db_user = "user name which is created by you to the database" db_password = "password which is created" ;addons_path = /home/deadpool/workspace/odoo_13_community/custom_addons, /home/deadpool/workspace/odoo_13_community/custom_addons

Then go to the command line and do the following.

  1. Stop your odoo instance
~$ service odoo stop
  1. Enable command line for the user odoo
~$ chsh -s /bin/bash odoo
  1. execute odoo from command line as user odoo
~$ runuser -l odoo -c "odoo -i base -d YourRDSDatabase --db_host YourAmazonRDSHost.Address.rds.amazonaws.com -r YourRDSDatabaseUserName -w YourRDSDatabasePassword --stop-after-init"
  1. After the initialization finished, start odoo service
~$ service odoo start

Troubleshooting :

if odoo doesn't start correctly make sure that the database user in your RDS instance have privileges at least on the database you are using.

~$ psql --host=YourAmazonRDSHost.Address.rds.amazonaws.com --port=5432 --username=YourRDSDatabaseUserName --password --dbname=YourRDSDatabase

and when you are inside postgresql type the following:

~$ grant all privileges on database YourRDSDatabase to YourRDSDatabaseUserName;

~$ \q

and try again from step 3.

Hope that Helps!!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM