{Alibaba PolarDB} Getting Started

 

https://www.alibabacloud.com/help/ja/polardb/getting-started

https://qiita.com/dennis_wang/items/b353b74def6d458389c0

https://www.alibabacloud.com/ja/product/polardb?_p_lc=1


polar.mysql.g2.medium
ノード数=2
0.250ドル/h

 


-- 1. クラスタ作成

aliyun polardb CreateDBCluster \
--DBNodeClass polar.mysql.g2.medium \
--DBType MySQL \
--DBVersion 8.0 \
--PayType Postpaid \
--BackupRetentionPolicyOnClusterDeletion NONE \
--ClusterNetworkType VPC \
--CreationCategory Normal \
--CreationOption Normal \
--DBClusterDescription cluster01 \
--DBMinorVersion 8.0.1 \
--DBNodeNum 2 \
--DefaultTimeZone +9:00 \
--LowerCaseTableNames 1 \
--SecurityIPList "10.1.0.0/16,127.0.0.1/32,192.0.2.1/32" \
--StorageType PSL4 \
--VPCId vpc-111111111111111111111 \
--VSwitchId vsw-111111111111111111111 \
--ZoneId ap-northeast-1a 


aliyun polardb DescribeDBClusters 

aliyun polardb DescribeDBClusterAccessWhitelist \
--DBClusterId pc-11111111111111111 

 


-- 2. 公開用エンドポイント追加

 

aliyun polardb DescribeDBClusterEndpoints \
--DBClusterId pc-11111111111111111 


aliyun polardb CreateDBEndpointAddress \
--DBClusterId pc-11111111111111111 \
--DBEndpointId pe-11111111111111111 \
--NetType Public \
--ConnectionStringPrefix ep123 

 


-- 3. データベースアカウント作成

aliyun polardb CreateAccount \
--DBClusterId pc-11111111111111111 \
--AccountName user01 \
--AccountPassword 'password' \
--AccountDescription user01 \
--AccountType Super 

 


aliyun polardb DescribeAccounts \
--DBClusterId pc-11111111111111111 

 


-- 4. 接続確認

mysql -h ep123.mysql.polardb.japan.rds.aliyuncs.com -u user01 -p

 


-- 5. クリーンアップ


aliyun polardb DescribeAccounts \
--DBClusterId pc-11111111111111111 

aliyun polardb DeleteAccount \
--DBClusterId pc-11111111111111111 \
--AccountName user01 

 


aliyun polardb DescribeDBClusterEndpoints \
--DBClusterId pc-11111111111111111 


aliyun polardb DeleteDBEndpointAddress \
--DBClusterId pc-11111111111111111 \
--DBEndpointId pe-11111111111111111 \
--NetType Public 

 


aliyun polardb DescribeDBClusters 

aliyun polardb DeleteDBCluster \
--DBClusterId pc-11111111111111111 \
--BackupRetentionPolicyOnClusterDeletion NONE 

 

 

 

 

 

 

Squid

 

(22)


https://zenn.dev/zuzuzu/articles/squid_setting


sudo apt update
sudo apt install squid

sudo nl -b a /etc/squid/squid.conf | grep -Pv "^ *?[0-9]+\t *?#|^ *?[0-9]+\t *?$"


# http_access denyの上に追加

sudo vim /etc/squid/squid.conf

acl allowed_ip src 192.168.137.63
http_access allow allowed_ip
http_access deny all

 

sudo systemctl enable squid
sudo systemctl restart squid
sudo systemctl status squid

squidデフォルトポート -> 3128


sudo tail -f /var/log/squid/access.log

 

(12)


apt update
apt install squid

nl -b a /etc/squid/squid.conf | grep -Pv "^ *?[0-9]+\t *?#|^ *?[0-9]+\t *?$"


# http_access denyの上に追加

vim /etc/squid/squid.conf

acl allowed_ip src 192.168.137.63
http_access allow allowed_ip
http_access deny all

 

systemctl enable squid
systemctl restart squid
systemctl status squid

squidデフォルトポート -> 3128


tail -f /var/log/squid/access.log

 

 

(RL9)

https://www.digitalocean.com/community/tutorials/how-to-set-up-squid-proxy-for-private-connections-on-rocky-linux-9

 

dnf install epel-release -y
dnf install squid -y


