primary keyとは
-> 他のカラムと重複不可、nullも不可
-> ユーザーIDなどによく使われる
サンプル
CREATE TABLE テーブル名 ( カラム1 型情報 NOT NULL PRIMARY KEY, カラム2 型情報 );
随机应变 ABCD: Always Be Coding and … : хороший
primary keyとは
-> 他のカラムと重複不可、nullも不可
-> ユーザーIDなどによく使われる
サンプル
CREATE TABLE テーブル名 ( カラム1 型情報 NOT NULL PRIMARY KEY, カラム2 型情報 );
selectを使おう
#!/bin/bash select color in red blue yellow green; do case "$color" in red) echo "stop" ;; blue) echo "go" ;; yello) echo "caution" ;; *) echo "wrong signal" break esac done
[vagrant@localhost shell]$ sed -i ‘s/\r//’ hello
[vagrant@localhost shell]$ ./hello
1) red
2) blue
3) yellow
4) green
#? 2
go
#? 4
wrong signal
#!/bin/bash
hello(){
echo "hello ... $1"
}
hello yoshida
[vagrant@localhost shell]$ sed -i ‘s/\r//’ hello
[vagrant@localhost shell]$ ./hello
hello … yoshida
UNIX系(Linux,Mac)はシェルスクリプト、Windowsはバッチ処理
シェルスクリプトに処理を書いていき、実行する
#!/bin/bash read -p "Number? " n if ((n > 10)); then echo "bigger than 10" fi
[vagrant@localhost shell]$ sed -i ‘s/\r//’ hello
[vagrant@localhost shell]$ ./hello
Number? 12
bigger than 10
#!/bin/bash
for i in {1..5};
do
echo $i
done
#!/bin/bash
for ((i=1; i<10; i++)); do echo $i done [/code] [code] #!/bin/bash for item in $(date); do echo $item done [/code] [vagrant@localhost shell]$ sed -i 's/\r//' hello [vagrant@localhost shell]$ ./hello 2018年 9月 30日 日曜日 12:11:36 JST [code] #!/bin/bash i=1 while read line; do echo $i "$line" ((i++)) done < colors.txt [/code] [vagrant@localhost shell]$ sed -i 's/\r//' hello [vagrant@localhost shell]$ ./hello 1 red 2 blue [code] #!/bin/bash read -p "Signal color? " color case "$color" in red) echo "stop" ;; blue) echo "go" ;; yello) echo "caution" ;; *) echo "wrong signal" esac [/code] [vagrant@localhost shell]$ sed -i 's/\r//' hello [vagrant@localhost shell]$ ./hello Signal color? red stop
[vagrant@localhost shell]$ sed -i ‘s/\r//’ hello
[vagrant@localhost shell]$ ./hello yoshida
hello yoshida
#!/bin/bash echo "hello $1"
$1, $2などを使う
#!/bin/bash echo "hello $1" echo $0 echo $# echo $@
[vagrant@localhost shell]$ sed -i ‘s/\r//’ hello
[vagrant@localhost shell]$ ./hello a aa aaa
hello a
./hello
3
a aa aaa
ユーザーからの入力を受け取る
#!/bin/bash
read -p "名前: " name
echo "hello ${name}"
[vagrant@localhost shell]$ ./hello
名前: 田中
hello 田中
なんじゃこりゃーー
#!/bin/bash read -p "Pick 3 colors: " c1 c2 c3 echo $c1 echo $c2 echo $c3
[vagrant@localhost shell]$ ./hello
Pick 3 colors: red geen blue
red
geen
blue
配列
#!/bin/bash
colors=(red blue pink)
colors[1]=silver
colors+=(green orange)
echo ${colors[@]}
[vagrant@localhost shell]$ sed -i ‘s/\r//’ hello
[vagrant@localhost shell]$ ./hello
red silver pink green orange
数値計算
#!/bin/bash echo $((5 + 2)) n=10 ((n=n + 2)) echo $n
if文
read -p "Name? " name if [ "$name" = "yoshida" ] then echo "welcome" else echo "you are not allowed" fi
[vagrant@localhost shell]$ ./hello
Name? yoshida
welcome
#!/bin/bash read -p "Name? " name if [ "$name" = "yoshida" ] then echo "welcome" elif [ "$name" = "kobayashi" ] then echo "welcome, too" else echo "you are not allowed" fi
[vagrant@localhost shell]$ sed -i ‘s/\r//’ hello
[vagrant@localhost shell]$ ./hello
Name? kobayashi
welcome, too
[vagrant@localhost shell]$ ./hello
Name?
empty …
ファイルを比較
#!/bin/bash if [[ -f $0 ]]; then echo "file exists ..." fi
[vagrant@localhost shell]$ sed -i ‘s/\r//’ hello
[vagrant@localhost shell]$ ./hello
file exists …
[vagrant@localhost shell]$ which bash
/bin/bash
[vagrant@localhost shell]$ cat -A hello
#!/bin/bash^M$
^M$
echo hello
^Mがあるのがよろしくない
tr(ティーアール)はUNIXおよびUNIX系システムのコマンドである。名称は translate または transliterate の略。
tr は標準入力から読み込んで標準出力に出力する。パラメータとして2つの文字集合を指定し、一方の文字集合に含まれる文字が出現する度に、もう一方の文字集合の同じ位置にある文字に置換して出力する。
sed(セド)は、入力ストリーム(ファイルまたはパイプラインからの入力)に対してテキスト変換などのデータ処理をおこなうために使用されるプログラム
文字列の置き換えは「s」コマンドを使って、「s/置換前/置換後/」と指定します。例えば、文字列「GNU」を「gnu」に置き換えるならば、「s/GNU/gnu/」と指定します。
[vagrant@localhost shell]$ sed -e s/^M// hello
#!/bin/bash
echo hello
改行コードを変換する
[vagrant@localhost shell]$ sed -i 's/\r//' hello [vagrant@localhost shell]$ cat -e hello #!/bin/bash$ $ echo hello[vagrant@localhost shell]$ ./hello hello
変数を使用する
#!/bin/bash
name="yoshida"
echo "hello world $name"
echo "foo ${name}san"; echo "bar"
[vagrant@localhost shell]$ sed -i ‘s/\r//’ hello
[vagrant@localhost shell]$ ./hello
hello world yoshida
foo yoshidasan
bar
in: type: file path_prefix: "./ratings.csv" out: type: stdout
[vagrant@localhost embulk]$ embulk guess seed.yml -o config.yml
2018-09-30 09:35:40.455 +0900: Embulk v0.9.7
2018-09-30 09:35:43.144 +0900 [WARN] (main): DEPRECATION: JRuby org.jruby.embed.ScriptingContainer is directly injected.
2018-09-30 09:35:47.529 +0900 [INFO] (main): Gem’s home and path are set by default: “/home/vagrant/.embulk/lib/gems”
2018-09-30 09:35:49.736 +0900 [INFO] (main): Started Embulk v0.9.7
2018-09-30 09:35:49.900 +0900 [INFO] (0001:guess): Listing local files at directory ‘.’ filtering filename by prefix ‘ratings.csv’
2018-09-30 09:35:49.912 +0900 [INFO] (0001:guess): “follow_symlinks” is set false. Note that symbolic links to directories are skipped.
2018-09-30 09:35:49.932 +0900 [INFO] (0001:guess): Loading files [ratings.csv.bak, ratings.csv]
2018-09-30 09:35:49.983 +0900 [INFO] (0001:guess): Try to read 32,768 bytes from input source
2018-09-30 09:35:50.397 +0900 [INFO] (0001:guess): Loaded plugin embulk (0.9.7)
2018-09-30 09:35:50.469 +0900 [INFO] (0001:guess): Loaded plugin embulk (0.9.7)
2018-09-30 09:35:50.516 +0900 [INFO] (0001:guess): Loaded plugin embulk (0.9.7)
2018-09-30 09:35:50.535 +0900 [INFO] (0001:guess): Loaded plugin embulk (0.9.7)
in:
type: file
path_prefix: ./ratings.csv
parser:
charset: UTF-8
newline: LF
type: csv
delimiter: ‘,’
quote: ‘”‘
escape: ‘”‘
trim_if_not_quoted: false
skip_header_lines: 1
allow_extra_columns: false
allow_optional_columns: false
columns:
– {name: id, type: long}
– {name: restaurant_id, type: long}
– {name: user_id, type: string}
– {name: total, type: long}
– {name: food, type: long}
– {name: service, type: long}
– {name: atmosphere, type: long}
– {name: cost_performance, type: long}
– {name: title, type: string}
– {name: body, type: string}
– {name: purpose, type: long}
– {name: created_on, type: timestamp, format: ‘%Y-%m-%d %H:%M:%S’}
out: {type: stdout}
Created ‘config.yml’ file.
[vagrant@localhost embulk]$ embulk preview config.yml
2018-09-30 09:39:04.618 +0900: Embulk v0.9.7
2018-09-30 09:39:07.007 +0900 [WARN] (main): DEPRECATION: JRuby org.jruby.embed.ScriptingContainer is directly injected.
2018-09-30 09:39:11.003 +0900 [INFO] (main): Gem’s home and path are set by default: “/home/vagrant/.embulk/lib/gems”
2018-09-30 09:39:12.432 +0900 [INFO] (main): Started Embulk v0.9.7
2018-09-30 09:39:12.612 +0900 [INFO] (0001:preview): Listing local files at directory ‘.’ filtering filename by prefix ‘ratings.csv’
2018-09-30 09:39:12.614 +0900 [INFO] (0001:preview): “follow_symlinks” is set false. Note that symbolic links to directories are skipped.
2018-09-30 09:39:12.620 +0900 [INFO] (0001:preview): Loading files [ratings.csv.bak, ratings.csv]
2018-09-30 09:39:12.641 +0900 [INFO] (0001:preview): Try to read 32,768 bytes from input source
2018-09-30 09:39:13.337 +0900 [WARN] (0001:preview): Skipped line 48 (Unexpected end of line during parsing a quoted value): 72860,1076,4e11ad7b,1,0,0,0,0,,”なぜあの店はあんなに行列ができるのだろうと、車で通�
なんじゃこりゃーーーーーーーーーーー
設定ファイル
sourceディレクティブ。入力方法を決める
<source> type forward </source>
matchディレクティブ。マッチした入力への処理を決める
<match index.html> type file path /var/log/fluent/access1 </match>
[vagrant@localhost td-agent]$ sudo /etc/init.d/td-agent status
td-agent is running [ OK ]
vagrant@vagrant-ubuntu-trusty-64:~$ ruby -v
ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]
vagrant@vagrant-ubuntu-trusty-64:~$ gem -v
1.8.23
vagrant@vagrant-ubuntu-trusty-64:~$ gem update –system
ERROR: While executing gem … (RuntimeError)
gem update –system is disabled on Debian, because it will overwrite the content of the rubygems Debian package, and might break your Debian system in subtle ways. The Debian-supported way to update rubygems is through apt-get, using Debian official repositories.
If you really know what you are doing, you can still update rubygems by setting the REALLY_GEM_UPDATE_SYSTEM environment variable, but please remember that this is completely unsupported by Debian.
vagrant@vagrant-ubuntu-trusty-64:~$ gem list
*** LOCAL GEMS ***
curl -L https://toolbelt.treasuredata.com/sh/install-amazon1-td-agent3.sh | sh
[vagrant@localhost td-agent]$ ls
plugin td-agent.conf
PHPを用いて動的Webサイトを構築するために利用するオープンソースのWebアプリケーションフレームワーク
コード量が少ない(どこでどんな処理をしているのかの見通しもいい)
動作が速い(これまた、レイヤーの薄さがあっての効果です)
稼働中のコンテナに入る
docker-compose exec hoge_app bash
stop
docker-compose stop
docker-compose rm -v
docker-compose build –no-cache
docker rm ‘docker ps -a -q’
docker volume rm $(docker volume ls -qf dangling=true)
docker images -a
docker rmi ‘docker images -aq’
docker rmi -f ‘docker images -aq’
docker image prune
docker rmi $(docker images | awk ‘/^
docker cp file.rc continername:/host/dir/
docker cp continer_name:/var/www/html/ /User/meta/hoge
vagrant@vagrant-ubuntu-trusty-64:~/wordpress/dataonly$ sudo curl -L https://github.com/docker/compose/releases/download/1.16.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 617 0 617 0 0 374 0 –:–:– 0:00:01 –:–:– 374
100 8648k 100 8648k 0 0 205k 0 0:00:42 0:00:42 –:–:– 303k
vagrant@vagrant-ubuntu-trusty-64:~/wordpress/dataonly$ sudo chmod +x /usr/local/bin/docker-compose
vagrant@vagrant-ubuntu-trusty-64:~/wordpress/dataonly$ sudo docker-compose ps
Name Command State Ports
————————————————————————————
dataonly_dbserver_1 docker-entrypoint.sh mysqld Up 3306/tcp, 33060/tcp
dataonly_webserver_1 docker-entrypoint.sh apach … Exit 1
Docker compose とは、複数のコンテナから成るサービスを構築・実行する手順を自動的にし、管理を容易にする機能