DevOps Classroomnotes 30/Sep/2023

Observability for a .net core application

  • Ensure you have elastic cloud account
  • Application architecture

Database setup

sudo apt update
sudo apt install mysql-server -y
  • Change the mysql bind address to 0.0.0.0
sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf


* Now reload the daemon and restart mysql

sudo systemctl daemon-reload
sudo systemctl restart mysql.service
sudo systemctl status mysql.service
  • login into mysql shell
sudo mysql
  • Now create a user and grant permissions to the user on all databases in this server
CREATE USER 'nop'@'%' IDENTIFIED BY 'nop12345';
GRANT ALL PRIVILEGES ON * . * TO 'nop'@'%';
FLUSH PRIVILEGES;

Application server setup

  • Refer Here for documentation
  • Install .net core 7
cd /tmp
wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get update
sudo apt-get install -y apt-transport-https aspnetcore-runtime-7.0
  • Install nginx
sudo apt install nginx -y
  • Use nginx as reverse proxy to forward the connections to 5000 port. replace the contents of /etc/nginx/sites-available/default with the below content
# Default server configuration
#
server {
    listen 80 default_server;
    listen [::]:80 default_server;

    server_name   nopCommerce.com;

    location / {
    proxy_pass         http://localhost:5000;
    proxy_http_version 1.1;
    proxy_set_header   Upgrade $http_upgrade;
    proxy_set_header   Connection keep-alive;
    proxy_set_header   Host $host;
    proxy_cache_bypass $http_upgrade;
    proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header   X-Forwarded-Proto $scheme;
    }

    # SSL configuration
    #
    # listen 443 ssl default_server;
    # listen [::]:443 ssl default_server;
    #
    # Note: You should disable gzip for SSL traffic.
    # See: https://bugs.debian.org/773332
    #
    # Read up on ssl_ciphers to ensure a secure configuration.
    # See: https://bugs.debian.org/765782
    #
    # Self signed certs generated by the ssl-cert package
    # Don't use them in a production server!
    #
    # include snippets/snakeoil.conf;
}
  • Now reload daemon and restart nginx
sudo systemctl daemon-reload
sudo systemctl restart nginx.service

Install nop

  • Install nop into app server
sudo -i
mkdir /var/www/nopCommerce
cd /var/www/nopCommerce
sudo wget https://github.com/nopSolutions/nopCommerce/releases/download/release-4.60.4/nopCommerce_4.60.4_NoSource_linux_x64.zip
sudo apt-get install unzip -y
sudo unzip nopCommerce_4.60.4_NoSource_linux_x64.zip
sudo mkdir bin
sudo mkdir logs
cd ..
sudo chgrp -R www-data nopCommerce/
sudo chown -R www-data nopCommerce/
  • Create a service file for nopcommerce in this path /etc/systemd/system/nopCommerce.service
[Unit]
Description=Example nopCommerce app running on Xubuntu

[Service]
WorkingDirectory=/var/www/nopCommerce
ExecStart=/usr/bin/dotnet /var/www/nopCommerce/Nop.Web.dll
Restart=always
# Restart service after 10 seconds if the dotnet service crashes:
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=nopCommerce-example
User=www-data
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false

[Install]
WantedBy=multi-user.target
  • Now start and enable the nopCommerce.servic
sudo systemctl enable nopCommerce.service
sudo systemctl start nopCommerce.service

Lets setup observability

For mysql

  • Integrate mysql in elastic cloud
  • refer classroom videos
Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a comment

Turn on JavaScript to leave a comment.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Social Network Integration by Acurax Social Media Branding Company
Exit mobile version
%%footer%%