#!/bin/sh a=0 while [ $a -lt 5 ] do echo $a a=`expr $a + 1` done
[vagrant@localhost tests]$ sed -i ‘s/\r//’ test.sh
[vagrant@localhost tests]$ ./test.sh
0
1
2
3
4
‘と`の違いで手古摺った.
#!/bin/sh a=0 until [ ! $a -lt 5 ] do echo $a a=`expr $a + 1` done
随机应变 ABCD: Always Be Coding and … : хороший
#!/bin/sh a=0 while [ $a -lt 5 ] do echo $a a=`expr $a + 1` done
[vagrant@localhost tests]$ sed -i ‘s/\r//’ test.sh
[vagrant@localhost tests]$ ./test.sh
0
1
2
3
4
‘と`の違いで手古摺った.
#!/bin/sh a=0 until [ ! $a -lt 5 ] do echo $a a=`expr $a + 1` done
#!/bin/sh DRINK="beer" case "$DRINK" in "beer") echo "this is beer" ;; "juice") echo "that is juice" ;; "coak") echo "Do not drink it" ;; esac
[vagrant@localhost tests]$ sed -i ‘s/\r//’ test.sh
[vagrant@localhost tests]$ ./test.sh
this is beer
esacとか、使い慣れてないなー
#!/bin/sh if [ "$1" -gt "$2" ] then echo "1番目の引数が2番目の引数より大きい" elif [ "$1" -eq "$2" ] then echo "1番目の引数と2番目の引数は同じです" else echo "1番目の引数が2番目の引数より小さい" fi
[vagrant@localhost tests]$ sed -i ‘s/\r//’ test.sh
[vagrant@localhost tests]$ ./test.sh 5 4
1番目の引数が2番目の引数より大きい
Variable Function
$0 script name
Access $1 ~ $9 arguments, $1 for the first argument, $2 for the second argument
$ # number of arguments given to the script
$ * treat all arguments together as one
$ @ Thread all arguments as separate
$? End value of the last executed command (0 is success, 1 is failure)
$$ Process ID of this shell script
$! last executed background process ID
#!/bin/sh echo "\$0 (スクリプト名): $0" echo "\$1 (1番目の引数): $1" echo "\$2 (2番目の引数): $2" echo "\$# (引数の数): $#" echo "\"\$*\": \"$*\"" echo "\"\$@\": \"$@\"" VAR="exit値は0になるはずです" echo $?
[vagrant@localhost tests]$ sed -i ‘s/\r//’ test.sh
[vagrant@localhost tests]$ ./test.sh
$0 (スクリプト名): ./test.sh
$1 (1番目の引数):
$2 (2番目の引数):
$# (引数の数): 0
“$*”: “”
“$@”: “”
0
Can use single-byte alphanumeric characers and underscores as variable name. a to z, A to Z, 0 to 9 and _.
When giving a value to a variable, write = without leading and trailing blanks. If it is a string, enclose it in “.
Put $ before the variable name when accessing the variable. or put $ and enclose the variable in {}.
Only one value can be stored in one variable.
Use readonly to not overwrite the value of the variable. Variables can be deleted by unset. (You can not delete the readonly variable.)
#!/bin/sh var="yukijirushi" var2="coffee" echo "I'm drinking $var2"
[vagrant@localhost tests]$ sed -i ‘s/\r//’ test.sh
[vagrant@localhost tests]$ ./test.sh
I’m drinking coffee
なるほど。
#!/bin/sh
var="yukijirushi"
var2="coffee"
echo "I'm drinking $var2"
var2="traditional test"
echo ${var2}
[vagrant@localhost tests]$ sed -i ‘s/\r//’ test.sh
[vagrant@localhost tests]$ ./test.sh
I’m drinking coffee
traditional test
ここまでは簡単
Shell script is simply to execute Unix command etc. side by side. It is responsible for when to execute what instruction and what condition, read file contents, and write log file.
#!/bin/sh echo "Hello, World!"
[vagrant@localhost tests]$ chmod 755 test.sh
[vagrant@localhost tests]$ ./test.sh
-bash: ./test.sh: /bin/sh^M: bad interpreter: そのようなファイルやディレクトリはありません
[vagrant@localhost tests]$ sed -i ‘s/\r//’ test.sh
sed: -e 表現 #1, 文字数 1: 未知のコマンドです: 「▒」
[vagrant@localhost tests]$ ./test.sh
-bash: ./test.sh: /bin/sh^M: bad interpreter: そのようなファイルやディレクトリはありません
[vagrant@localhost tests]$ sed -i ‘s/\r//’ test.sh
[vagrant@localhost tests]$ ./test.sh
Hello, World!
#!/bin/sh # コメントです。 read NAME echo "Hello, $NAME!"
あれ、コマンドラインが止まる? なんでだろう。。

