Category Archives: Linux

CentOS7でredis4.0.2をインストールする

1.redisのインストール
#cd
#wget http://download.redis.io/releases/redis-4.0.2.tar.gz
#tar xzf redis-4.0.2.tar.gz
#mv redis-4.0.2 /usr/local/redis-4.0.2
#cd /usr/local/redis-4.0.2
#make
#make install
#redis-server redis.conf
#redis-cli
ps -ef | grep redis

2.Dockerの設定
#docker version
#docker pull redis
#docker run –name payredis -d redis
#docker run –rm -it –link payredis:redis redis /bin/bash
#redis-cli -h redis -p 6379

CentOS7.4にDockerをインストールする

1.既存Dockerを削除
# sudo yum remove docker docker-common docker-selinux docker-engine

2.必要なパッケージをインストール
# sudo yum install -y yum-utils device-mapper-persistent-data lvm2
中略
Dependency Installed:
device-mapper-event.x86_64 7:1.02.140-8.el7
device-mapper-event-libs.x86_64 7:1.02.140-8.el7
libxml2-python.x86_64 0:2.9.1-6.el7_2.3
lvm2-libs.x86_64 7:2.02.171-8.el7
python-chardet.noarch 0:2.2.1-1.el7_1
python-kitchen.noarch 0:1.1.1-5.el7

Complete!

3.レポジトリを追加
# sudo yum-config-manager –add-repo https://download.dock
er.com/linux/centos/docker-ce.repo
Loaded plugins: fastestmirror, langpacks
adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo

4.パッケージインデックスを更新
# sudo yum makecache fast
Loaded plugins: fastestmirror, langpacks
base | 3.6 kB 00:00
centosplus | 2.9 kB 00:00
docker-ce-stable | 2.9 kB 00:00
epel/x86_64/metalink | 6.8 kB 00:00
extras | 3.4 kB 00:00
nginx | 2.9 kB 00:00
remi-safe | 2.9 kB 00:00
updates | 3.4 kB 00:00
docker-ce-stable/x86_64/primary_db | 9.3 kB 00:00
Loading mirror speeds from cached hostfile
* epel: mirror.dmmlabs.jp
* remi-safe: mirrors.tuna.tsinghua.edu.cn
Metadata Cache Created

5.Dockerインストール
# sudo yum install docker-ce-17.06.0.ce-1.el7.centos
中略
Installed:
docker-ce.x86_64 0:17.06.0.ce-1.el7.centos

Dependency Installed:
container-selinux.noarch 2:2.21-2.gitba103ac.el7
iptables.x86_64 0:1.4.21-18.0.1.el7.centos
libmnl.x86_64 0:1.0.3-7.el7
libnetfilter_conntrack.x86_64 0:1.0.6-1.el7_3
libnfnetlink.x86_64 0:1.0.1-4.el7
libseccomp.x86_64 0:2.3.1-3.el7
selinux-policy.noarch 0:3.13.1-166.el7_4.4
selinux-policy-targeted.noarch 0:3.13.1-166.el7_4.4

6.起動
#sudo systemctl start docker

確認
#sudo docker run hello-world
Unable to find image ‘hello-world:latest’ locally
latest: Pulling from library/hello-world
5b0f327be733: Pull complete
Digest: sha256:07d5f7800dfe37b8c2196c7b1c524c33808ce2e0f74e7aa00e603295ca9a0972
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the “hello-world” image from the Docker Hub.
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
https://cloud.docker.com/

For more examples and ideas, visit:
https://docs.docker.com/engine/userguide/

Dockerを自動起動
#sudo systemctl enable docker

 

「Linux入門」atqで実行待ちjobを表示する


at now + 10 minutes
at> echo 1111
at> <eot>
job 3 at Fri Apr 26 12:56:00 2015
atq
3 Fri Apr 26 12:56:00 2015 a root

xxx is not in the sudoers file.This incident will be reportedの解決方法

エラーメッセージ:
yamada_user is not in the sudoers file. This incident will be reported.

解決方法
#chmod u+w /etc/sudoers
#vi /etc/sudoers

## Allow root to run any commands anywhere
root ALL=(ALL) ALL
追記
yamada_user ALL=(ALL) ALL

「CentOS7入門」tarコマンドの使い方

1.tarで圧縮ファイルを作成
$ tar zcvf 作成するファイル名 対象ディレクトリ・ファイル
# tar zcvf testbak.tar.gz test/
test/
test/aa.php
test/aa.html
#ls

2.tarで圧縮ファイルを展開
$ tar zxvf 圧縮ファイル
# tar zxvf testbak.tar.gz
test/
test/aa.php
test/aa.html

 

3.圧縮ファイルの中身のファイル一覧を表示
$ tar tzf 圧縮ファイル
#tar tzf testbak.tar.gz
test/
test/aa.php
test/aa.html

