Basic Software installation| Moving micro-services into AWS EC2 instance – Part 1

As I mentioned in the previous post, I should move out of micro-services. Solving this I am taking an AWS EC2 instance and configuring every micro-services in this instance. Here I use Ubuntu 16.04 machine, because my application setup is little old. You can take Ubuntu 20.04 if you have newer versions of Rails, Ruby etc.

Our setup includes Ruby on Rails (5.2.1) micro-services (5-10 nos), NodeJS application, Sinatra Application, Angular 9.1 Front-End Application.

Go to AWS EC2 home page and select ubuntu 16.04 machine with default configurations and ssh enabled.

https://ap-south-1.console.aws.amazon.com/ec2/v2/home

Now login to this new instance and install all the packages we needed for our setup.

Software Installation

Update the package list.

sudo apt-get update

Install Ruby dependencies.

sudo apt-get install ruby-dev
sudo apt-get install libxml2-dev
sudo apt-get install libxslt-dev
sudo apt-get install graphviz

Install NodeJS

curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs
node -v

Install yarn and other dependencies.

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update
sudo apt-get install git-core zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev nodejs yarn

Install Mysql 5.7 (Remember this is for Ubuntu 16.04, 18.04 versions)

sudo apt-get install mysql-server-5.7 mysql-client-core-5.7 libmysqlclient-dev
sudo service mysql status # or
systemctl status mysql
username: <your-username>, password: <your-password>

You can also try
mysql_secure_installation, if you use other mysql version.

Note: If you are setting up Ubuntu 20.04 note that there is a big change in mysql and the version of mysql is 8.0 instead of 5.7. If you have applications running in mysql 5.7 then setup and use Ubuntu 16.04 or 18.04.

Let’s continue the installation in our next post.

Liferay 7.3: Connect with MYSQL database

Go inside the downloaded liferay portal folder. And start the tomcat server

cd ~/liferay-ce-portal-tomcat-7.3.0-ga1-20200127150653953/liferay-ce-portal-7.3.0-ga1/tomcat-9.0.17/bin
sh startup.sh


Goto http://localhost:8080/ and start setting up liferay configurations as follows:

Do the basic configuration and change database to mysql

Mysql database is recommended fot staging and production environment.

JDBC URL:
jdbc:mysql://localhost/lportal?characterEncoding=UTF-8&dontTrackOpenResources=true&holdResultsOpenOverStatementClose=true&serverTimezone
=GMT&useFastDateParsing=false&useUnicode=true
JDBC Driver Class Name: com.mysql.cj.jdbc.Driver

If you get the error like this, some of your provided mysql configuration went wrong. Check your mysql username and password.

If the given mysql configuration is correct, then you have to check the Liferay DB exists in your Mysql database. Else create the DB `lportal` as follows:

Create database ‘lportal’

Now click on the Configure button, you will be ready to go

Open ‘~/liferay-ce-portal-tomcat-7.3.0-ga1-20200127150653953/liferay-ce-portal-7.3.0-ga1/portal-setup-wizard.properties’ file and you can see the above configurations added by liferay.

You can see the above server log in Dev studio. Here mentioned about which property files loads during the start and picking MYSQL DB, creating tables for first time in `lportal` database, inserting data to the table

You can see the following tables populated in the database lportal

