Category Archives: Linux

CentOS7.4に「Another app is currently holding the yum lock」の解決方法

エラーメッセージ
Another app is currently holding the yum lock; waiting for it to exit…
The other application is: yum
Memory : 105 M RSS (1.4 GB VSZ)
Started: Sat Apr 7 15:57:39 2018 – 1:35:56 ago
State : Sleeping, pid: 15014

解決方法
#rm -rf /var/run/yum.pid
#yum update

CentOS7.4.1708にJDK9、Tomcat9.0.06をインストールするメモ

1.JDK9のインストール
ダウンロードURL
http://www.oracle.com/technetwork/java/javase/downloads/jdk9-downloads-3848520.html
# cd /usr/local/src
# rpm -ivh jdk-9_linux-x64_bin.rpm

環境変数の設定
$ vim .bash_profile
+ JRE_HOME=/usr/java/default
+ CATALINA_HOME=/opt/tomcat/apache-tomcat-9.0.6
+ export JRE_HOME CATALINA_HOME

環境変数の反映
$ source .bash_profile
# java –version

2.Tomcat9のインストール
ダウンロードURL
https://tomcat.apache.org/download-90.cgi

tomcatユーザの作成
# useradd -s /sbin/nologin tomcat

tomcatファイルの展開、移動
# cd /usr/local/src
$ tar -xvzf apache-tomcat-9.0.6.tar.gz
$ sudo mv apache-tomcat-9.0.6 /opt/tomcat/

環境変数の設定
$ vim .bash_profile
+ JRE_HOME=/usr/java/default
+ CATALINA_HOME=/opt/tomcat/apache-tomcat-9.0.6
+ export JRE_HOME CATALINA_HOME

環境変数の反映
$ source .bash_profile

3.8080ポートを解放
# firewall-cmd –zone=public –add-port=8080/tcp –permanent
# firewall-cmd –reload
# firewall-cmd –list-all

4.Tomcatバージョンの確認
# /opt/tomcat/apache-tomcat-9.0.6/bin/version.sh

CentOS/RHEL 7/6/5にMySQLをインストールするメモ

1.MySQLYumの追加
For CentOS/RHEL 7
# rpm -Uvh http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm

For CentOS/RHEL 6
# rpm -Uvh http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm

For CentOS/RHEL 5
# rpm -Uvh http://repo.mysql.com/mysql-community-release-el5-5.noarch.rpm

For Fedora 20
# rpm -Uvh http://repo.mysql.com/mysql-community-release-fc20-5.noarch.rpm

For Fedora 19
# rpm -Uvh http://repo.mysql.com/mysql-community-release-fc19-5.noarch.rpm

For Fedora 18
# rpm -Uvh http://repo.mysql.com/mysql-community-release-fc18-5.noarch.rpm

2.MySQLのインストール
# yum install mysql-community-server

3.MySQL起動
CentOS/RHEL 6/5の場合
# service mysqld start
# service mysqld status
# service mysqld stop

CentOS/RHEL 7の場合
# systemctl status mysqld
# systemctl stop mysqld

4.MySQLの設定
# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we’ll need the current
password for the root user. If you’ve just installed MySQL, and
you haven’t set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on…

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

You already have a root password set, so you can safely answer ‘n’.

Change the root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
… Success!

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? [Y/n] 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? [Y/n] 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? [Y/n] 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? [Y/n] y
… Success!

Cleaning up…

All done! If you’ve completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!

5.mysqlに接続
CentOS/RHEL 6/5の場合
# service mysqld restart

CentOS/RHEL 7の場合
# systemctl restart mysqld
# chkconfig mysqld on
# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 51
Server version: 5.5.34 MySQL Community Server (GPL) by Remi

Copyright (c) 2000, 2013, 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>

ubuntu17.10にdocker-ceをインストールするメモ

インストール手順
#sudo apt-get update
#sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
#curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add –
#sudo apt-key fingerprint 0EBFCD88

#sudo add-apt-repository “deb [arch=amd64] https://download.docker.com/linux/ubuntu zesty stable”

#sudo apt-get update
#sudo apt-get install docker-ce

CentOSに自動マウント(mount)を設定する方法

1./etc/rc.local
mount -o acl,grpquota,usrquota,rw,sync /dev/sda5 /mnt/

2./etc/fstab
/dev/sda6 /opt ext3 defaults,rw,acl 0 0
mount -a

3.autofs
1) vim /etc/auto.master
/test /etc/auto.test

2) mkdir /test
touch /etc/auto.test

3) vim /etc/auto.test
disk7 -fstype=ext3,rw :/dev/sda7

4)service autofs restart

テスト
cd /test/disk7
ls /test/disk7
mount
watch -n 1 mount

「CentOS7入門」SSH公開鍵・秘密鍵の作成、転送のコマンド

1.SSH接続
#ssh root@xxx.xxx.xxx.xxx

2.ユーザー追加とパスワード設定
# useradd yamada_user
# passwd yamada_pwd
# usermod -G wheel yamada_user