4.特定のファイルのみ展開
$ tar zxvf 圧縮ファイル 対象ファイル
# tar zxvf testbak.tar.gz test/aa.php
test/aa.php

「CentOS7」ip aコマンドでIPアドレスを取得する

ipコマンド
# ip a | grep inet | grep -v inet6 | grep -v 127 | sed ‘s/^[ \t]*//g’ | cut -d ‘ ‘ -f2
結果
xxx.xxx.181.55/23

CentOS7.3.1611でポートを解放する

ポートを解放
firewall-cmd –zone=public –add-port=80/tcp –permanent
firewall-cmd –add-port=22/tcp –zone=public –permanent

ファイアウォールを再起動
systemctl restart firewalld

利用しているポートを確認
lsof -i tcp:80

ポートの一覧を表示
netstat -ntlp

CentOS7.4でIPコマンドをメモする

1.環境の確認
# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)

2.IPコマンド

# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 9c:a3:ba:01:e1:a5 brd ff:ff:ff:ff:ff:ff
inet xxx.xxx.xxx.55/23 brd xxx.xxx.xxx.255 scope global eth0
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 9c:a3:ba:03:68:45 brd ff:ff:ff:ff:ff:ff
4: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 9c:a3:ba:04:ee:e5 brd ff:ff:ff:ff:ff:ff

 

3.特定デバイスの状態確認
ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet xxx.xxx.xxx.55 netmask 255.255.254.0 broadcast xxx.xxx.xxx.255
ether 9c:a3:ba:01:e1:a5 txqueuelen 1000 (Ethernet)
RX packets 14156471 bytes 920928982 (878.2 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3618059 bytes 4088711994 (3.8 GiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

4.デバイスごとのパケット処理数
# netstat -i
Kernel Interface table
Iface MTU RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0 1500 14159495 0 0 0 3618824 0 0 0 BMRU
eth1 1500 0 0 0 0 0 0 0 0 BMRU
eth2 1500 0 0 0 0 0 0 0 0 BMRU
lo 65536 1583651 0 0 0 1583651 0 0 0 LRU

CentOS7にlshwでディスクの型番を取得する

# yum install lshw
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* remi-safe: mirror.bebout.net
Resolving Dependencies
–> Running transaction check
—> Package lshw.x86_64 0:B.02.17-12.el7 will be installed
–> Processing Dependency: hwdata for package: lshw-B.02.17-12.el7.x86_64
–> Running transaction check
—> Package hwdata.x86_64 0:0.252-8.4.el7 will be installed
–> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
lshw x86_64 B.02.17-12.el7 base 286 k
Installing for dependencies:
hwdata x86_64 0.252-8.4.el7 base 2.1 M

Transaction Summary
================================================================================
Install 1 Package (+1 Dependent package)

Total download size: 2.4 M
Installed size: 13 M
Is this ok [y/d/N]: y
Downloading packages:
(1/2): lshw-B.02.17-12.el7.x86_64.rpm | 286 kB 00:00
(2/2): hwdata-0.252-8.4.el7.x86_64.rpm | 2.1 MB 00:00
——————————————————————————–
Total 5.3 MB/s | 2.4 MB 00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : hwdata-0.252-8.4.el7.x86_64 1/2
Installing : lshw-B.02.17-12.el7.x86_64 2/2
Verifying : lshw-B.02.17-12.el7.x86_64 1/2
Verifying : hwdata-0.252-8.4.el7.x86_64 2/2

Installed:
lshw.x86_64 0:B.02.17-12.el7

Dependency Installed:
hwdata.x86_64 0:0.252-8.4.el7

Complete!

# sudo lshw -c disk
*-cdrom
description: SCSI CD-ROM
physical id: 0.0.0
bus info: scsi@1:0.0.0
logical name: /dev/cdrom
logical name: /dev/sr0
capabilities: audio
configuration: status=nodisc
*-virtio3
description: Virtual I/O device
physical id: 0
bus info: virtio@3
logical name: /dev/vda
size: 200GiB (214GB)
capabilities: gpt-1.00 partitioned partitioned:gpt
configuration: driver=virtio_blk guid=24e50a8f-eb81-4573-9f30-1084d97ebbc2 logicalsectorsize=512 sectorsize=512

「Linux」ワイルドカード(* ?)を利用するメモ

サンプルコード1(*)
$ ls
test.txt test1 test2 test3 index.php error.log
$ rm test*
$ ls
index.php error.log

 

サンプルコード2(?)
$ ls
test01 test02 test03 test04 test11 test12 test13 test14
$ rm test?4
$ ls
test01 test02 test03 test11 test12 test13

1 / 3612345...102030...最後 »