【背景】
折腾:
【已解决】OpenFire中无法使用自定义数据库中用户去登陆
期间,注意到,别人:
Ignite Realtime : Discussion List – All Communities
Custom Authentication using MYSQL | Ignite Realtime
的domain是localhost:
'xmpp.domain' - 'localhost'
而我这里的是:
xmpp.domain | bogon
但是之前看到自己的bogon是无法解析的:
/opt/openfire/logs/warn.log
中有:
2015.07.08 04:36:11 org.jivesoftware.openfire.XMPPServer - Unable to determine local hostname. java.net.UnknownHostException: bogon: bogon: No address associated with hostname at java.net.InetAddress.getLocalHost(Unknown Source) at org.jivesoftware.openfire.XMPPServer.initialize(XMPPServer.java:356) at org.jivesoftware.openfire.XMPPServer.start(XMPPServer.java:491) at org.jivesoftware.openfire.XMPPServer.<init>(XMPPServer.java:216) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at java.lang.Class.newInstance(Unknown Source) at org.jivesoftware.openfire.starter.ServerStarter.start(ServerStarter.java:105) at org.jivesoftware.openfire.starter.ServerStarter.main(ServerStarter.java:56) Caused by: java.net.UnknownHostException: bogon: No address associated with hostname at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method) at java.net.InetAddress$1.lookupAllHostAddr(Unknown Source) at java.net.InetAddress.getAddressesFromNameService(Unknown Source) ... 11 more
【解决过程】
1.先不管,先去把domain改为localhost:
root@bogon:logs# mysql -u root -p openfire_xxx Enter password: Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 14067 Server version: 5.5.44-cll-lve MySQL Community Server (GPL) by Atomicorp Copyright (c) 2000, 2015, 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> UPDATE ofproperty SET propValue = 'xmpp.domain' WHERE `name` = 'localhost'; Query OK, 0 rows affected (0.00 sec) Rows matched: 0 Changed: 0 Warnings: 0 mysql> select * from ofproperty; +--------------------------------------------+------------------------------------------------------------------------------------------+ | name | propValue | +--------------------------------------------+------------------------------------------------------------------------------------------+ | adminConsole.port | 9090 | | adminConsole.securePort | 9091 | | connectionProvider.className | org.jivesoftware.database.DefaultConnectionProvider | | database.defaultProvider.connectionTimeout | 1.0 | | database.defaultProvider.driver | com.mysql.jdbc.Driver | | database.defaultProvider.maxConnections | 25 | | database.defaultProvider.minConnections | 5 | | database.defaultProvider.password | 033b026b73e667e577e75db8e1e89be18a5e2b73f753b7d0 | | database.defaultProvider.serverURL | jdbc:mysql://localhost:3306/openfire_xxx | | database.defaultProvider.testAfterUse | false | | database.defaultProvider.testBeforeUse | false | | database.defaultProvider.testSQL | select 1 | | database.defaultProvider.username | 5dd94410019658abf45bed61292a9278e345af92686462d9 | | jdbcAuthProvider.passwordSQL | select password from UserSecurity where userId=? | | jdbcAuthProvider.passwordType | plain | | jdbcGroupProvider.allGroupsSQL | SELECT groupId as groupName FROM GroupInfo | | jdbcGroupProvider.descriptionSQL | SELECT groupName as groupDescription FROM GroupInfo WHERE groupId=? | | jdbcGroupProvider.groupCountSQL | SELECT count(*) FROM GroupInfo | | jdbcGroupProvider.loadAdminsSQL | SELECT userId as username FROM GroupUser WHERE groupId=? AND isAdmin='Y' | | jdbcGroupProvider.loadMembersSQL | SELECT userId as username FROM GroupUser WHERE groupId=? AND isAdmin='N' | | jdbcGroupProvider.userGroupsSQL | SELECT groupId as groupName FROM GroupUser WHERE userId=? | | jdbcProvider.connectionString | jdbc:mysql://localhost:3306/xxxx?user=root&password=root | | jdbcProvider.driver | com.mysql.jdbc.Driver | | jdbcUserProvider.allUsersSQL | select userId as username from UserSecurity | | jdbcUserProvider.emailField | email | | jdbcUserProvider.loadUserSQL | SELECT t1.username as name, t2.email as email FROM UserBase t1, UserSecurity t2 userId=? | | jdbcUserProvider.nameField | name | | jdbcUserProvider.searchSQL | SELECT userId as username FROM UserSecurity WHERE | | jdbcUserProvider.userCountSQL | SELECT COUNT(*) FROM UserSecurity | | jdbcUserProvider.usernameField | username | | locale | zh_CN | | passwordKey | IbM546F0lyV9PSm | | provider.admin.className | org.jivesoftware.openfire.admin.DefaultAdminProvider | | provider.auth.className | org.jivesoftware.openfire.auth.DefaultAuthProvider | | provider.group.className | org.jivesoftware.openfire.group.DefaultGroupProvider | | provider.lockout.className | org.jivesoftware.openfire.lockout.DefaultLockOutProvider | | provider.securityAudit.className | org.jivesoftware.openfire.security.DefaultSecurityAuditProvider | | provider.user.className | org.jivesoftware.openfire.user.DefaultUserProvider | | provider.vcard.className | org.jivesoftware.openfire.vcard.DefaultVCardProvider | | setup | true | | update.lastCheck | 1436297725067 | | xmpp.auth.anonymous | true | | xmpp.domain | bogon | | xmpp.session.conflict-limit | 0 | | xmpp.socket.ssl.active | true | +--------------------------------------------+------------------------------------------------------------------------------------------+ 45 rows in set (0.00 sec) mysql> quit Bye root@bogon:logs#
然后重启OpenFire。
2.不对啊,没改掉这个:
xmpp.domain | bogon
搞反了,重新去:
UPDATE ofproperty SET propValue = 'localhost' WHERE `name` = 'xmpp.domain';
结果出现另外的错误:
【已解决】mysql连接出错:ERROR 1040 (HY000): Too many connections
然后就可以去改配置了:
root@bogon:logs# mysql -u root -p openfire_xxx Enter password: Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 440 Server version: 5.5.44-cll-lve MySQL Community Server (GPL) by Atomicorp Copyright (c) 2000, 2015, 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> UPDATE ofproperty SET propValue = 'localhost' WHERE `name` = 'xmpp.domain'; Query OK, 1 row affected (0.05 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> select * from ofProperty; +--------------------------------------------+------------------------------------------------------------------------------------------+ | name | propValue | +--------------------------------------------+------------------------------------------------------------------------------------------+ | adminConsole.port | 9090 | | adminConsole.securePort | 9091 | | connectionProvider.className | org.jivesoftware.database.DefaultConnectionProvider | | database.defaultProvider.connectionTimeout | 1.0 | | database.defaultProvider.driver | com.mysql.jdbc.Driver | | database.defaultProvider.maxConnections | 25 | | database.defaultProvider.minConnections | 5 | | database.defaultProvider.password | 033b026b73e667e577e75db8e1e89be18a5e2b73f753b7d0 | | database.defaultProvider.serverURL | jdbc:mysql://localhost:3306/openfire_xxx | | database.defaultProvider.testAfterUse | false | | database.defaultProvider.testBeforeUse | false | | database.defaultProvider.testSQL | select 1 | | database.defaultProvider.username | 5dd94410019658abf45bed61292a9278e345af92686462d9 | | jdbcAuthProvider.passwordSQL | select password from UserSecurity where userId=? | | jdbcAuthProvider.passwordType | plain | | jdbcGroupProvider.allGroupsSQL | SELECT groupId as groupName FROM GroupInfo | | jdbcGroupProvider.descriptionSQL | SELECT groupName as groupDescription FROM GroupInfo WHERE groupId=? | | jdbcGroupProvider.groupCountSQL | SELECT count(*) FROM GroupInfo | | jdbcGroupProvider.loadAdminsSQL | SELECT userId as username FROM GroupUser WHERE groupId=? AND isAdmin='Y' | | jdbcGroupProvider.loadMembersSQL | SELECT userId as username FROM GroupUser WHERE groupId=? AND isAdmin='N' | | jdbcGroupProvider.userGroupsSQL | SELECT groupId as groupName FROM GroupUser WHERE userId=? | | jdbcProvider.connectionString | jdbc:mysql://localhost:3306/xxx?user=root&password=root | | jdbcProvider.driver | com.mysql.jdbc.Driver | | jdbcUserProvider.allUsersSQL | select userId as username from UserSecurity | | jdbcUserProvider.emailField | email | | jdbcUserProvider.loadUserSQL | SELECT t1.username as name, t2.email as email FROM UserBase t1, UserSecurity t2 userId=? | | jdbcUserProvider.nameField | name | | jdbcUserProvider.searchSQL | SELECT userId as username FROM UserSecurity WHERE | | jdbcUserProvider.userCountSQL | SELECT COUNT(*) FROM UserSecurity | | jdbcUserProvider.usernameField | username | | locale | zh_CN | | passwordKey | IbM546F0lyV9PSm | | provider.admin.className | org.jivesoftware.openfire.admin.DefaultAdminProvider | | provider.auth.className | org.jivesoftware.openfire.auth.DefaultAuthProvider | | provider.group.className | org.jivesoftware.openfire.group.DefaultGroupProvider | | provider.lockout.className | org.jivesoftware.openfire.lockout.DefaultLockOutProvider | | provider.securityAudit.className | org.jivesoftware.openfire.security.DefaultSecurityAuditProvider | | provider.user.className | org.jivesoftware.openfire.user.DefaultUserProvider | | provider.vcard.className | org.jivesoftware.openfire.vcard.DefaultVCardProvider | | setup | true | | update.lastCheck | 1436297725067 | | xmpp.auth.anonymous | true | | xmpp.domain | localhost | | xmpp.session.conflict-limit | 0 | | xmpp.socket.ssl.active | true | +--------------------------------------------+------------------------------------------------------------------------------------------+ 45 rows in set (0.00 sec) mysql>
3.然后再去重启mysqld和OpenFire:
root@bogon:logs# service mysqld restart Stopping mysqld: [ OK ] Starting mysqld: [ OK ] root@bogon:logs# service openfire restart Shutting down openfire: [ OK ] Starting openfire:
然后重新打开OpenFire,登陆试试,结果:
2015.07.08 21:48:03 org.jivesoftware.openfire.XMPPServer - Unable to determine local hostname. java.net.UnknownHostException: bogon: bogon: No address associated with hostname at java.net.InetAddress.getLocalHost(Unknown Source) at org.jivesoftware.openfire.XMPPServer.initialize(XMPPServer.java:356) at org.jivesoftware.openfire.XMPPServer.start(XMPPServer.java:491) at org.jivesoftware.openfire.XMPPServer.<init>(XMPPServer.java:216) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) at java.lang.reflect.Constructor.newInstance(Unknown Source) at java.lang.Class.newInstance(Unknown Source) at org.jivesoftware.openfire.starter.ServerStarter.start(ServerStarter.java:105) at org.jivesoftware.openfire.starter.ServerStarter.main(ServerStarter.java:56) Caused by: java.net.UnknownHostException: bogon: No address associated with hostname at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method) at java.net.InetAddress$1.lookupAllHostAddr(Unknown Source) at java.net.InetAddress.getAddressesFromNameService(Unknown Source) ... 11 more 2015.07.08 21:48:04 org.jivesoftware.util.XMLProperties - XML Property 'provider.auth.className' differs from what is stored in the database. Please make property changes in the database instead of the configuration file. 2015.07.08 21:48:04 org.jivesoftware.util.XMLProperties - XML Property 'provider.user.className' differs from what is stored in the database. Please make property changes in the database instead of the configuration file. 2015.07.08 21:48:05 org.jivesoftware.openfire.container.AdminConsolePlugin - Admin console: Using RSA certificates but they are not valid for the hosted domain 2015.07.08 21:48:06 org.jivesoftware.openfire.http.HttpSessionManager - HttpSessionManager.init() recreate sendPacketPool 2015.07.08 21:48:06 org.jivesoftware.openfire.http.HttpBindManager - HTTP binding: Using RSA certificates but they are not valid for the hosted domain 2015.07.08 21:48:22 org.jivesoftware.admin.LoginLimitManager - Failed admin console login attempt by 123 from 58.208.66.48 2015.07.08 21:48:27 org.jivesoftware.admin.LoginLimitManager - Failed admin console login attempt by 123 from 58.208.66.48 2015.07.08 21:48:38 org.jivesoftware.admin.LoginLimitManager - Failed admin console login attempt by 123 from 58.208.66.48
还是有那个bogon无法解析的问题。
4.不过注意到了,此处是XMPPServer,应该指的是对于xml配置文件:
/opt/openfire/conf/openfire.xml
中的,所以要去修改该配置文件:
把对应的之前加的东西都删除掉:
然后重启OpenFire,看看新的log如何:
/opt/openfire/logs/warn.log
2015.07.08 21:57:27 org.jivesoftware.admin.LoginLimitManager - Failed admin console login attempt by 123 from 58.208.66.48 2015.07.08 22:01:40 org.jivesoftware.admin.LoginLimitManager - Failed admin console login attempt by 123 from 58.208.66.48
就没有了对应的xml解析的错误了。
【总结】
此处是通过把Openfire的配置文件:
/opt/openfire/conf/openfire.xml
中把之前添加的一堆的配置去掉,这样:
启动Openfire的时候,就不会出现解析xml错误的问题了。
而对应的配置信息,不写在xml配置文件里,而改写在数据库中,即可。
转载请注明:在路上 » 【已解决】OpenFire无法解析domain:org.jivesoftware.openfire.XMPPServer – Unable to determine local hostname