Support Questions

Find answers, ask questions, and share your expertise

scm_prepare_database.sh failure

avatar
Explorer

Hello,

 

I have installed mysql database as external database and I'm trying to run scm_prepare_database.sh script and I get this error;

 

[root@cm mysql]# /usr/share/cmf/schema/scm_prepare_database.sh mysql -h localhost -u temp -p --verbose scmdb scmuser
Enter database password:
Enter SCM password:
JAVA_HOME=/usr/java/jdk1.8.0_171-amd64/
Verifying that we can write to /etc/cloudera-scm-server
Database type: mysql
Database user: temp
Executing: /usr/java/jdk1.8.0_171-amd64//bin/java -cp /usr/share/java/mysql-connector-java.jar:/usr/share/java/oracle-connector-java.jar:/usr/share/java/postgresql-connector-java.jar:/usr/share/cmf/schema/../lib/* com.cloudera.enterprise.dbutil.DbProvisioner --create -h localhost -u temp -H localhost -U scmuser -d scmdb -t mysql
[ main] DbProvisioner ERROR Exception when creating/dropping database with user 'temp' and jdbc url 'jdbc:mysql://localhost/?useUnicode=true&characterEncoding=UTF-8'
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)[:1.8.0_171]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)[:1.8.0_171]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)[:1.8.0_171]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)[:1.8.0_171]
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)[mysql-connector-java.jar:]
at com.mysql.jdbc.Util.getInstance(Util.java:386)[mysql-connector-java.jar:]
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1015)[mysql-connector-java.jar:]
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989)[mysql-connector-java.jar:]
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:975)[mysql-connector-java.jar:]
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:920)[mysql-connector-java.jar:]
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2570)[mysql-connector-java.jar:]
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2306)[mysql-connector-java.jar:]
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:839)[mysql-connector-java.jar:]
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:49)[mysql-connector-java.jar:]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)[:1.8.0_171]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)[:1.8.0_171]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)[:1.8.0_171]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)[:1.8.0_171]
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)[mysql-connector-java.jar:]
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:421)[mysql-connector-java.jar:]
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:350)[mysql-connector-java.jar:]
at java.sql.DriverManager.getConnection(DriverManager.java:664)[:1.8.0_171]
at java.sql.DriverManager.getConnection(DriverManager.java:247)[:1.8.0_171]
at com.cloudera.enterprise.dbutil.DbProvisioner.executeSql(DbProvisioner.java:296)[db-common-5.15.0.jar:]
at com.cloudera.enterprise.dbutil.DbProvisioner.doMain(DbProvisioner.java:104)[db-common-5.15.0.jar:]
at com.cloudera.enterprise.dbutil.DbProvisioner.main(DbProvisioner.java:123)[db-common-5.15.0.jar:]
[ main] DbProvisioner ERROR Stack Trace:
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)[:1.8.0_171]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)[:1.8.0_171]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)[:1.8.0_171]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)[:1.8.0_171]
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)[mysql-connector-java.jar:]
at com.mysql.jdbc.Util.getInstance(Util.java:386)[mysql-connector-java.jar:]
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1015)[mysql-connector-java.jar:]
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989)[mysql-connector-java.jar:]
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:975)[mysql-connector-java.jar:]
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:920)[mysql-connector-java.jar:]
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2570)[mysql-connector-java.jar:]
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2306)[mysql-connector-java.jar:]
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:839)[mysql-connector-java.jar:]
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:49)[mysql-connector-java.jar:]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)[:1.8.0_171]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)[:1.8.0_171]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)[:1.8.0_171]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)[:1.8.0_171]
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)[mysql-connector-java.jar:]
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:421)[mysql-connector-java.jar:]
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:350)[mysql-connector-java.jar:]
at java.sql.DriverManager.getConnection(DriverManager.java:664)[:1.8.0_171]
at java.sql.DriverManager.getConnection(DriverManager.java:247)[:1.8.0_171]
at com.cloudera.enterprise.dbutil.DbProvisioner.executeSql(DbProvisioner.java:296)[db-common-5.15.0.jar:]
at com.cloudera.enterprise.dbutil.DbProvisioner.doMain(DbProvisioner.java:104)[db-common-5.15.0.jar:]
at com.cloudera.enterprise.dbutil.DbProvisioner.main(DbProvisioner.java:123)[db-common-5.15.0.jar:]
--> Error 1, giving up (use --force if you wish to ignore the error)

 

Could you help me on this?

 

Best regards,

 

Huriye

14 REPLIES 14

