おっさんエンジニアの忘備録

Linux系の各種作業を自分用の忘備録として残しています

RHEL6にruby2.3.0をインストール

https://github.com/rbenv/rbenv#installation

こちらを参考にしました。

事前に以下のパッケージのインストールが必要です。

 openssl-devel readline-devel zlib-devel

 

(1)gitインストール

# yum install git

 

(2)rbenvインストール

①gitからチェックアウト

# git clone https://github.com/rbenv/rbenv.git ~/.rbenv
Initialized empty Git repository in /root/.rbenv/.git/
remote: Counting objects: 2495, done.
remote: Total 2495 (delta 0), reused 0 (delta 0), pack-reused 2495
Receiving objects: 100% (2495/2495), 455.13 KiB | 163 KiB/s, done.
Resolving deltas: 100% (1543/1543), done.

コンパイル

# cd ~/.rbenv && src/configure && make -C src
make: ディレクトリ `/root/.rbenv/src' に入ります
gcc -fPIC -c -o realpath.o realpath.c
gcc -shared -Wl,-soname,../libexec/rbenv-realpath.dylib -o ../libexec/rbenv-realpath.dylib realpath.o
make: ディレクトリ `/root/.rbenv/src' から出ます

 

③パスを通す

# echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile

 

④ログインし直し

 

⑤確認

# type rbenv
rbenv is /root/.rbenv/bin/rbenv

 

(3)ruby-buildインストール

# git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
Initialized empty Git repository in /root/.rbenv/plugins/ruby-build/.git/
remote: Counting objects: 6028, done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 6028 (delta 0), reused 0 (delta 0), pack-reused 6022
Receiving objects: 100% (6028/6028), 1.16 MiB | 479 KiB/s, done.
Resolving deltas: 100% (3418/3418), done.

 

(4)rubyインストール

①インストール

# rbenv install 2.3.0
Downloading ruby-2.3.0.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.0.tar.bz2
Installing ruby-2.3.0...
Installed ruby-2.3.0 to /root/.rbenv/versions/2.3.0

 

②環境全体でのRubyバージョンの指定

# rbenv global 2.3.0

⇒これをやらないとruby実行時にエラーになっちゃいます。。。。

 

③パスを通す

# echo 'export PATH="$HOME/.rbenv/shims/:$PATH"' >> ~/.bash_profile

 

④ログインし直し

 

⑤バージョン確認

# ruby -v
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]

 

(5)お決まりのhello,world

①hello.rb作成

puts "hello,world"

 

②実行してみる

# ruby hello.rb
hello,world

MySQLデータベース・テーブル作成

(1)データベース作成

mysql> CREATE DATABASE test_db;
Query OK, 1 row affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| test_db |
+--------------------+
5 rows in set (0.00 sec)

mysql>

 

 

(2)テーブル作成

mysql> create table test_db.zaiko(id int auto_increment primary key,
-> maker text,
-> type text,
-> serial varchar(100),
-> purpose varchar(20),
-> input_date date,
-> output_date date,
-> index(id));
Query OK, 0 rows affected (0.27 sec)

mysql> use test_db;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+-------------------+
| Tables_in_test_db |
+-------------------+
| zaiko |
+-------------------+
1 row in set (0.00 sec)

mysql> SHOW COLUMNS FROM zaiko;
+-------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| maker | text | YES | | NULL | |
| type | text | YES | | NULL | |
| serial | varchar(100) | YES | | NULL | |
| purpose | varchar(20) | YES | | NULL | |
| input_date | date | YES | | NULL | |
| output_date | date | YES | | NULL | |
+-------------+--------------+------+-----+---------+----------------+
7 rows in set (0.00 sec)

mysql>

負荷テスト関連サイト

◆abコマンド
http://www.atmarkit.co.jp/ait/articles/0206/29/news001_2.html


◆stressコマンド
http://d.hatena.ne.jp/jitsu102/20111120/1321790533

Linux Test Project
http://blog.livedoor.jp/hakin/archives/51038015.html

◆ApacheJmeter
http://jmeter.apache.org/
http://codezine.jp/article/detail/336
http://www.techscore.com/tech/Java/ApacheJakarta/JMeter/1/

JmeterでWeb操作を記録
http://isakado.blog106.fc2.com/blog-entry-81.html

◆負荷テスト時のモニタリング方法
http://www.ashisuto.co.jp/product/category/quality/loadrunner/technical/list/1195222_3454.html

RHEL6にsambaをインストール

必要最小限のみの設定です。