mysql> show tables;
+--------------------------------+
| Tables_in_lportal              |
+--------------------------------+
| AMImageEntry                   |
| AccountEntry                   |
| AccountEntryOrganizationRel    |
| AccountEntryUserRel            |
| AccountRole                    |
| Account_                       |
| Address                        |
| AnnouncementsDelivery          |
| AnnouncementsEntry             |
| AnnouncementsFlag              |
| AppBuilderApp                  |
| AppBuilderAppDeployment        |
| AssetAutoTaggerEntry           |
| AssetCategory                  |
| AssetCategoryProperty          |
| AssetDisplayPageEntry          |
| AssetEntries_AssetCategories   |
| AssetEntries_AssetTags         |
| AssetEntry                     |
| AssetEntryAssetCategoryRel     |
| AssetEntryUsage                |
| AssetLink                      |
| AssetListEntry                 |
| AssetListEntryAssetEntryRel    |
| AssetListEntrySegmentsEntryRel |
| AssetListEntryUsage            |
| AssetTag                       |
| AssetVocabulary                |
| Audit_AuditEvent               |
| BackgroundTask                 |
| BatchEngineExportTask          |
| BatchEngineImportTask          |
| BlogsEntry                     |
| BlogsStatsUser                 |
| BrowserTracker                 |
| CTCollection                   |
| CTEntry                        |
| CTMessage                      |
| CTPreferences                  |
| CTProcess                      |
| CTSContent                     |
| Calendar                       |
| CalendarBooking                |
| CalendarNotificationTemplate   |
| CalendarResource               |
| ChangesetCollection            |
| ChangesetEntry                 |
| ClassName_                     |
| Company                        |
| CompanyInfo                    |
| Configuration_                 |
| Contact_                       |
| Contacts_Entry                 |
| Counter                        |
| Country                        |
| DDLRecord                      |
| DDLRecordSet                   |
| DDLRecordSetVersion            |
| DDLRecordVersion               |
| DDMContent                     |
| DDMDataProviderInstance        |
| DDMDataProviderInstanceLink    |
| DDMFormInstance                |
| DDMFormInstanceRecord          |
| DDMFormInstanceRecordVersion   |
| DDMFormInstanceVersion         |
| DDMStorageLink                 |
| DDMStructure                   |
| DDMStructureLayout             |
| DDMStructureLink               |
| DDMStructureVersion            |
| DDMTemplate                    |
| DDMTemplateLink                |
| DDMTemplateVersion             |
| DEDataDefinitionFieldLink      |
| DEDataListView                 |
| DLContent                      |
| DLFileEntry                    |
| DLFileEntryMetadata            |
| DLFileEntryType                |
| DLFileEntryTypes_DLFolders     |
| DLFileRank                     |
| DLFileShortcut                 |
| DLFileVersion                  |
| DLFileVersionPreview           |
| DLFolder                       |
| DLOpenerFileEntryReference     |
| DLSyncEvent                    |
| EmailAddress                   |
| ExpandoColumn                  |
| ExpandoRow                     |
| ExpandoTable                   |
| ExpandoValue                   |
| ExportImportConfiguration      |
| FragmentCollection             |
| FragmentEntry                  |
| FragmentEntryLink              |
| FriendlyURLEntry               |
| FriendlyURLEntryLocalization   |
| FriendlyURLEntryMapping        |
| Group_                         |
| Groups_Orgs                    |
| Groups_Roles                   |
| Groups_UserGroups              |
| HtmlPreviewEntry               |
| IM_MemberRequest               |
| Image                          |
| JournalArticle                 |
| JournalArticleLocalization     |
| JournalArticleResource         |
| JournalContentSearch           |
| JournalFeed                    |
| JournalFolder                  |
| KBArticle                      |
| KBComment                      |
| KBFolder                       |
| KBTemplate                     |
| KaleoAction                    |
| KaleoCondition                 |
| KaleoDefinition                |
| KaleoDefinitionVersion         |
| KaleoInstance                  |
| KaleoInstanceToken             |
| KaleoLog                       |
| KaleoNode                      |
| KaleoNotification              |
| KaleoNotificationRecipient     |
| KaleoTask                      |
| KaleoTaskAssignment            |
| KaleoTaskAssignmentInstance    |
| KaleoTaskForm                  |
| KaleoTaskFormInstance          |
| KaleoTaskInstanceToken         |
| KaleoTimer                     |
| KaleoTimerInstanceToken        |
| KaleoTransition                |
| Layout                         |
| LayoutBranch                   |
| LayoutClassedModelUsage        |
| LayoutFriendlyURL              |
| LayoutPageTemplateCollection   |
| LayoutPageTemplateEntry        |
| LayoutPageTemplateStructure    |
| LayoutPageTemplateStructureRel |
| LayoutPrototype                |
| LayoutRevision                 |
| LayoutSEOEntry                 |
| LayoutSEOSite                  |
| LayoutSet                      |
| LayoutSetBranch                |
| LayoutSetPrototype             |
| ListType                       |
| Lock_                          |
| MBBan                          |
| MBCategory                     |
| MBDiscussion                   |
| MBMailingList                  |
| MBMessage                      |
| MBStatsUser                    |
| MBThread                       |
| MBThreadFlag                   |
| MDRAction                      |
| MDRRule                        |
| MDRRuleGroup                   |
| MDRRuleGroupInstance           |
| Marketplace_App                |
| Marketplace_Module             |
| MembershipRequest              |
| OA2Auths_OA2ScopeGrants        |
| OAuth2Application              |
| OAuth2ApplicationScopeAliases  |
| OAuth2Authorization            |
| OAuth2ScopeGrant               |
| OrgGroupRole                   |
| OrgLabor                       |
| Organization_                  |
| PasswordPolicy                 |
| PasswordPolicyRel              |
| PasswordTracker                |
| Phone                          |
| PluginSetting                  |
| PollsChoice                    |
| PollsQuestion                  |
| PollsVote                      |
| PortalPreferences              |
| Portlet                        |
| PortletItem                    |
| PortletPreferences             |
| QUARTZ_BLOB_TRIGGERS           |
| QUARTZ_CALENDARS               |
| QUARTZ_CRON_TRIGGERS           |
| QUARTZ_FIRED_TRIGGERS          |
| QUARTZ_JOB_DETAILS             |
| QUARTZ_LOCKS                   |
| QUARTZ_PAUSED_TRIGGER_GRPS     |
| QUARTZ_SCHEDULER_STATE         |
| QUARTZ_SIMPLE_TRIGGERS         |
| QUARTZ_SIMPROP_TRIGGERS        |
| QUARTZ_TRIGGERS                |
| RatingsEntry                   |
| RatingsStats                   |
| ReadingTimeEntry               |
| RecentLayoutBranch             |
| RecentLayoutRevision           |
| RecentLayoutSetBranch          |
| Region                         |
| Release_                       |
| Repository                     |
| RepositoryEntry                |
| ResourceAction                 |
| ResourcePermission             |
| Role_                          |
| SAPEntry                       |
| SegmentsEntry                  |
| SegmentsEntryRel               |
| SegmentsEntryRole              |
| SegmentsExperience             |
| SegmentsExperiment             |
| SegmentsExperimentRel          |
| ServiceComponent               |
| SharingEntry                   |
| SiteFriendlyURL                |
| SiteNavigationMenu             |
| SiteNavigationMenuItem         |
| SocialActivity                 |
| SocialActivityAchievement      |
| SocialActivityCounter          |
| SocialActivityLimit            |
| SocialActivitySet              |
| SocialActivitySetting          |
| SocialRelation                 |
| SocialRequest                  |
| Subscription                   |
| SystemEvent                    |
| Team                           |
| Ticket                         |
| TrashEntry                     |
| TrashVersion                   |
| UserGroup                      |
| UserGroupGroupRole             |
| UserGroupRole                  |
| UserGroups_Teams               |
| UserIdMapper                   |
| UserNotificationDelivery       |
| UserNotificationEvent          |
| UserTracker                    |
| UserTrackerPath                |
| User_                          |
| Users_Groups                   |
| Users_Orgs                     |
| Users_Roles                    |
| Users_Teams                    |
| Users_UserGroups               |
| ViewCountEntry                 |
| VirtualHost                    |
| WebDAVProps                    |
| Website                        |
| WikiNode                       |
| WikiPage                       |
| WikiPageResource               |
| WorkflowDefinitionLink         |
| WorkflowInstanceLink           |
+--------------------------------+
262 rows in set (0.00 sec)

