SQL Declare Variable

คำสั่ง SET

เป็นการให้ค่าจาก SQL ด้วยคำสั่ง SET แล้วก็อ่านค่าด้วย SQL

%sql
SET value = 2;
%sql
SELECT ${hiveconf:value} 
%sql
SELECT ${hiveconf:value} AS value
%sql
SET LastChangeDate = current_date()
%sql
Select ${hiveconf:LastChangeDate}

คำสั่ง spark.conf.set()

เป็นการให้ค่าจาก Python ด้วยคำสั่ง spark.conf.set() แล้วอ่านค่าด้วย SQL

%python 
spark.conf.set("ab.name", "jack") 
spark.conf.set("AB.name", "jack") 

จะสังเกตุเห็นได้ว่าที่ Python ให้ค่าทั้ง ab และ AB เพื่อให้ SQL อ่านค่าได้ทั้ง ab และ AB

%sql
SELECT '${AB.name}' AS name

Databricks extension for Visual Studio Code

Before you begin

Before you can use the Databricks extension for Visual Studio Code, your Databricks workspace and your local development machine must meet the following requirements. You must also have an access token to authenticate with Databricks.

  • Workspace requirements
  • Access token
  • Local development machine requirements

Workspace requirements

enable Files in Repos

คอนฟิกไฟล์ %USERPROFILE%\.databrickscfg เช่น C:\Users\jack\.databrickscfg

[DEFAULT]
host = https://dbc-xxx2345c-yyyy.cloud.databricks.com
token = dapi1234567xxx123456yyyy123456789012

[DEV]
host = https://dbc-xxx3456d-yyyy.cloud.databricks.com
token = dapi2345678xxx234567yyyy234567890123

Access token

You must have a Databricks personal access token. If you do not have one available, you can generate a personal access token now.

Local development machine requirements

Visual Studio Code version 1.69.1 or higher.

ติดตั้ง Extension

ทดสอบ

from pyspark.sql import SparkSession

spark: SparkSession = spark
print("Hello from Databricks")

Basic SQL

  1. แสดงรายชื่อดาต้าเบส และตาราง
  2. ใช้ SQL อ่านไฟล์
  3. อ่านข้อมูลในไฟล์ CSV มาใส่ใน Delta Table
  4. อ่านข้อมูลในไฟล์ CSV มาสร้าง Temp View
  5. สร้าง external table โดยชี้ไปที่ไฟล์ CSV
  6. คำสั่ง CREATE VIEW
  7. คำสั่ง CREATE TABLE

แสดงรายชื่อดาต้าเบส และตาราง

แสดงรายชื่อดาต้าเบส

%sql
SHOW DATABASES;

แสดงรายชื่อตารางในดาต้าเบส

%sql
USE default;
SHOW TABLES;

ใช้ SQL อ่านไฟล์

%sql
SELECT * FROM delta.`${DA.paths.datasets}/nyctaxi-with-zipcodes/data`
SELECT * FROM text.`dbfs:/databricks-datasets/Rdatasets/data-001/datasets.csv`
SELECT * FROM csv.`dbfs:/databricks-datasets/Rdatasets/data-001/datasets.csv`

ใช้ SQL อ่านไฟล์แบบ text

