changeset 117:2bc31d4e86ec

backup 2023-04-19
author autobackup
date Wed, 19 Apr 2023 15:07:28 +0900
parents 92172df8e59a
children 0bdc092c40c5
files trash/user/matac42/note/2023/04/08.md user/Moririn.md user/matac42/note/2023/04/08.md user/matac42/notes/2023/04/10.md user/mizuki/メモ/2023-04-10.md user/nana.md
diffstat 6 files changed, 554 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/trash/user/matac42/note/2023/04/08.md	Wed Apr 19 15:07:28 2023 +0900
@@ -0,0 +1,1 @@
+## test
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/user/Moririn.md	Wed Apr 19 15:07:28 2023 +0900
@@ -0,0 +1,2 @@
+# Moririn
+moririnです
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/user/matac42/note/2023/04/08.md	Wed Apr 19 15:07:28 2023 +0900
@@ -0,0 +1,1 @@
+redirect /trash/user/matac42/note/2023/04/08
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/user/matac42/notes/2023/04/10.md	Wed Apr 19 15:07:28 2023 +0900
@@ -0,0 +1,479 @@
+## 研究目的
+
+### Gears OSのファイルシステムとDB
+
+本研究室では信頼性の保証と拡張性を目的としたGearsOSを開発している。
+OSにおいてファイルシステムは重要な機能の一つであるため実装する必要がある。
+現在、一般的なアプリケーションはファイルシステムとデータベースを併用する形で構成される。
+DBはSQLによってデータの挿入や変更が可能だがスキーマを事前に定義したり、
+insert時にそれらのschemaを指定したりする必要がある。
+Gears OSのファイルシステムではSQLの機能に相当するgrepやfindなどのインターフェースを実装し、
+アプリケーションのデータベースとしてファイルシステムを使用する構成が取れるようにしたい。
+ファイルシステムとデータベースの違いについて考え、データベースとしても利用可能なファイルシステムを構築したい。
+本研究では、ファイルシステムとデータベースの違いについて考察し、Gears OSのファイルシステムの設計について述べる。
+
+## 進捗
+
+### 論文リポジトリを作った
+
+http://www.cr.ie.u-ryukyu.ac.jp/hg/Papers/2023/matac-sigos/
+
+### Growiを移行した
+
+見たいページがあったが,外からアクセスできなかったので修正した.
+また,amaneのVMからdalmoreのpodmanに移行した.
+
+https://growi.cr.ie.u-ryukyu.ac.jp/
+
+### Mindmapを書いた
+
+![gearsos_db.jpg](/attachment/6433d44de450d700423f22e5)
+
+### MySQLの`alter table`
+
+カラムの変更は`alter table`を使用する.
+`begin;`してカラム名を変更して`rollback`してもカラム名は元に戻らない.
+
+なぜならば`alter table`時にimplicit commitをしているから.implicit commitしなかった場合,他のセッションと不整合を起こす場合がある.
+
+```
+mysql> select * from user;
++-------------+------+
+| user_name_1 | age  |
++-------------+------+
+| hoge        |   10 |
++-------------+------+
+1 row in set (0.00 sec)
+
+mysql> begin;
+Query OK, 0 rows affected (0.00 sec)
+
+mysql> alter table user rename column user_name_1 to user_name_2;
+Query OK, 0 rows affected (0.02 sec)
+Records: 0  Duplicates: 0  Warnings: 0
+
+mysql> select * from user;
++-------------+------+
+| user_name_2 | age  |
++-------------+------+
+| hoge        |   10 |
++-------------+------+
+1 row in set (0.00 sec)
+
+mysql> rollback;
+Query OK, 0 rows affected (0.00 sec)
+
+mysql> select * from user;
++-------------+------+
+| user_name_2 | age  |
++-------------+------+
+| hoge        |   10 |
++-------------+------+
+1 row in set (0.00 sec)
+
+mysql>
+```
+
+### schemaが無いDB
+
+- schemaを定義したり変更したりといった,テーブルに対する破壊的な操作が無くなる.
+- DBを利用するアプリケーション側はschemaが無い前提で構築する必要がある.
+- SQLとは別のインターフェースを使用する(grep, find).
+- indexはinodeのTreeを使用する.
+
+#### find grep
+
+- 従来のfind,grepコマンドでは,データを特定しきれない場合がある.
+    - schemalessはデータが正規形になっていないため.
+- 正規化する必要がある?ただし,schemaは使用しない.
+
+### おまけ
+
+#### ChatGPTにRedBlackTreeをCで書いてもらった
+
+```c
+#include <stdio.h>
+#include <stdlib.h>
+
+/* 色定数 */
+#define RED 0
+#define BLACK 1
+
+/* Red-Black Treeのノード構造体 */
+typedef struct node {
+    int key;             /* キー */
+    int color;           /* 色 */
+    struct node *parent; /* 親ノード */
+    struct node *left;   /* 左の子ノード */
+    struct node *right;  /* 右の子ノード */
+} Node;
+
+/* NILノード */
+Node *NIL;
+
+/* プロトタイプ宣言 */
+void leftRotate(Node **root, Node *x);
+void rightRotate(Node **root, Node *x);
+void insertFixup(Node **root, Node *z);
+void insertNode(Node **root, Node *z);
+void transplant(Node **root, Node *u, Node *v);
+Node *minimum(Node *x);
+void deleteFixup(Node **root, Node *x);
+void deleteNode(Node **root, Node *z);
+
+/* 初期化 */
+void
+init()
+{
+    NIL = (Node *)malloc(sizeof(Node));
+    NIL->color = BLACK;
+}
+
+/* 左回転 */
+void
+leftRotate(Node **root, Node *x)
+{
+    Node *y = x->right;
+    x->right = y->left;
+    if (y->left != NIL) {
+        y->left->parent = x;
+    }
+    y->parent = x->parent;
+    if (x->parent == NIL) {
+        *root = y;
+    }
+    else if (x == x->parent->left) {
+        x->parent->left = y;
+    }
+    else {
+        x->parent->right = y;
+    }
+    y->left = x;
+    x->parent = y;
+}
+
+/* 右回転 */
+void
+rightRotate(Node **root, Node *x)
+{
+    Node *y = x->left;
+    x->left = y->right;
+    if (y->right != NIL) {
+        y->right->parent = x;
+    }
+    y->parent = x->parent;
+    if (x->parent == NIL) {
+        *root = y;
+    }
+    else if (x == x->parent->right) {
+        x->parent->right = y;
+    }
+    else {
+        x->parent->left = y;
+    }
+    y->right = x;
+    x->parent = y;
+}
+
+/* 親子関係の修正と色の変更 */
+void
+insertFixup(Node **root, Node *z)
+{
+    Node *y;
+    while (z->parent->color == RED) {
+        if (z->parent == z->parent->parent->left) {
+            y = z->parent->parent->right;
+            if (y->color == RED) {
+                z->parent->color = BLACK;
+                y->color = BLACK;
+                z->parent->parent->color = RED;
+                z = z->parent->parent;
+            }
+            else {
+                if (z == z->parent->right) {
+                    z = z->parent;
+                    leftRotate(root, z);
+                }
+                z->parent->color = BLACK;
+                z->parent->parent->color = RED;
+                rightRotate(root, z->parent->parent);
+            }
+        }
+        else {
+            y = z->parent->parent->left;
+            if (y->color == RED) {
+                z->parent->color = BLACK;
+                y->color = BLACK;
+                z->parent->parent->color = RED;
+                z = z->parent->parent;
+            }
+            else {
+                if (z == z->parent->left) {
+                    z = z->parent;
+                    rightRotate(root, z);
+                }
+                z->parent->color = BLACK;
+                z->parent->parent->color = RED;
+                leftRotate(root, z->parent->parent);
+            }
+        }
+    }
+    (*root)->color = BLACK;
+}
+
+/* ノードの挿入 */
+void
+insertNode(Node **root, Node *z)
+{
+    Node *y = NIL;
+    Node *x = *root;
+    while (x != NIL) {
+        y = x;
+        if (z->key < x->key) {
+            x = x->left;
+        }
+        else {
+            x = x->right;
+        }
+    }
+    z->parent = y;
+    if (y == NIL) {
+        *root = z;
+    }
+    else if (z->key < y->key) {
+        y->left = z;
+    }
+    else {
+        y->right = z;
+    }
+    z->left = NIL;
+    z->right = NIL;
+    z->color = RED;
+    insertFixup(root, z);
+}
+
+/* ノードの置換 */
+void
+transplant(Node **root, Node *u, Node *v)
+{
+    if (u->parent == NIL) {
+        *root = v;
+    }
+    else if (u == u->parent->left) {
+        u->parent->left = v;
+    }
+    else {
+        u->parent->right = v;
+    }
+    v->parent = u->parent;
+}
+
+/* 最小値を持つノードを探索 */
+Node *
+minimum(Node *x)
+{
+    while (x->left != NIL) {
+        x = x->left;
+    }
+    return x;
+}
+
+/*削除のための修正 */ void
+deleteFixup(Node **root, Node *x)
+{
+    Node *w;
+    while (x != *root && x->color == BLACK) {
+        if (x == x->parent->left) {
+            w = x->parent->right;
+            if (w->color == RED) {
+                w->color = BLACK;
+                x->parent->color = RED;
+                leftRotate(root, x->parent);
+                w = x->parent->right;
+            }
+            if (w->left->color == BLACK && w->right->color == BLACK) {
+                w->color = RED;
+                x = x->parent;
+            }
+            else {
+                if (w->right->color == BLACK) {
+                    w->left->color = BLACK;
+                    w->color = RED;
+                    rightRotate(root, w);
+                    w = x->parent->right;
+                }
+                w->color = x->parent->color;
+                x->parent->color = BLACK;
+                w->right->color = BLACK;
+                leftRotate(root, x->parent);
+                x = *root;
+            }
+        }
+        else {
+            w = x->parent->left;
+            if (w->color == RED) {
+                w->color = BLACK;
+                x->parent->color = RED;
+                rightRotate(root, x->parent);
+                w = x->parent->left;
+            }
+            if (w->right->color == BLACK && w->left->color == BLACK) {
+                w->color = RED;
+                x = x->parent;
+            }
+            else {
+                if (w->left->color == BLACK) {
+                    w->right->color = BLACK;
+                    w->color = RED;
+                    leftRotate(root, w);
+                    w = x->parent->left;
+                }
+                w->color = x->parent->color;
+                x->parent->color = BLACK;
+                w->left->color = BLACK;
+                rightRotate(root, x->parent);
+                x = *root;
+            }
+        }
+    }
+    x->color = BLACK;
+}
+
+/* ノードの削除 */
+void
+deleteNode(Node **root, Node *z)
+{
+    Node *y = z;
+    Node *x;
+    int y_original_color = y->color;
+    if (z->left == NIL) {
+        x = z->right;
+        transplant(root, z, z->right);
+    }
+    else if (z->right == NIL) {
+        x = z->left;
+        transplant(root, z, z->left);
+    }
+    else {
+        y = minimum(z->right);
+        y_original_color = y->color;
+        x = y->right;
+        if (y->parent == z) {
+            x->parent = y;
+        }
+        else {
+            transplant(root, y, y->right);
+            y->right = z->right;
+            y->right->parent = y;
+        }
+        transplant(root, z, y);
+        y->left = z->left;
+        y->left->parent = y;
+        y->color = z->color;
+    }
+    if (y_original_color == BLACK) {
+        deleteFixup(root, x);
+    }
+    /* ノードを削除する前に、メモリを解放 */
+    free(z);
+    z = NIL;  // z を NIL に設定
+}
+
+/* ノードの検索 */
+Node *
+search(Node *x, int key)
+{
+    while (x != NIL && key != x->key) {
+        if (key < x->key) {
+            x = x->left;
+        }
+        else {
+            x = x->right;
+        }
+    }
+    return x;
+}
+
+/* ノードの挿入と削除のテスト */
+int
+main()
+{
+    /* 初期化 */
+    init();
+
+    /* 空のRed-Black Treeの作成 */
+    Node *root = NIL;
+
+    /* ノードの挿入 */
+    insertNode(&root, (Node[]){{11, RED, NIL, NIL, NIL}});
+    insertNode(&root, (Node[]){{2, RED, NIL, NIL, NIL}});
+    insertNode(&root, (Node[]){{14, RED, NIL, NIL, NIL}});
+    insertNode(&root, (Node[]){{1, RED, NIL, NIL, NIL}});
+    insertNode(&root, (Node[]){{7, RED, NIL, NIL, NIL}});
+    insertNode(&root, (Node[]){{15, RED, NIL, NIL, NIL}});
+    insertNode(&root, (Node[]){{5, RED, NIL, NIL, NIL}});
+    insertNode(&root, (Node[]){{8, RED, NIL, NIL, NIL}});
+    insertNode(&root, (Node[]){{4, RED, NIL, NIL, NIL}});
+
+    /* 挿入後のTreeの出力 */
+    printf("insert: 11, 2, 14, 1, 7, 15, 5, 8, 4\n");
+    printf("output: ");
+    printf("%d(%c) ", root->key, (root->color == RED) ? 'R' : 'B');
+    printf("%d(%c) ", root->left->key, (root->left->color == RED) ? 'R' : 'B');
+    printf("%d(%c) ", root->right->key,
+           (root->right->color == RED) ? 'R' : 'B');
+    printf("%d(%c) ", root->left->left->key,
+           (root->left->left->color == RED) ? 'R' : 'B');
+    printf("%d(%c) ", root->left->right->key,
+           (root->left->right->color == RED) ? 'R' : 'B');
+    printf("%d(%c) ", root->right->right->key,
+           (root->right->right->color == RED) ? 'R' : 'B');
+    printf("%d(%c) ", root->left->right->left->key,
+           (root->left->right->left->color == RED) ? 'R' : 'B');
+    printf("%d(%c) ", root->left->right->right->key,
+           (root->left->right->right->color == RED) ? 'R' : 'B');
+    printf("%d(%c) ", root->left->right->left->right->key,
+           (root->left->right->left->right->color == RED) ? 'R' : 'B');
+    printf("\n");
+
+    /* ノードの削除 */
+    Node *z = search(root, 2);
+    if (z != NIL) {
+        deleteNode(&root, z);
+    }
+
+    /* 削除後のTreeの出力 */
+    printf("delete: 2\n");
+    printf("output: ");
+    printf("%d(%c) ", root->key, (root->color == RED) ? 'R' : 'B');
+    printf("%d(%c) ", root->left->key, (root->left->color == RED) ? 'R' : 'B');
+    printf("%d(%c) ", root->right->key,
+           (root->right->color == RED) ? 'R' : 'B');
+    printf("%d(%c) ", root->left->left->key,
+           (root->left->left->color == RED) ? 'R' : 'B');
+    printf("%d(%c) ", root->left->right->key,
+           (root->left->right->color == RED) ? 'R' : 'B');
+    printf("%d(%c) ", root->right->right->key,
+           (root->right->right->color == RED) ? 'R' : 'B');
+    printf("%d(%c) ", root->left->right->left->key,
+           (root->left->right->left->color == RED) ? 'R' : 'B');
+    printf("%d(%c) ", root->left->right->left->right->key,
+           (root->left->right->left->right->color == RED) ? 'R' : 'B');
+    printf("\n");
+
+    return 0;
+}
+```
+
+#### 実行結果
+
+途中までは動いてそう
+
+```
+$ ./a.out
+insert: 11, 2, 14, 1, 7, 15, 5, 8, 4
+output: 7(B) 2(R) 11(R) 1(B) 5(B) 14(B) 4(R) 0(B) 0(B)
+a.out(17079,0x1de8d7a80) malloc: *** error for object 0x16f207008: pointer being freed was not allocated
+a.out(17079,0x1de8d7a80) malloc: *** set a breakpoint in malloc_error_break to debug
+zsh: abort      ./a.out
+```
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/user/mizuki/メモ/2023-04-10.md	Wed Apr 19 15:07:28 2023 +0900
@@ -0,0 +1,69 @@
+# 研究目的  
+・サービスを保守運用する中で、システム障害は避けられないものである。しかしながら、障害が発生した時には既に手遅れであることが多く、普段からシステムの状態を把握することが重要である
+
+・障害が発生した際だけでなく、常にシステムの状態を気軽に確認できることが望ましい
+
+・その際、現状ではサーバーやサービスの管理画面にログインしコマンドを打って調査する必要があり手間がかかる。
+
+・そこでチャットツール上からシステムの状態を確認する手法を提案する。
+
+# やったこと
+### grafana, lokiのversion up  
+grafana v9.0 → v9.4  
+loki v 2.6 → 2.8
+
+### cephの状態をmattermost経由で確認
+go-cephというC言語で構築されたCeph APIをgolangにバインドしているプロジェクトがあったのでそちらを使用していこうとおもう  
+https://github.com/ceph/go-ceph  
+
+[API hints](https://github.com/ceph/go-ceph/blob/master/docs/hints.md)を参考に少しコードを書いてみたがどの関数でcephの状態を取得できるかがまだわかっていない。  
+
+daru上で動作確認を行なった。
+go-cephを動作する上で必要なライブラリをインストール  
+`apt-get install librados-dev`
+
+```
+func main(){
+        conn, _ := rados.NewConn()
+        conn.ReadDefaultConfigFile()
+        conn.Connect()
+        defer conn.Shutdown()
+
+        result,err := conn.GetClusterStats()
+        if err != nil {
+                log.Fatalf("failed to execute command: %+v\n", err)
+        }
+        fmt.Println(result)
+}
+```
+上記の関数の返り値は  
+uint64 Kb          
+uint64 Kb_used    
+uint64 Kb_avail 
+uint64 Num_objects  
+らしく、daruでの実行結果は  
+{93755179008 28095795136 65659383872 33180125}
+
+go-cephの関数群が動作することを確認できたのでcephの状態を取得するような処理を探します。
+
+### mattermostへのアラートにダッシュボード画像を入れる
+alertmanagerではなくgrafanaにもアラート機能が存在する  
+その機能にダッシュボードの画像を入れることが可能らしい  
+[公式ドキュメント](https://grafana.com/docs/grafana/latest/alerting/manage-notifications/images-in-notifications/)
+
+前提条件をざっくり要約する  
+アラートで画像を使用するにはプラグインが必要  
+スクリーンショットは一度ローカルに保存される。アクセス権限がないと処理が失敗し、エラーログが吐き出される  
+Discord、メール、Pushover、Slack、Telegram以外は一度クライドストレージに画像を保存する必要がある。  
+grafanaはローカルに保存された画像を削除しないので一定期間過ぎたら削除するようなシステムが必要
+
+
+上記のプラグインのインストール方法でgrafna dockerイメージとの互換性がないらしく別コンテナで作成しリモートレンダリングをする必要があるらしい
+
+### コメント
+df duで容量の確認もチャットで見れたらいい  
+ceph: サーバー上でコマンドを打つのと比較して利点をあげれたらいい
+
+# やること
+論文リポジトリの作成  
+mind mapの作成
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/user/nana.md	Wed Apr 19 15:07:28 2023 +0900
@@ -0,0 +1,2 @@
+# nana
+This is nana's page
\ No newline at end of file