mysql> 

Here is the list of Users created. We are selected `Add Sample data` option at the time configuration. That is why we can see lot of users with my domain is listed

Login with

Email: provide the email given at the time of register

Password: test (default password for version 7.3)

If you are using Liferay 7.2 version, then this default password may not work. In this version liferay generates a random password, that you can check in the log file as below:

cd ~/Downloads/liferay-ce-portal-tomcat-7.2.1-ga2-20191111141448326/liferay-ce-portal-7.2.1-ga2/tomcat-9.0.17/logs/ && tail -f catalina.out


Search word password. You can get it.

After login you can see this terms of use page

Then a Password remainder page

DONE! Congrats, you can see the admin home page with all controls

changing to new db from old db

Add the new db name ‘liferay721’ to portal-setup-wizard.properties

.........
jdbc.default.url=jdbc:mysql://localhost/liferay721?characterEncoding=UTF-8&dontTrackOpenResources=true&holdResultsOpenOverStatementClose=true&serverTimezone=GMT&useFastDateParsing=false&useUnicode=true
.........

Restart the server. Server Log:

Starting Liferay Community Edition Portal 7.2.1 CE GA2 (Mueller / Build 7201 / November 12, 2019)

2020-05-08 14:45:53.921 INFO  [main][StartupHelper:75] There are no patches installed
2020-05-08 14:45:54.000 WARN  [main][ReleaseLocalServiceImpl:238] Table 'liferay721.Release_' doesn't exist
2020-05-08 14:45:54.003 INFO  [main][ReleaseLocalServiceImpl:129] Create tables and populate with default data
...................
...................

Issues you may face during the setup

Once I created a DB names liferay_7_3_1 and the setup wizard finishes successfully and message shown to restart the server for get into the portal.

When I restart it I received the following issue:

An unexpected system error occurred.

java.lang.NullPointerException

Database is not setup properly. Check the DB name. Use characters as DB name if possible and start the server. If proper DB setup is done, then you can see 250 – 280 tables in database

and the following tables were created in the database named liferay_7_3_1

Only 155 rows

+--------------------------------+
| Tables_in_liferay_7_3_1        |
+--------------------------------+
| AccountEntry                   |
| AccountEntryOrganizationRel    |
| AccountEntryUserRel            |
.........
|
| Website                        |
| WikiNode                       |
| WikiPage                       |
| WikiPageResource               |
| WorkflowDefinitionLink         |
| WorkflowInstanceLink           |
+--------------------------------+
155 rows in set (0.00 sec)

Then I renamed the DB to liferay731. Then it works! So beware of underscore characters in your DB name.

Another error is shown when the server is not able to connect to your database, or database is not created that is specified as in your portal.ext.properties or portal-setup-wizard.properties

Create a database specified in properties file to get rid of the issue. Else check given DB permissions are correct