avatar
Super Collaborator
I cannot see any clear indication in the logs, other than connection to mysql failed for some reason. mysql java connector seem to be in place. Have you installed mysql with default options? Port 3306? If for example, you have used 3307, then you should also specify "-P 3307". I recommend to specify it, even if you are using the default port. Have you granted permissions to "temp" user according to instructions? PS: since your mysql is on localhost, you do not need to define another user and you can use root /usr/share/cmf/schema/scm_prepare_database.sh mysql -h localhost -u root -p --verbose scmdb scmuser

avatar
Explorer

Hello,

Thank you for the response. I have installed mysql with default options, even if I specify the port I still get the same error. I also tried to run the script by using root user, I still get the same error.

Thanks,

Huriye

avatar
Super Collaborator

Can you try

mysql -h localhost -u temp -p

just to verify that mysql server accepts connections?

 

Also, can you check if SELinux is enabled?

getenforce

If the output is "1" then you should disable it.

Temp change

setenforce 0

avatar
Explorer

Hello,

 

I can access to mysql with temp user and I have disabled selinux before. I get the output in below;

 

[root@cm ~]# mysql -h localhost -u temp -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 8.0.11 MySQL Community Server - GPL

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> exit
Bye
[root@cm ~]# getenforce
Disabled

 

Thanks,

 

Huriye

avatar
Master Guru

@Huriye,

 

Try using tcpdump to see if a connection is established with mysql

 

for example:

 

# tcpdump -i any -w ~/mysql.pcap port 3306

 

Run that while using scm_prepare_database.sh and find out if the connection is being made.

 

You can open mysql.pcap in WireShark to view the packets,etc.

 

If it is, check mysql logs for clues if the connection is being made at the TCP level but the server is rejecting the connection for some reason.

avatar
Explorer

Hello,

 

I run the tcpdump command, the output is in below;

 

[root@cm ~]# tcpdump -i any -w ~/mysql.pcap port 3306
tcpdump: listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes

 

There is no error in mysqld.log and mysql.log.

 

Do you have any idea?

 

Thanks,

 

Huriye

avatar
Super Collaborator
I suppose that you have followed Cloudera's instructions and created the temp user with the command below: mysql> grant all on *.* to 'temp'@'%' identified by 'temp' with grant option; Which is fine. In that case you should use the actual hostname instead of localhost. In mysql "%" does not always include "localhost".

avatar
Explorer

Hello,

 

I checked if root is belong to local host and I tried to run with root user and localhost but got the same error. 

 


mysql> SELECT User, Host FROM mysql.user;
+------------------+-----------+
| User | Host |
+------------------+-----------+
| reportmanager | % |
| temp | % |
| mysql.infoschema | localhost |
| mysql.session | localhost |
| mysql.sys | localhost |
| root | localhost |
+------------------+-----------+
6 rows in set (0.01 sec)

mysql> exit
Bye

 

 

 

 

[root@cm ~]# /usr/share/cmf/schema/scm_prepare_database.sh mysql -h localhost -u root -p 3306 --verbose scmdb scmuser
Enter database password:
JAVA_HOME=/usr/java/jdk1.8.0_171-amd64/
Verifying that we can write to /etc/cloudera-scm-server
Database type: mysql
Database user: root
Executing: /usr/java/jdk1.8.0_171-amd64//bin/java -cp /usr/share/java/mysql-connector-java.jar:/usr/share/java/oracle-connector-java.jar:/usr/share/java/postgresql-connector-java.jar:/usr/share/cmf/schema/../lib/* com.cloudera.enterprise.dbutil.DbProvisioner --create -h localhost -u root -H localhost -U scmdb -d 3306 -t mysql
[ main] DbProvisioner ERROR Exception when creating/dropping database with user 'root' and jdbc url 'jdbc:mysql://localhost/?useUnicode=true&characterEncoding=UTF-8'
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)[:1.8.0_171]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)[:1.8.0_171]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)[:1.8.0_171]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)[:1.8.0_171]
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)[mysql-connector-java.jar:]
at com.mysql.jdbc.Util.getInstance(Util.java:386)[mysql-connector-java.jar:]

avatar
Master Guru

@Huriye,

 

You need to view the pcap file in WireShark and check to see what's going on.  The exception that is displayed does not tell the entire story, stack-wise.  Usually there is a caused by that shows "connection refused" or something else.  I'm not sure why we don't see that in this case.

 

I suggest using some test code outside Cloudera Manager to test as the stack trace indicates there are problems connecting via Java.

 

There are example sources everywhere... this one I think is pretty simple.  You could compile after making the JDBC url look like is formulated by scm_prepare_database.sh

 

http://www.vogella.com/tutorials/MySQLJava/article.html

 

At the least this may give us the full stack trace.