(1)yumsambaインストール

yum install samba

 

(2)公開用のディレクトリ作成

# mkdir /home/share

# chmod 777 /home/share

 

(3)smb.confの修正

security = user
map to guest = Bad User

⇒セキュリティの設定(guestアクセスを許可)

⇒『security = share』はSamba 3.6.0以降ではdeprecatedとなっているみたいです

hosts allow = 10.

⇒アクセスを許可するIPアドレスの設定(こちらの場合ですと10.0.0.0/8からのアクセスを許可)

複数ある場合はスペース区切りで記述すればよいみたいです

; [public]
; comment = Public Stuff
; path = /home/samba
; public = yes
; writable = yes
; printable = no
; write list = +staff

[public]
comment = Public
path = /home/share
public = yes
writable = yes
printable = no
write list = +staff

⇒上記の通りに変更

 

(4)動作確認

f:id:saosao_0706:20160414135541p:plain

⇒ファイルが参照できる

 

 

 

 

 

 

 

 

 

Mysql5.7初期セットアップ

(1)/var/log/mysqld.logに出力されている初期パスワードを確認

# less /var/log/mysqld.log
2016-04-09T12:30:14.228569Z 1 [Note] A temporary password is generated for root@localhost: rK;img*lo7Oe

 

(2)mysql_secure_installationを起動

# mysql_secure_installation
Securing the MySQL server deployment.
Enter password for user root:[初期パスワードを入力]
The existing password for the user account root has expired. Please set a new password.
New password:[新しいパスワードを入力]                                Ts****-2016
Re-enter new password:[新しいパスワードを入力]
The 'validate_password' plugin is installed on the server.
The subsequent steps will run with the existing configuration
of the plugin.
Using existing password for root.
Estimated strength of the password: 100
Change the password for root ? ((Press y|Y for Yes, any other key for No) : y
New password:[新しいパスワードを入力]
Re-enter new password:[新しいパスワードを入力]
Estimated strength of the password: 100
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.

Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
- Dropping test database...
Success.
- Removing privileges on test database...
Success.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately. Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.
All done!

 

(3)変更したパスワードでログインできることを確認

# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 22
Server version: 5.7.11 MySQL Community Server (GPL)
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> \q
Bye
[root@localhost ~]#

vegrantのCentOS6.7のロケール変更

vagrantCentOSの仮想環境を構築した場合、ロケールが英語になってしまう(init時にロケールを選択できない)ため、ロケールを変更してあげる必要があります。

 

(1)デフォルトのロケール確認

# locale

LANG=en_GB.UTF-8
LC_CTYPE="en_GB.UTF-8"
LC_NUMERIC="en_GB.UTF-8"
LC_TIME="en_GB.UTF-8"
LC_COLLATE="en_GB.UTF-8"
LC_MONETARY="en_GB.UTF-8"
LC_MESSAGES="en_GB.UTF-8"
LC_PAPER="en_GB.UTF-8"
LC_NAME="en_GB.UTF-8"
LC_ADDRESS="en_GB.UTF-8"
LC_TELEPHONE="en_GB.UTF-8"
LC_MEASUREMENT="en_GB.UTF-8"
LC_IDENTIFICATION="en_GB.UTF-8"
LC_ALL=

        ⇒英語(en_GB.UTF-8)になっています

 

(2)/etc/sysconfig/i18n変更

LANG="ja_JP.utf8"
SYSFONT="latarcyrheb-sun16"

⇒LANGを「ja_JP.utf8」に変更

 

(3)ログインし直してlocaleの確認

# locale
LANG=ja_JP.utf8
LC_CTYPE="ja_JP.utf8"
LC_NUMERIC="ja_JP.utf8"
LC_TIME="ja_JP.utf8"
LC_COLLATE="ja_JP.utf8"
LC_MONETARY="ja_JP.utf8"
LC_MESSAGES="ja_JP.utf8"
LC_PAPER="ja_JP.utf8"
LC_NAME="ja_JP.utf8"
LC_ADDRESS="ja_JP.utf8"
LC_TELEPHONE="ja_JP.utf8"
LC_MEASUREMENT="ja_JP.utf8"
LC_IDENTIFICATION="ja_JP.utf8"
LC_ALL=

      ⇒ロケールが日本語(ja_JP.utf8)に変更されます

 

(4)軽~く確認

$ hogehoge
-bash: hogehoge: コマンドが見つかりません

      ⇒エラーメッセージが日本語になります

 

ちなみに端末内で利用できるロケール一覧は「locale -a」で見れます。