nl -b a /etc/squid/squid.conf | grep -Pv "^ *?[0-9]+\t *?#|^ *?[0-9]+\t *?$"


# http_access denyの上に追加

vim /etc/squid/squid.conf

acl allowed_ip src 192.168.137.63
http_access allow allowed_ip
http_access deny all

 

systemctl enable squid
systemctl restart squid
systemctl status squid


squidデフォルトポート -> 3128

tail -f /var/log/squid/access.log

 

(2022)

https://4thsight.xyz/37141


タスクトレイのアイコンを右クリックして、メニューから「Open Squid Configuration」を選択します。

# http_access denyの上に追加

acl allowed_ip src 192.168.137.63
http_access allow allowed_ip
http_access deny all

サービス再起動

 

 

{SystemsManager} ハイブリッドおよびマルチクラウド環境に Systems Manager をセットアップする

 

https://docs.aws.amazon.com/ja_jp/systems-manager/latest/userguide/systems-manager-managedinstances.html

https://qiita.com/hyj624117615/items/a6e97e34c222ed0626e0

https://qiita.com/hirosys-biz/items/5e535781433aa9a7caf7


OCIのコンピュートインスタンス(Canonical-Ubuntu-22.04-aarch64-2023.10.13-0) をセッションマネージャーに登録

前提:
OCI側コンピュートインスタンス作成済

 


-- 1. ハイブリッドおよびマルチクラウド環境に IAM サービスロールを作成する


cat <<-'EOF' > a.json
{
   "Version":"2012-10-17",
   "Statement":[
      {
         "Sid":"",
         "Effect":"Allow",
         "Principal":{
            "Service":"ssm.amazonaws.com"
         },
         "Action":"sts:AssumeRole",
         "Condition":{
            "StringEquals":{
               "aws:SourceAccount":"999999999999"
            },
            "ArnEquals":{
               "aws:SourceArn":"arn:aws:ssm:ap-northeast-1:999999999999:*"
            }
         }
      }
   ]
}

EOF


aws iam create-role \
--role-name role01 \
--assume-role-policy-document file://a.json 


aws iam attach-role-policy \
--role-name role01 \
--policy-arn arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore  

 

-- 2. ハイブリッドおよびマルチクラウド環境用のハイブリッドアクティベーションを作成する


aws ssm create-activation \
--default-instance-name instance01 \
--iam-role role01 \
--registration-limit 1 \
--region ap-northeast-1 \
--expiration-date "2024-03-28T00:00:00" 


aws ssm describe-activations 

 

アクティベーションが正常に完了するとすぐに、システムからアクティベーションコードとアクティベーション ID が返ります。

 

-- 3. ハイブリッドおよびマルチクラウド環境 (Linux) に SSM Agent をインストールする

ssh ubuntu@192.0.2.1

mkdir /tmp/ssm

curl https://amazon-ssm-ap-northeast-1.s3.ap-northeast-1.amazonaws.com/latest/debian_arm64/ssm-setup-cli -o /tmp/ssm/ssm-setup-cli

sudo chmod +x /tmp/ssm/ssm-setup-cli

sudo /tmp/ssm/ssm-setup-cli -register -activation-code "11111111111111111111" -activation-id "11111111-1111-1111-1111-111111111111" -region "ap-northeast-1"

 

AWS Systems Manager ->アクティベーション


セッションマネージャーでログイン

※アドバンスドインスタンスの有効化必要

 

-- 4. クリーンアップ

aws ssm describe-activations 

aws ssm delete-activation \
--activation-id 11111111-1111-1111-1111-111111111111 

 


-- ロールの一覧
aws iam list-roles | grep role01

-- ロールの削除

aws iam detach-role-policy \
--role-name role01 \
--policy-arn arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore  


aws iam delete-role --role-name role01


アドバンスドインスタンスの無効化
フリートマネージャーの画面上部にある、「設定」から無効化可能

 

 

 

 

 

{Alibaba Function Compute} Quickly create a function

https://qiita.com/morozumi_h/items/d3f22b79729d1c7ba03f
https://www.bigriver.jp/?p=16889
https://www.bigriver.jp/?p=16912

https://www.alibabacloud.com/help/en/fc/developer-reference/cli-reference
https://www.alibabacloud.com/help/en/functioncompute/latest/quick-function-creation

 


前提: 
画面のメッセージに従い、下記実施済み

1. Function Compute有効化

