MySQL transaction

A transaction is a unit of work or unit of work performed in a DB system.

The result of the transaction is either “commit” or “rollback”.

■ Commit
Commit is a process that is executed when there is no problem with all the processes in the transaction. Execution will confirm the processing, and the result of the transaction will be reflected in the DB. You can not roll back committed data.

■ Rollback
Rollback is a process that is executed when a problem occurs in the processing of a transaction. When executed, data is returned until the transaction start time. Rollback is not process(SQL) unit in a transaction. It is done on a transaction basis.

MySQL auto commit

One of MySQL functions, autocommit is enabled / disabled and how it changes behavior.

Bottom line that InnoDB table is transaction safe.
(MySAM does not support transactions)

あれ、そもそもトランザクションって何?単語から何かの処理なんだろうなーってことはわかるけど???

DB auto commit and manual commit

There are two methods of transaction commit: auto commit and manual commit.

Auto-commit means that automatically starts and terminates a transaction for each data operation, that is, for each API call.
Manual commit means that the application commits by executing commit.

Use manual commit to combine multiple update operations into a single transaction.

When establishing a connection, auto-commit is enabled. If auto-commit is enabled, it will be auto-commit, and if auto-commit is disabled, it will be manual commit. Switching between auto commit and manual commit is configured with API.

Access MySQL from external host: mysql -h ip u root -p

After logging in as root, check the registered users and register additional external IP addresses.

Connect to database, mysql -u root -p
-u: specify a user option
-u root: meaning like “by root user”
-p: login with password option

-Add an external IP address
Configure John user to access xxxdb from 192.168.1.*.

mysql> grant all privileges on xxxdb.* to john@”192.168.1.%” identified by ‘hoge’ with grant option;

How to login from an external host
$ mysql -h 192.168.1.12 -u John -p
port number: 3306 is running.
If it can not connect, check TCP Wrapper and IP tables.

How to login by specifying a database:
$ mysql -h 192.168.1.12 dbname -u John -p

To specify a port from an external host and login
$ mysql -h 192.168.1.12 –port=3307 -u John -p
When connecting to a MySQL server whose port number is set other than 3306, also specify the port number.

Outgoing webhooks

Outgoing Webhooks sends a post data from Slack via POST when there is a specific post, and sends a response in json in a specific format to that post.

ん?outgoing webhookを検索します。
ありました。

token=hoge
team_id=T0001
team_domain=例

channel_id=C2147483705
channel_name=テスト

timestamp=1355517523.000005
user_id=U1234
user_name=スティーブ

text=googlebot: 身軽なツバメの対気速度はどのくらい?

trigger_word=googlebot:

返信中

{
	"text": "アフリカ系あるいはヨーロッパ系?"
}

Channel :投稿を取得するチャンネル
URL(s) :POST送信先になるURL
Customize Name :レスポンスを返す際の名前
Customize Icon :レスポンスを返す際のアイコン

When a message that meets the conditions is posted, an HTTP request is thrown to the URL(web service) set in advance.


引き金となるワードがあると、特定のURLにリクエストを送ることができるということですね。なるほどー

Technical debt(技術的負債)とは

Technical debt is a new metaphor that refers to a sloppy software architecture and the consequences of unsatisfying software development. It is also referred to as “design debt”.

What kind of technical debt is there?
– Low coverage or no written test code
– Findings that smooth sharing has not been done between developers and stakeholders.
– Ignored compiler warnings and code analysis results
– Designs and codes that are unnecessarily complex
– Code not in compliance with coding conventions
– Unwanted odor (this metaphor is often used for refactoring)
– Old versions of languages and frameworks
– Difference between development environment and production environment

rsync

rsync is application software that uses differential encoding to minimize the amount of data transfer and synchronize files and directories between remote site in UNIX sytems. As a unique feature of rsync which is not found in similar programs and protocols, there is a point that transfer with a mirror site is done bidirectionally at most once. rsync displays directory contents and can copy directories and files. Optionally data compression and recursion can also be specified.

The rsync protocol daemon rsyncd uses TCP port number 873 by default. rsync can also be used to synchronize local directories, it can also be used via RSH or SSH remote shell. In the latter case, the rsync client program needs to be installed both locally and remotely.

It is released at GNU General Public License and is free software.

[vagrant@localhost ~]$ sudo lsyncd -nodaemon -log scarce /etc/lsyncd.conf
Error: failure getting absolute path of [/tmp/origin]
Error: Cannot access source directory: /tmp/origin
[vagrant@localhost ~]$ sudo lsyncd -nodaemon -log scarce /etc/lsyncd.conf

apache restart/reloadの必要性

-Apacheに関わる設定ファイルの修正であれば、再起動が必要
-SSL証明書の変更や、モジュール追加を行った場合も再起動が必要
-設定ファイルを変更した時

-.htaccessの修正であれば、再起動は不要(そのディレクトリ内(ディレクトリ以下すべて)のファイルを読み込もうとしたときに、設定がはじめて活かされる。そのため、変更は即座に反映され、Apacheを再起動する必要がない。)

ん?よくわらんぞ。。

what is xinetd?

xinetd is an Internet super server replacing the inetd daemon. For inetd, the setting of the service to be provided was done in /etc/intd.conf, but in xinetd, setting of services to be provided using /etc/xinetd.conf and files under /etc/xinetd.d to hold.

/etc/xinetd.conf is the default configuration file of xinetd, and each file under /etc/xinetd.d is a configuration file for each service.

[vagrant@localhost ~]$ sudo cat /etc/xinetd.conf
cat: /etc/xinetd.conf: そのようなファイルやディレクトリはありません

なんじゃーーーーーーーーー

edit /etc/lsyncd.conf

default file setting

----
-- User configuration file for lsyncd.
--
-- Simple example for default rsync, but executing moves through on the target.
--
-- For more examples, see /usr/share/doc/lsyncd*/examples/
-- 
-- sync{default.rsyncssh, source="/var/www/html", host="localhost", targetdir="/tmp/htmlcopy/"}

[vagrant@localhost ~]$ sudo vi /etc/lsyncd.conf

settings {
	logfile = "/var/log/lsyncd/lsyncd.log",
	statusFile = "/var/log/lsyncd/lsyncd.status"
}

sync {
	default.rsync,
	source = "/tmp/origin",
	target = "/tmp/target",
	rsync = {
		archive = true,
		compress = true
	},
	delete = false
}

[vagrant@localhost ~]$ mkdir -m 700 /var/log/lsyncd && chcon -R -u system_u “/var/log/lsyncd”
mkdir: ディレクトリ `/var/log/lsyncd’ を作成できません: ファイルが存在します
なにいいいいいいいいいいいいいいい

[vagrant@localhost ~]$ systemctl restart rsyslog
-bash: systemctl: コマンドが見つかりません
[vagrant@localhost ~]$ systemctl start lsyncd
-bash: systemctl: コマンドが見つかりません

なにいいいいいいいいいいいいいいいいいいいいいいいい