ใช้ backtick ` ครอบ

%sql
SELECT * FROM text.`dbfs:/databricks-datasets/Rdatasets/data-001/datasets.csv`

ใช้ SQL อ่านไฟล์แบบ CSV

%sql
SELECT * FROM csv.`dbfs:/databricks-datasets/Rdatasets/data-001/datasets.csv`

อ่านข้อมูลในไฟล์ CSV มาใส่ใน Delta Table

สร้างตารางชื่อ table1 โดยดูชื่อคอลัมน์จากคิวรีด้านบน

%sql
/*Table creation with schema*/
CREATE OR REPLACE TABLE table1 (
  Package string,
  Item string,
  Title string,
  csv string,
  doc string
);

SHOW TABLE อีกทีจะเห็นตาราง table1

ลอง SHOW CREATE TABLE

%sql
SHOW CREATE TABLE table1;

copy ข้อมูลจากไฟล์ csv ลงตาราง

%sql
/*Copying dbfs csv data into table*/
COPY INTO table1
  FROM "dbfs:/databricks-datasets/Rdatasets/data-001/datasets.csv"
  FILEFORMAT = csv
  FORMAT_OPTIONS('header'='true','inferSchema'='True');

คิวรีดูข้อมูล

%sql
SELECT * FROM table1

อ่านข้อมูลในไฟล์ CSV มาสร้าง Temp View

%sql
CREATE TEMPORARY VIEW view1 USING CSV OPTIONS (
  path "/databricks-datasets/Rdatasets/data-001/datasets.csv",
  header "true"
)
%sql
CREATE TEMPORARY VIEW diamonds USING CSV OPTIONS (
  path "/databricks-datasets/Rdatasets/data-001/csv/ggplot2/diamonds.csv",
  header "true"
)

ลอง SHOW TABLES จะเห็นว่าเป็น Temporary

สร้าง external table โดยชี้ไปที่ไฟล์ CSV

%sql
CREATE TABLE table2 USING CSV 
OPTIONS ('header' = 'true')
LOCATION '/databricks-datasets/Rdatasets/data-001/csv/ggplot2/diamonds.csv'

พาทไฟล์สามารถ กำหนดที่ LOCATION หรือใน OPTIONS (path) ก็ได้

%sql
DROP TABLE IF EXISTS diamonds;

CREATE TABLE diamonds USING CSV OPTIONS (
  path "/databricks-datasets/Rdatasets/data-001/csv/ggplot2/diamonds.csv",
  header "true"
)

ใน OPTIONS เครื่องหมาย = จะมีหรือไม่มีก็ได้

%sql
DROP TABLE IF EXISTS diamonds;

CREATE TABLE diamonds USING CSV OPTIONS (
  path = "/databricks-datasets/Rdatasets/data-001/csv/ggplot2/diamonds.csv",
  header = "true"
)

คำสั่ง CREATE VIEW

CREATE OR REPLACE TEMP VIEW demo_tmp_vw(name, value) AS VALUES
  ("Yi", 1),
  ("Ali", 2),
  ("Selina", 3);

CREATE TEMPORARY VIEW diamonds USING CSV OPTIONS (
  path "/databricks-datasets/Rdatasets/data-001/csv/ggplot2/diamonds.csv",
  header "true"
);

คำสั่ง CREATE TABLE

CREATE OR REPLACE TABLE table1 (
  Package string,
  Item string,
  Title string,
  csv string,
  doc string
);

CREATE TABLE diamonds USING CSV OPTIONS (
  path = "/databricks-datasets/Rdatasets/data-001/csv/ggplot2/diamonds.csv",
  header = "true"
);

CREATE TABLE diamonds USING CSV 
OPTIONS ('header' = 'true')
LOCATION '/databricks-datasets/Rdatasets/data-001/csv/ggplot2/diamonds.csv';

Self-Signed SSL Certificate for Apache in Ubuntu 20.04

ติดตั้ง Apache

sudo apt update
sudo apt install apache2

Enabling mod_ssl

Before we can use any SSL certificates, we first have to enable mod_ssl, an Apache module that provides support for SSL encryption.

Enable mod_ssl with the a2enmod command:

$ sudo a2enmod ssl
[sudo] password for jack:
Considering dependency setenvif for ssl:
Module setenvif already enabled
Considering dependency mime for ssl:
Module mime already enabled
Considering dependency socache_shmcb for ssl:
Enabling module socache_shmcb.
Enabling module ssl.
See /usr/share/doc/apache2/README.Debian.gz on how to configure SSL and create self-signed certificates.
To activate the new configuration, you need to run:
  systemctl restart apache2

Restart Apache to activate the module:

sudo systemctl restart apache2

Creating the SSL Certificate

Now that Apache is ready to use encryption, we can move on to generating a new SSL certificate. The certificate will store some basic information about your site, and will be accompanied by a key file that allows the server to securely handle encrypted data.

We can create the SSL key and certificate files with the openssl command:

sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
     -keyout /etc/ssl/private/apache-selfsigned.key \
     -out /etc/ssl/certs/apache-selfsigned.crt

private key ที่ได้จะอยู่ที่ /etc/ssl/private/apache-selfsigned.key

Configuring Apache to Use SSL

ที่ไฟล์ 000-default.conf เพิ่ม VirtualHost *:443

$ sudo nano /etc/apache2/sites-available/000-default.conf
<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

<VirtualHost *:443>
   DocumentRoot /var/www/html

   SSLEngine on
   SSLCertificateFile /etc/ssl/certs/apache-selfsigned.crt
   SSLCertificateKeyFile /etc/ssl/private/apache-selfsigned.key
</VirtualHost>

Next, let’s test for configuration errors:

sudo apache2ctl configtest

Let reload apache2

sudo systemctl reload apache2

ทดลองเรียกไปที่ https://localhost

Redirecting HTTP to HTTPS

$ sudo nano /etc/apache2/sites-available/000-default.conf

To use Redirect to match any requests and send them to the SSL VirtualHost. Make sure to include the trailing slash:

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        Redirect / https://jack5.com/

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

<VirtualHost *:443>
   DocumentRoot /var/www/html

   SSLEngine on
   SSLCertificateFile /etc/ssl/certs/apache-selfsigned.crt
   SSLCertificateKeyFile /etc/ssl/private/apache-selfsigned.key
</VirtualHost>

ตอนนี้พอเรียกไปที่ http://localhost ก็จะ redirect ไปที่ https://localhost ละ

Install Mautic on Ubuntu 20.04

ก่อนติดตั้ง Mautic ต้องมี

  • Apache2
  • Mysql

Step 1: Download Mautic onto Your Ubuntu 20.04 Server

ดู release ของ Mautic ที่ github.com/mautic/mautic/releases/

Download the latest stable version by executing the following command on your server.

wget https://github.com/mautic/mautic/releases/download/4.2.1/4.2.1-update.zip
wget https://github.com/mautic/mautic/releases/download/4.4.7/4.4.7-update.zip

Install the unzip utility and unzip it to /var/www/mautic/ directory.

sudo apt install unzip

sudo mkdir -p /var/www/mautic/

sudo unzip 4.4.7-update.zip -d /var/www/mautic/

Then make the web server user (www-data) as the owner of this directory.

sudo chown -R www-data:www-data /var/www/mautic/

Step 2: Create a MariaDB Database and User for Mautic

Log in to MariaDB console.

sudo mysql

Next, create a new database for Mautic using the following command. This tutorial names it mautic, you can use whatever name you like for the database.

CREATE DATABASE mautic DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

จะมี warning ประมาณนี้

CREATE DATABASE mautic DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci	1 row(s) affected, 2 warning(s):
 3719 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
 3778 'utf8mb3_unicode_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.

ให้เปลี่ยนเป็นใช้คำสั่งนี้แทน

CREATE DATABASE mautic DEFAULT CHARACTER SET UTF8MB4 COLLATE utf8mb4_unicode_ci;

The following command will create a database user and password, and at the same time grant all permission of the new database to the new user so later on Mautic can write to the database. Replace red texts with your preferred database name, username and password.

CREATE USER 'jack'@'localhost' IDENTIFIED BY 'password';
GRANT ALL ON mautic.* TO 'jack'@'localhost' IDENTIFIED BY 'password';

Flush privileges table and exit MariaDB console.

FLUSH PRIVILEGES;

EXIT;

Step 3: Install Required and Recommended PHP Modules.

Run the following command to install PHP modules required or recommended by Mautic

sudo apt install php-imagick php7.4-fpm php7.4-mysql php7.4-common php7.4-gd php7.4-imap php7.4-imap php7.4-json php7.4-curl php7.4-zip php7.4-xml php7.4-mbstring php7.4-bz2 php7.4-intl php7.4-gmp

เราใช้ PHP-FPM แทน PHP – PHP: FastCGI Process Manager (FPM) – Manual

If you use Apache web server, then you need to disable the PHP module for Apache.

sudo a2dismod php7.4

You also need to disable the prefork MPM module in Apache.

sudo a2dismod mpm_prefork

Now you need to run the following command to enable three modules in order to use PHP-FPM in Apache, regardless of whether mod_php is installed on your server.

sudo a2enmod mpm_event proxy_fcgi setenvif

Then restart Apache.

sudo systemctl restart apache2

Step 4: Create Apache Virtual Host for Mautic

If you use Apache web server, create a virtual host for Mautic.

sudo nano /etc/apache2/sites-available/mautic.conf

Put the following text into the file. Replace mautic.example.com with your real domain name and don’t forget to set DNS A record for it.

<VirtualHost *:80>
  ServerName mautic.example.com
  DocumentRoot /var/www/mautic/

  ErrorLog ${APACHE_LOG_DIR}/error.log
  CustomLog ${APACHE_LOG_DIR}/access.log combined

  <Directory />
    Options FollowSymLinks
    AllowOverride All
  </Directory>

  <Directory /var/www/mautic/>
    Options FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
  </Directory>

</VirtualHost>

Save and close the file. Then enable this virtual host with:

sudo a2ensite mautic.conf

enable PHP-FPM – How to Install PHP-FPM with Apache on Ubuntu 20.04 (cloudbooklet.com)

sudo a2enconf php7.4-fpm

สามารถทดสอบ PHP-FPM ได้ด้วย

<?php phpinfo(); ?>

Reload Apache for the changes to take effect.

sudo systemctl reload apache2

แก้ไฟล์ /etc/hosts

sudo nano /etc/hosts
127.0.0.1       localhost
127.0.1.1       jack5.com       jack5
192.168.1.142   mautic.example.com

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

ถ้าจะเรียกจาก Windows ให้แก้ไขไฟล์ C:\Windows\System32\drivers\etc\hosts

192.168.1.142        jack5.com
192.168.1.142        mautic.example.com

Now you should be able to see the Mautic web-based install wizard at http://mautic.example.com/installer.

แก้ไขไฟล์ php.ini ของ fpm ที่ /etc/php/7.4/fpm/php.ini
(ของ php ที่ /etc/php/7.4/apache2/php.ini ไม่ต้องแก้)

$ sudo nano /etc/php/7.4/fpm/php.ini
date.timezone = Asia/Bangkok
...
memory_limit = 512M

เสร็จแล้ว reload php7.4-fpm

sudo systemctl reload php7.4-fpm

Step 5: Enabling HTTPS

sudo a2enmod ssl
sudo systemctl restart apache2
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/apache-selfsigned.key -out /etc/ssl/certs/apache-selfsigned.crt
sudo nano /etc/apache2/sites-available/mautic.conf
<VirtualHost *:443>
  ServerName mautic.example.com
  DocumentRoot /var/www/mautic/

  ErrorLog ${APACHE_LOG_DIR}/error.log
  CustomLog ${APACHE_LOG_DIR}/access.log combined

  SSLEngine on
  SSLCertificateFile /etc/ssl/certs/apache-selfsigned.crt
  SSLCertificateKeyFile /etc/ssl/private/apache-selfsigned.key

  <Directory />
    Options FollowSymLinks
    AllowOverride All
  </Directory>

  <Directory /var/www/mautic/>
    Options FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
  </Directory>

</VirtualHost>

<VirtualHost *:80>
   ServerName mautic.example.com
   Redirect / https://mautic.example.com
</VirtualHost>
sudo a2ensite mautic.conf
sudo apache2ctl configtest
sudo systemctl reload apache2

Step 6: Finish Mautic Installation in Web Browser

  1. ใส่ข้อมูลดาต้าเบส
  2. ใส่ข้อมูล admin
  3. ใส่ข้อมูล SMTP Server , เราใช้ sendgrid.com แบบ API Key

ติดตั้ง เสร็จแล้ว login ไม่ได้ ฟ้องว่า

Unable to resolve binding type, invalid or unsupported http request

ให้แก้ไขด้วยคำสั่ง – Mautic 3. Can not login for first time – Support / Mautic 3 – Install/Upgrade Support – Mautic Community Forums

sudo a2enmod rewrite
sudo systemctl reload apache2

เมื่อ login สำเร็จจะได้หน้านี้

ติดตั้ง MySQL บน Ubuntu 20.04

ติดตั้ง MySQL

sudo apt update
sudo apt install mysql-server

ตรวจสอบสถานะ

systemctl status mysql

ลองใช้งาน

$ sudo mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.32-0ubuntu0.20.04.2 (Ubuntu)

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

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>

สร้าง user

CREATE USER 'jack'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON * . * TO 'jack'@'localhost';
FLUSH PRIVILEGES;
SELECT user,authentication_string,plugin,host FROM mysql.user;

ทดสอบที่ local จะเข้าได้ละ

$ sudo mysql -u jack  -p

เข้าจากเครื่องอื่น

1 Access mysqld.cnf File

sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf

2 Change Bind-Address IP

You now have access to the MySQL server configuration file. Scroll down to the bind-address line and change the IP address. The current default IP is set to 127.0.0.1. This IP limits MySQL connections to the local machine.

The new IP should match the address of the machine that needs to access the MySQL server remotely. For example, if you bind MySQL to 0.0.0.0, then any machine that reaches the MySQL server can also connect with it.

bind-address            = 0.0.0.0
sudo systemctl restart mysql

สร้าง remote user โดย remote ไปจากเครื่อง 192.168.1.124

CREATE USER 'jack'@'192.168.1.124' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON * . * TO 'jack'@'192.168.1.124';
FLUSH PRIVILEGES;

Apache Virtual Hosts on Ubuntu 20.04

Step 1 — Creating the Directory Structure

sudo mkdir -p /var/www/your_domain_1/public_html
sudo mkdir -p /var/www/your_domain_2/public_html

Step 2 — Granting Permissions

sudo chown -R $USER:$USER /var/www/your_domain_1/public_html
sudo chown -R $USER:$USER /var/www/your_domain_2/public_html

หรือ

sudo chown -R www-data:www-data your_domain_1/public_html
sudo chown -R www-data:www-data your_domain_2/public_html
sudo chmod -R 755 /var/www

Step 3 — Creating Default Pages for Each Virtual Host

nano /var/www/your_domain_1/public_html/index.html
<html>
  <head>
    <title>Welcome to your_domain_1!</title>
  </head>
  <body>
    <h1>Success! The your_domain_1 virtual host is working!</h1>
  </body>
</html>
nano /var/www/your_domain_2/public_html/index.html
<html>
  <head>
    <title>Welcome to your_domain_2!</title>
  </head>
  <body>
    <h1>Success! The your_domain_2 virtual host is working!</h1>
  </body>
</html>

Step 4 — Creating New Virtual Host Files

sudo nano /etc/apache2/sites-available/your_domain_1.conf
<VirtualHost *:80>
        ServerAdmin admin@your_domain_1
        ServerName your_domain_1
        ServerAlias www.your_domain_1
        DocumentRoot /var/www/your_domain_1/public_html

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
sudo nano /etc/apache2/sites-available/your_domain_2.conf
<VirtualHost *:80>
        ServerAdmin admin@your_domain_2
        ServerName your_domain_2
        ServerAlias www.your_domain_2
        DocumentRoot /var/www/your_domain_2/public_html

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Step 5 — Enabling the New Virtual Host Files

sudo a2ensite your_domain_1.conf
sudo a2ensite your_domain_2.conf
sudo apache2ctl configtest
sudo systemctl restart apache2
sudo systemctl status apache2

Step 6 — (Optional) Setting Up Local Hosts File

sudo nano /etc/hosts
%windir%\system32\drivers\etc\hosts
127.0.0.1   localhost
127.0.1.1   guest-desktop
your_server_IP your_domain_1
your_server_IP your_domain_2

Step 7 — Testing Your Results

http://your_domain_1
http://your_domain_2

Hostname (computer name) ของ Ubuntu 20.04

ดู Hostname

ดู Hostname ด้วยคำสั่ง hostname

$ hostname
jack5

ดู Hostname ด้วยคำสั่ง hostnamectl

$ hostnamectl
   Static hostname: jack5
         Icon name: computer-vm
           Chassis: vm
        Machine ID: d38e601ed3104707bc3b33c7058533e0
           Boot ID: afa54862c8be4726a7b75fc1e24ec4d1
    Virtualization: oracle
  Operating System: Ubuntu 20.04.6 LTS
            Kernel: Linux 5.15.0-67-generic
      Architecture: x86-64

ดู Hostname ที่ไฟล์ /etc/hostname

$ cat /etc/hostname
jack5

ดู Hostname ที่ไฟล์ /etc/hosts

$ cat /etc/hosts
127.0.0.1       localhost
127.0.1.1       jack5.com       jack5

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

ลอง ping jack5 จะได้ IP 127.0.1.1

$ ping jack5
PING jack5.com (127.0.1.1) 56(84) bytes of data.
64 bytes from jack5.com (127.0.1.1): icmp_seq=1 ttl=64 time=0.018 ms
64 bytes from jack5.com (127.0.1.1): icmp_seq=2 ttl=64 time=0.028 ms
64 bytes from jack5.com (127.0.1.1): icmp_seq=3 ttl=64 time=0.031 ms
$ ping jack5.com
PING jack5.com (127.0.1.1) 56(84) bytes of data.
64 bytes from jack5.com (127.0.1.1): icmp_seq=1 ttl=64 time=0.019 ms
64 bytes from jack5.com (127.0.1.1): icmp_seq=2 ttl=64 time=0.027 ms
64 bytes from jack5.com (127.0.1.1): icmp_seq=3 ttl=64 time=0.027 ms

ลอง ping localhost จะได้ IP 127.0.0.1

$ ping localhost
PING localhost (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.587 ms
64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.025 ms
64 bytes from localhost (127.0.0.1): icmp_seq=3 ttl=64 time=0.025 ms

เปลี่ยน Hostname

แก้ไขไฟล์ /etc/hostname และไฟล์ /etc/hosts

sudo nano /etc/hostname
sudo nano /etc/hosts

reboot เครื่อง

sudo reboot

ติดตั้ง VirtualBox 7.0 บน Windows 11

ถ้าติดตั้ง VirtualBox 7.0 เลย อาจเจอปัญหา “Missing Dependencies Python Core / win32api”

วิธีแก้ไข “Missing Dependencies Python Core / win32api” ให้ทำดังนี้ – Fix “Python win32api” in VirtualBox – SYSNETTECH Solutions

อัพเดท pip

python.exe -m pip install --upgrade pip

เปิด Command Prompt หรือ PowerShell ด้วยสิทธิ Administrator แล้ว install pywin32

py -m pip install pywin32

ติดตั้ง VirtualBox 7.0 ด้วยสิทธิ Administrator ก็จะได้ละ – How to Install VirtualBox 7.0 – SYSNETTECH Solutions

ตอนสร้าง Guest เลือก

  • เลือก Skip Unattended Installation
  • เลือก Enable EFI

command hostname

ดูชื่อเครื่องด้วย hostname

$ hostname

ดู help

$ hostname --help
Usage: hostname [-b] {hostname|-F file}         set host name (from file)
       hostname [-a|-A|-d|-f|-i|-I|-s|-y]       display formatted name
       hostname                                 display host name

       {yp,nis,}domainname {nisdomain|-F file}  set NIS domain name (from file)
       {yp,nis,}domainname                      display NIS domain name

       dnsdomainname                            display dns domain name

       hostname -V|--version|-h|--help          print info and exit

Program name:
       {yp,nis,}domainname=hostname -y
       dnsdomainname=hostname -d

Program options:
    -a, --alias            alias names
    -A, --all-fqdns        all long host names (FQDNs)
    -b, --boot             set default hostname if none available
    -d, --domain           DNS domain name
    -f, --fqdn, --long     long host name (FQDN)
    -F, --file             read host name or NIS domain name from given file
    -i, --ip-address       addresses for the host name
    -I, --all-ip-addresses all addresses for the host
    -s, --short            short host name
    -y, --yp, --nis        NIS/YP domain name

Description:
   This command can get or set the host name or the NIS domain name. You can
   also get the DNS domain or the FQDN (fully qualified domain name).
   Unless you are using bind or NIS for host lookups you can change the
   FQDN (Fully Qualified Domain Name) and the DNS domain name (which is
   part of the FQDN) in the /etc/hosts file.

set hostname เป็น example.org

$ sudo hostname example.org
$ hostname
example.org

ดู IP ของเครื่องด้วย hostname -I

$ hostname -I
10.0.2.15 192.168.1.142