3.SELinuxをOffに設定
#vim /etc/selinux/config
/etc/selinux/config
SELINUX=enforcing
↓ 修正
SELINUX=disabled

4.sudo権限付与
# visudo
## Allows people in group wheel to run all commands
# %wheel ALL=(ALL) ALL
↓ コメントアウト外す
%wheel ALL=(ALL) ALL

5.sshdの設定
$ sudo vi /etc/ssh/sshd_config
sshd設定項目
/etc/ssh/sshd_config
#ポート設定
Port 40198

#rootログイン設定
PermitRootLogin no

#鍵認証
RSAAuthentication yes
PubkeyAuthentication yes

PasswordAuthentication yes

6.公開鍵・秘密鍵の作成、転送
$ mkdir ~/.ssh
$ chmod 700 ~/.ssh
$ scp -i /usr/local/src/publickey/ yamada_user@xxx.xxx.xxx.xxx:~/.ssh/authorized_keys
$ chmod 600 ~/.ssh/authorized_keys

「CentOS入門」shell圧縮·解凍コマンド(tar、lha、bz2)のメモ

.tar
書庫化:tar xvf FileName.tar
展開:tar cvf FileName.tar DemoName

.gz
解凍1:gunzip FileName.gz
解凍2:gzip -d FileName.gz
圧縮:gzip FileName

.tar.gz 和 .tgz
解凍:tar zxvf FileName.tar.gz
圧縮:tar zcvf FileName.tar.gz DemoName

.bz2
解凍1:bzip2 -d FileName.bz2
解凍2:bunzip2 FileName.bz2
圧縮: bzip2 -z FileName

.tar.bz2
解凍:tar jxvf FileName.tar.bz2
圧縮:tar jcvf FileName.tar.bz2 DemoName

.Z
解凍:uncompress FileName.Z
圧縮:compress FileName
.tar.Z

解凍:tar Zxvf FileName.tar.Z
圧縮:tar Zcvf FileName.tar.Z DemoName

.zip
解凍:unzip FileName.zip
圧縮:zip FileName.zip DemoName

.rar
解凍:rar x FileName.rar
圧縮:rar a FileName.rar DemoName

.lha
解凍:lha -e FileName.lha
圧縮:lha -a FileName.lha FileName

.rpm
書庫化:rpm2cpio FileName.rpm | cpio -div

.deb
書庫化:ar p FileName.deb data.tar.gz | tar zxf –

ubuntuにmysql pycharm sublimeをインストールするメモ

1.ubuntuにmysqlのインストール
sudo netstat -tap|grep mysql
sudo apt-get install mysql-server
apt-get update

MySQLにログイン
MySQL -u root -p

2.Ubuntuにpycharmのインストール
ダウンロード:
http://www.jetbrains.com/pycharm/download/#section=linux,,
ファイル:pycharm-community-2017.3.3.tar.gz

tar -xvzf pycharm-community-2017.2.3.tar.gz -C~
sh pycharm.sh

3.Ubuntuにsublimeのインストール
sudo add-apt-repository ppa:webupd8team/sublime-text-3
sudo apt-get update
sudo apt-get install sublime-text-installer

sublime起動
subl

sublimeアンインストール
sudo apt-get remove sublime-text-installer

CentOS7にfirewalld の使い方

Firewallのインストール
#yum install firewalld firewalld-config

Firewallでポートを許可
#firewall-cmd –zone=public –add-port=80/tcp –permanent
#firewall-cmd –zone=public –add-port=443/tcp –permanent
#firewall-cmd –zone=public –add-port=22/tcp –permanent
#firewall-cmd –zone=public –add-port=21/tcp –permanent
#firewall-cmd –zone=public –add-port=53/udp –permanent

Firewallでポートを閉じる
#firewall-cmd –zone=public –remove-port=80/tcp –permanent
#firewall-cmd –zone=public –remove-port=443/tcp –permanent
#firewall-cmd –zone=public –remove-port=22/tcp –permanent
#firewall-cmd –zone=public –remove-port=21/tcp –permanent
#firewall-cmd –zone=public –remove-port=53/udp –permanent

Firewallで複数ポートを追加
#firewall-cmd –zone=public –add-port=4400-4600/udp –permanent
#firewall-cmd –zone=public –add-port=4400-4600/tcp –permanent

Firewallを有効する
#systemctl start firewalld.service

Firewallを再起動する
#firewall-cmd –reload 或者 service firewalld restart

ポートリストを確認する
#firewall-cmd –permanent –list-port

ポートを禁止
#systemctl stop firewalld

自動起動を有効
#systemctl enable firewalld

自動起動を無効
sytemctl disable firewalld

ステータスを確認
systemctl status firewalld
firewall-cmd –state

CentOS7にgo1.8.1をインストールするメモ

1.go1.8.1をインストール
$ cd /usr/local/src
$ sudo tar -C /usr/local -xzf go1.8.1.linux-amd64.tar.gz

2.PATHを設定
~/.bash_profile
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin
export PATH=$PATH:/usr/local/go/bin

3.hello.go
package main
import “fmt”

func main() {
fmt.Printf(“hello, world\n”)
}