2021年6月18日 星期五

How to increase root disk of Google Compute Engine ?

 Resize the persistent disk in the Google Cloud Platform Console:

  1. Go to the Compute Engine page.
  2. Click on "Disks" in the sidebar
  3. Click the name of the disk that you want to resize.
  4. At the top of the disk details page, click "Edit".
  5. In the "Size" field, enter the new size for your disk.
  6. At the bottom of the disk details page, click "Save" to apply your changes to the disk.
  7. After you resize the disk, you must resize the disk partitions so that the operating system can access the additional space.

 Then, on Debian/Ubuntu/etc. run:

$ sudo apt install -y cloud-utils         # Debian jessie
$ sudo apt install -y cloud-guest-utils   # Debian stretch, Ubuntu
$ sudo growpart /dev/sda 1
$ sudo resize2fs /dev/sda1

or, for RedHat/Fedora/CentOS/etc.:

$ sudo dnf install -y cloud-utils-growpart
$ sudo growpart /dev/sda 1
$ sudo xfs_growfs -d / 

Refer from https://stackoverflow.com/questions/22381686/how-can-size-of-the-root-disk-in-google-compute-engine-be-increased

2020年11月23日 星期一

Browser 3D顯示解決方案研究

 1. 360立體化顯示

使用jquery & jquery reel套件

EX. http://test.vostrel.net/jquery.reel/example/index.html

http://reel360.org/reel

http://jquery.vostrel.cz/reel

http://spritespin.ginie.eu/


2. GLTF display 參考資料

https://threejsfundamentals.org/threejs/lessons/threejs-fundamentals.html

https://threejsfundamentals.org/threejs/lessons/threejs-load-gltf.html

https://gltf-viewer.donmccurdy.com/

https://codepen.io/pen/?&editable=true&editors=101=https%3A%2F%2Fthreejsfundamentals.org%2Fthreejs%2Flessons%2Fthreejs-load-gltf.html

https://creazilla.com/sections/3-3d-models/tags/649-gltf

How to install linkchecker 9.x later

 pip install https://github.com/linkchecker/linkchecker/archive/master.zip#egg=linkchecker



2020年11月10日 星期二

GCP mysql import/export procedure

 Export:

1. export from GCP mysql

mysqldump -u user -p database [tables] > ddd.sql

2. export entire database

mysqldump -u user -p database --column-statistics=0 --triggers --routines > data.sql


Import:

1. edit export file and remove following lines

SET @@SESSION.SQL_LOG_BIN= 0;

SET @@GLOBAL.GTID_PURGED=/*!80000 '+'*/ '';

SET @@SESSION.SQL_LOG_BIN = @MYSQLDUMP_TEMP_LOG_BIN;


2. mysql -u user -p database < data.sql

2020年11月6日 星期五

Get country code from ip

 如何從由IP位址找到國家,網路上有許多網站提供服務,但幾乎都是付費網站,若是免費服務也大都有數量限制..目前搜集到的網站如下

https://api.ip2country.info/ip?<ip>

http://ip-api.com/json/<ip>

https://extreme-ip-lookup.com/json/<ip>

https://ipapi.co/<ip>/json/

https://ip.nf/<ip>.json

https://api.ipdata.co<ip>?api-key=test

https://ipwhois.app/json/<ip>

以上網站都不需要註刪,且提供一定數量免費查詢的付費網站。

另外python module也有許多模組,但大都是付費網站所提供的功能..我選用了geoip2,因為整合到pyton程式較方便。整合方式如下:

1. install geoip2

    pip install geoip2

2. download database

    到https://ftp.openbsd.org/pub/OpenBSD/distfiles/下載最新的dbip-country & dbip-city的mmdb檔案,我下載的檔案為dbip-city-lite-2020-11.mmdb.gz & dbip-country-lite-2020-11.mmdb.gz

3. 將資料庫解壓縮到data目錄

4. python程式如下:

import os,sys

import geoip2.database


ip = sys.argv[1]

rtn = {"countryCode":"", "country":""}

with geoip2.database.Reader('data/dbip-country-lite.mmdb') as reader:

    try:

        response = reader.country(ip)

        rtn['countryCode'] = response.country.iso_code

        rtn['country'] = response.country.name

    except:

        pass

print(rtn)

2019年12月24日 星期二

Initializing shm:/var/xxxxxxx errno=13. Unable to start due to shared memory failure


You can generate a local policy module to allow this access. Do allow this access for now by executing:
# grep httpd /var/log/audit/audit.log | audit2allow -M mypol
# semodule -i mypol.pp

2019年12月18日 星期三

Apache proxy not working for a localhost port

ProxyPass / http://localhost:8983/
ProxyPassReverse / http://localhost:8983/
Above setting does not work.
To turn on this boolean you simple have to use this line (root permissions)
setsebool -P httpd_can_network_connect on