2. 下記サービスにリンクされたロール作成

ロール名:AliyunServiceRoleForFC
ロール権限:AliyunServiceRolePolicyForFC
ロール種別: サービス連携ロール


3. 「アプリ」を選択して、下記ロールを作成

ロール名:AliyunFcDefaultRole 
ロール権限:AliyunFCDefaultRolePolicy
ロール種別: 一般ロール

 

-- 1. サービスの作成

aliyun fc-open GET /2021-04-06/services 


aliyun fc-open POST /2021-04-06/services \
--body "{\"serviceName\":\"service01\",\"description\":\"service01\"}"

 

-- 2. Create a bucket for code package upload

aliyun oss ls -s

aliyun oss mb oss://bucket123 \
--storage-class Standard \
--redundancy-type LRS \
--acl private 

 

cat <<-'EOF' > test.py
# -*- coding: utf-8 -*-
import json
def handler(event, context):
  print ('hello world');
  return 'OK'

EOF


cat test.py 

zip test.zip test.py


aliyun oss cp test.zip oss://bucket123

aliyun oss ls oss://bucket123 -s

 


-- 3. 関数の作成

aliyun fc-open GET /2021-04-06/services/service01/functions

aliyun fc-open POST /2021-04-06/services/service01/functions \
--body "{\"functionName\": \"func01\",\"runtime\": \"python3\",\"handler\": \"test.handler\",\"code\": {\"ossBucketName\": \"bucket123\",\"ossObjectName\": \"test.zip\"}}"

 


-- 4. 関数の実行

aliyun fc-open POST /2021-04-06/services/service01/functions/func01/invocations

 


-- 5. クリーンアップ


aliyun fc-open GET /2021-04-06/services/service01/functions

aliyun fc-open DELETE /2021-04-06/services/service01/functions/func01


バケットの削除
※最初にバケットを空にする必要がある

aliyun oss rm oss://bucket123 --recursive --force 
aliyun oss ls oss://bucket123 -s

aliyun oss rm oss://bucket123 --bucket --force
aliyun oss ls -s


aliyun fc-open GET /2021-04-06/services 

aliyun fc-open DELETE /2021-04-06/services/service01 

 

 

 

{Alibaba VPC} フローログの作成と管理

https://www.alibabacloud.com/help/ja/vpc/user-guide/create-and-manage-flow-log

https://www.alibabacloud.com/help/en/sls/developer-reference/cli-reference/

https://www.alibabacloud.com/help/ja/sls/user-guide/manage-a-project

 

前提: 
画面のメッセージに従い、下記実施済み

1. 下記ロールを作成
ロール名:AliyunVPCLogArchiveRole 
ロール権限:AliyunVPCLogArchiveRolePolicy
ロール種別: 一般ロール

2. Log Service の有効化

3. FlowLogの有効化

 

-- 1. Install Simple Log Service CLI in macOS

python -m venv venv
source venv/bin/activate

pip3 install -U aliyun-log-cli --no-cache
aliyunlog --version

 

-- 2. Log Service プロジェクトの作成

aliyunlog log list_project 

aliyunlog log create_project \
--project_name=project123 \
--project_des=project123 


-- 3. Logstore の作成


aliyunlog log list_logstore \
--project_name=project123 


aliyunlog log create_logstore \
--project_name=project123 \
--logstore_name=logstore123 

aliyunlog log get_logstore \
--project_name=project123 \
--logstore_name=logstore123 \
--format-output=json

 

 

-- 4. フローログの作成

aliyun vpc DescribeFlowLogs 


aliyun vpc CreateFlowLog \
--ProjectName project123 \
--LogStoreName logstore123 \
--FlowLogName flowlog01 \
--ResourceType VPC \
--ResourceId vpc-111111111111111111111 \
--TrafficType All \
--AggregationInterval 1 

 


-- 5. 動作確認

フローログの画面からLogstoreを選択する
有効化ボタンを押下する

 

-- 6. クリーンアップ

aliyun vpc DescribeFlowLogs 

aliyun vpc DeleteFlowLog \
--FlowLogId fl-111111111111111111111 


aliyunlog log list_logstore \
--project_name=project123 

aliyunlog log delete_logstore \
--project_name=project123 \
--logstore_name=logstore123 


aliyunlog log list_project 

aliyunlog log delete_project \
--project_name=project123