Customize Database

Top  Previous  Next

The default NGASI configuration comes with an embedded Apache Derby

Database. This is ideal for demos and testing. However in production

it may be desirable to use a more robust database such as PostgreSQL

or MySQL. To change the Database, you simply need to change

Database entries in the following file

 

/usr/ngasi/conf/Catalina/localhost/ROOT.xml

 

For example, to use a MySQL database, edit the file like so:

<Context path="" crossContext="true">

<Resource name="jdbc/ws" auth="Container" type="javax.sql.DataSource"

maxActive="200" maxIdle="20" maxWait="10000"

username="ws_portalu" password="tiger" driverClassName="com.mysql.jdbc.Driver"

url="jdbc:mysql://localhost:3306/ws_portal?autoReconnect=true"/>

       <Resource

               name="mail/MailSession"

               auth="Container"

               type="javax.mail.Session"

               mail.smtp.host="localhost"

       />

<Realm className="com.ws.web.auth.WSTomcatDataSourceRealm" digest="SHA"

dataSourceName="jdbc/ws" localDataSource="true"

userTable="wsusers" userNameCol="username" userCredCol="passphrase"

userRoleTable="wsuserroles" roleNameCol="rolename"

mailHostDS="ws" mailHostTable="ws_mail_info" mailHostCol="mailhost" domainCol="domain" customUserName="postmaster@*" customUserRoleName="postmaster" defaultUserRole="wsportaluser"

passFile="/etc/shadow" passFileType="unix" disallowedSysUsers="admin" vpsRoot="/vz/private/" authConfDir="/usr/ngasi/webapps/ROOT/WEB-INF/ws/auth/"

externalDBConnectionURL="jdbc:mysql://localhost/psa?autoReconnect=true" externalDBQuery="SELECT PASSWORD FROM accounts WHERE id = (SELECT account_id FROM clients WHERE login = ?)" externalDBDriver="com.mysql.jdbc.Driver" externalDBUser="admin" externalDBPasswordFile="/etc/psa/.psa.shadow"

/>

</Context>

 

 

To migrate an existing Database, run the combined SQL scripts from

/usr/ngasi/webapps/ROOT/WEB-INF/ws/webapps/appservermgr/ZP-INF/load_db.sql

and the Backup db.sql script on the new Database.