我完成了一个小应用程序的开发,并尝试将其投入生产。我将应用程序复制到一个新文件夹,使用新用户创建了一个新的psql数据库,调整了我的database.yml文件,并尝试运行rake db:schema:load使数据库处于正确的状态。由于执行了第一步,Rake能够连接到我的数据库,但是在执行完之后,它会中止并显示以下消息。据谷歌告诉我,这应该是用户的问题。但是,由于rake可以执行第一步,所以我怀疑我对此有疑问。
[root@l1vmgt08 web_qip_parser_v2]# rake db:schema:load
-- enable_extension("plpgsql")
-> 0.0171s
-- create_table("qip_changes", {:force=>:cascade})
-> 0.0919s
-- create_table("users", {:force=>:cascade})
-> 0.0989s
-- add_foreign_key("qip_changes", "users")
-> 0.0042s
-- enable_extension("plpgsql")
rake aborted!
ActiveRecord::NoDatabaseError: FATAL: role "root" does not exist
config / database.yml:
default: &default
adapter: postgresql
encoding: unicode
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
development:
<<: *default
database: my_db_name
username: my_user_name
password: my_password
host: localhost
port: 5432
test:
<<: *default
database: my_db_name
production:
<<: *default
database: my_db_name
username: my_user_name
password: my_password
host: localhost
port: 5432
我的开发人员和新的Prod用户的Psql输出以进行特权比较:
postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
------------------------+-------------------+----------+-------------+-------------+--------------------------------
my_dev_user_name | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =Tc/postgres +
| | | | | postgres=CTc/postgres +
| | | | | my_dev_db_name=CTc/postgres
my_user_name | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =Tc/postgres +
| | | | | postgres=CTc/postgres +
| | | | | my_db_name=CTc/postgres
所以在我看来,我想尝试使用本地用户通过UNIX套接字进行连接。我找到了一些描述此问题的文章。当我通过TCP / IP连接时,只需在我的database.yml文件中简单添加“ host:localhost”,即可解决此问题。但是,那正是我所做的,所以我不知道如何进行
这是我的pg_hba.conf:
# TYPE DATABASE USER ADDRESS METHOD
local all all peer
host all all 127.0.0.1/32 md5
服务器上正在运行另一个应用程序,该应用程序可以工作。它具有与我相同的database.yml配置。
答案 0 :(得分:0)
可能由于缺少测试环境的public class Main {
public static void main(String[] args) {
boolean tru = true;
try {
/*MQ Конфигурация подключения*/
MQQueueConnectionFactory mqQueueConnectionFactory = new MQQueueConnectionFactory();
mqQueueConnectionFactory.setHostName("localhost");
mqQueueConnectionFactory.setChannel("SVRCONN");
mqQueueConnectionFactory.setPort(1414);
mqQueueConnectionFactory.setIntProperty(WMQConstants.WMQ_CONNECTION_MODE, WMQConstants.WMQ_CM_CLIENT);
mqQueueConnectionFactory.setQueueManager("MQ_APPLE");
mqQueueConnectionFactory.setTransportType(JMSC.MQJMS_TP_CLIENT_MQ_TCPIP);
QueueConnection queueConnection = mqQueueConnectionFactory.createQueueConnection("name", "pass");
MQQueueSession session = (MQQueueSession) queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
MQQueue queue = (MQQueue) session.createQueue("queue:///Q1");
MQQueueReceiver receiver = (MQQueueReceiver) session.createReceiver(queue);
queueConnection.start();
while(tru){
TextMessage receivedMessage = (TextMessage) receiver.receive();
if(receivedMessage != null){
MStart(receivedMessage);
tru = false;
} else {
Timer timer = new Timer(10000,new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
System.out.println("Timer Run");
}
});
timer.start();
}
}
receiver.close();
session.close();
queueConnection.close();
} catch (JMSException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
public static void MStart(TextMessage receivedMessage) throws JMSException {
if (receivedMessage instanceof BytesMessage) {
TextMessage textMessage = (TextMessage) receivedMessage;
System.out.println("Received message '"
+ textMessage.getText() + "'");
} else if (receivedMessage instanceof TextMessage) {
System.out.println("Received message: " + receivedMessage.getText());
}
}
}
语句而发生了。
请参阅this question