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: コマンドが見つかりません

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

cp -ip ${file_name}

-i option: to confirm when overwriting is necessary
In contrast to the -f option, sometimes you want to check whether it will be overwritten. When dealing with important files, overwriting is a fatal injury.

$cp -i after original copy

“yes or no” confirmation will come out.

cp -i

In recent distributions this is the default as well. If it is not set it may be set with alias.

-p opiton(-parents): copy each directory structure
With the usual cp command, you can not copy in subdirectories. In that case, use the “-P” option.

Running without options in the example will normally just let file.txt go into the directory. Using the –parents option you will find that you can copy the directory structure as is.

[vagrant@localhost ~]$ cp -ip /etc/lsyncd.conf{,.org}
cp: cannot create regular file `/etc/lsyncd.conf.org’: 許可がありません
[vagrant@localhost ~]$ sudo cp -ip /etc/lsyncd.conf{,.org}

install Lsyncd on CentOS

Introduction of Extra Packages for Enterprise Linux (EPEL).

/etc/yum.repos.d/epel.repo

[epel]
name=Extra Packages for Enterprise Linux 6 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

[epel-debuginfo]
name=Extra Packages for Enterprise Linux 6 - $basearch - Debug
#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch/debug
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-6&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
gpgcheck=1

[epel-source]
name=Extra Packages for Enterprise Linux 6 - $basearch - Source
#baseurl=http://download.fedoraproject.org/pub/epel/6/SRPMS
mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-6&arch=$basearch
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
gpgcheck=1

[vagrant@localhost ~]$ sudo sed -i -e “s/enabled=1/enabled=0/” /etc/yum.repos.d/epel.repo

[vagrant@localhost ~]$ sudo yum –enablerepo=epel install lsyncd
読み込んだプラグイン:fastestmirror
インストール処理の設定をしています
Determining fastest mirrors
epel/metalink | 7.6 kB 00:00
* base: ftp-srv2.kddilabs.jp
* epel: mirror01.idc.hinet.net
* extras: ftp-srv2.kddilabs.jp
* remi-safe: ftp.riken.jp
* updates: ftp-srv2.kddilabs.jp
base | 3.7 kB 00:00
epel | 4.7 kB 00:00
epel/primary_db | 6.0 MB 00:12
extras | 3.4 kB 00:00
jenkins | 2.9 kB 00:00
jenkins/primary_db | 126 kB 00:01
mariadb | 2.9 kB 00:00
mysql-connectors-community | 2.5 kB 00:00
mysql-tools-community | 2.5 kB 00:00
mysql56-community | 2.5 kB 00:00
nginx | 2.9 kB 00:00
nodesource | 2.5 kB 00:00
remi-safe | 3.0 kB 00:00
remi-safe/primary_db | 1.2 MB 00:02
updates | 3.4 kB 00:00
依存性の解決をしています
–> トランザクションの確認を実行しています。
—> Package lsyncd.x86_64 0:2.1.5-0.el6 will be インストール
–> 依存性解決を終了しました。

依存性を解決しました

================================================================================
パッケージ アーキテクチャ バージョン リポジトリー 容量
================================================================================
インストールしています:
lsyncd x86_64 2.1.5-0.el6 epel 73 k

トランザクションの要約
================================================================================
インストール 1 パッケージ

総ダウンロード容量: 73 k
インストール済み容量: 205 k
これでいいですか? [y/N]y
パッケージをダウンロードしています:
lsyncd-2.1.5-0.el6.x86_64.rpm | 73 kB 00:00
rpm_check_debug を実行しています
トランザクションのテストを実行しています
トランザクションのテストを成功しました
トランザクションを実行しています
インストールしています : lsyncd-2.1.5-0.el6.x86_64 1/1
Verifying : lsyncd-2.1.5-0.el6.x86_64 1/1

インストール:
lsyncd.x86_64 0:2.1.5-0.el6

完了しました!

ほう^^