Oracle data type: NUMBER
The “NUMBER” data type stores fixed and floating point numbers. It can store virtually any numerical value. If your system is running Oracle Database, portability between systems is guaranteed with up to 38 digits of precision.
The NUMBER column can contain the following numbers:
A positive number in the range 1 x 10 – 130 to 9.99 … 9x 10125
Oracle guarantees the portability of numbers with the precision of 38 digits or less. When specifying numeric fields, it is better to specify precision and scale.
MySQL Data type
BIG INT:NUMBER (19, 0)
INT:NUMBER(10,0)
MEDIUMINT:NUMBER(7, 0)
NUMERIC:NUMBER
SMALLINT:NUMBER(5,0)
TINYINT:NUMBER(3,0)
YEAR:NUMBER
primary keyのIDでnumberを使われていれば、intでいいでしょうね。
creating elb

ん?セキュリティグループで制御してるのか??

VPCを見ます。

Network ACLのinboundから編集する VPCはvisual private cloud.

なるほどーELBで実際に負荷分散して運用しないとあかんな
1. General
Do not use capital letters
Neither table names nor column names use uppercase letters.
× DOCUMENTS
× Documents
〇 documents
2. Cooperation of multiple words is a snake case
Use snake case for both table name and column name. Camel case, camel back is NG.
× tableName
× TableName
× tablename
〇 table_name
3. English notation
Basically not in roman letters, but in English. Do not use abbreviations.
なるほどースネークケースか。
わかりましたぞー
The INNODB_TRX table indicates whether the transaction is waiting for a lock, when the transaction starts, the SQL statement that the transaction is executing (if any), etc. Currently executing inside InnoDB (except for read-only transactions) contains information about all transactions.
TRX_ID
Unique transaction ID number within InnoDB. (As of Mysql5.6, these IDs are not created for read-only, non-locked transactions.)
TRX_WEIGHT
Transaction weight. This reflects the number of rows changed by the transaction and the number of rows locked(but not necessarily exactly). To resolve deadlocks, InnoDB chooses the transaction with the lowest weight as the target to roll back. Transactions that have changed non-transactional tables are considered more heavily weighted than other transactions.
TRX_STATE
Transaction execution status. One of Running, lock wait, rolling back, or commiting.
TRX_STARTED
Transaction start time.
TRX_REQUESTED_LOCK_ID
Lock ID on which the transaction is currently waiting (if TRX_STATE is lock wait, otherwise NULL). Details about locks can be found by linking to INNODB_LOCKS in LOCK_ID.
TRX_WAIT_STARTED
The time when the transaction started waiting for the lock(if TRX_STATE is lock wait, otherwise null).
TRX_MYSQL_THREAD_ID
Mysql thread id. It can be used to combine with Processlist by id.
TRX_QUERY
SQL query being executed by the transaction.
TRX_OPERATION_STATE
Transaction’s current operation or NULL.
TRX_TABLES_IN_USE
Number of InnoDB tables used when processing the current SQL statement for this transaction.
TRX_TABLES_LOCKED
The number of InnoDB tables for which the current SQL statement has a row lock.
TRX_LOCK_STRUTTS
Number of locks reserved in the transaction.
TRX_LOCK_MEMORY_BYTES
Total size used in memory by the lock structure for this transaction.
TRX_ROWS_LOCKED
Approximate number of rows locked by this transaction. This value may include rows that are marked for deletion that physically exist but are not recognized by the transaction.
TRX_ROWS_MODIFIED
Number of rows changed and inserted in this transaction.
TRX_CONCURRENCY_TICKETS
A value that indicates the amount of work that can be done in the current transaction before being swapped out, as specified by the innodb_concurrency_tickets option.
mysql> SELECT * FROM INFORMATION_SCHEMA.INNODB_TRX \G
*************************** 1. row ***************************
trx_id: 3298
trx_state: RUNNING
trx_started: 2014-11-19 13:54:39
trx_requested_lock_id: NULL
trx_wait_started: NULL
trx_weight: 316436
trx_mysql_thread_id: 2
trx_query: DELETE FROM employees.salaries WHERE salary > 65000
trx_operation_state: updating or deleting
trx_tables_in_use: 1
trx_tables_locked: 1
trx_lock_structs: 1621
trx_lock_memory_bytes: 243240
trx_rows_locked: 759343
trx_rows_modified: 314815
trx_concurrency_tickets: 0
trx_isolation_level: REPEATABLE READ
trx_unique_checks: 1
trx_foreign_key_checks: 1
trx_last_foreign_key_error: NULL
trx_adaptive_hash_latched: 0
trx_adaptive_hash_timeout: 10000
trx_is_read_only: 0
trx_autocommit_non_locking: 0
うーん、なんか覚えておいた方が良さそうだなー、特にトラブル対応
でも、こーなる
mysql> select * from information_schema.innodb_trx\G; Empty set (0.00 sec) ERROR: No query specified