MySQL の root パスワードをリセットする

MySQL の root パスワードが?になったときの対応

LIGincさん のページを参考にさせていただきました!

◆下のように root のパスワードが受け付けられなくなったときのお話しです。
[root@***]# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)

◆起動している MySQL を停止する
[root@***]# service mysqld stop
mysqld を停止中:                                           [  OK  ]

◆MySQLをセーフモードで起動する
[root@***]# mysqld_safe –skip-grant-tables &
[2] 676
[1]   Exit 127                mysql_safe –skip-grant-tables
Starting mysqld daemon with databases from /var/lib/mysql

◆MySQL へ root でログインする
[root@***]# mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.95 Source distribution

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

◆root の新しいパスワードをセットする
mysql> use mysql;
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> update user set password=PASSWORD(“パスワード”) where User=’root’;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> quit;
Bye

◆セーフモードの MySQL を停止する
[root@***]# service mysqld stop
STOPPING server from pid file /var/run/mysqld/mysqld.pid
160318 11:14:26  mysqld ended

mysqld を停止中:                                           [  OK  ]
[2]+  Done                    mysqld_safe –skip-grant-tables

◆MySQL を起動する
[root@***]# service mysqld start
mysqld を起動中:                                           [  OK  ]

Autodesk製品のネットワークライセンス認証を linux で行う場合の設定

Autodesk製品のネットワークライセンス認証を linux で行う場合の設定

Network License Manager を使う環境は、以下のとおりです。
# cat /etc/redhat-release
CentOS release 6.6 (Final)
# uname -a
Linux pub.edd.osaka-sandai.ac.jp 2.6.32-504.16.2.el6.x86_64 #1 SMP Wed Apr 22 06:48:29 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

■認証システムのダウンロード
以下のサイトより、nlm11.12.1.4_ipv4_linux64 をダウンロードします。gz(gz – 3328 Kb)
Linux 用の Autodesk IPv4 Network License Manager のダウンロード
http://knowledge.autodesk.com/support/autocad/troubleshooting/caas/downloads/content/autodesk-ipv4-network-license-manager-for-linux.html

■インストール方法
以下のページを参考にし、インストールします。
Autodesk Network License Manager IPv4 Support Readme for 64-bit Linux
http://knowledge.autodesk.com/sites/default/files/file_downloads/nlm11.12.1.4_ipv4_Linux64_readme.htm

(1). ダウンロードしたファイルを Unzip します。
    # tar -zxvf nlm11.12.1.4_ipv4_linux64.tar.gz

(2). Unzip で解凍すると”nlmipv4support_linux64.rpm”となるので以下のコマンドでインストールします。
    # rpm -vhi nlmipv4support_linux64.rpm

(3). インストールすると、”/opt/flexnetserver”内にシステムが展開されます。
    # ls -l /opt/flexnetserver/
    合計 6884
    -r–r–r– 1 root root 2399866 1月 20 16:23 2015 LicenseAdministration.pdf
    -r-xr-xr-x 1 root root 1768448 1月 20 16:23 2015 adskflex*
    -r-xr-xr-x 1 root root 1509304 1月 20 16:23 2015 lmgrd*
    -r-xr-xr-x 1 root root 1315848 1月 20 16:23 2015 lmutil*

オートデスク製品の登録とアクティベーションを行うと、ライセンスファイルを入手できますので、
ここでは、”autodesk2014.lic“というファイルに保存しました。
“*****.lic”というように、ファイル名を設定します。
    # ls -l /opt/flexnetserver
    合計 6884
    -r–r–r– 1 root root 2399866 1月 20 16:23 2015 LicenseAdministration.pdf
    -r-xr-xr-x 1 root root 1768448 1月 20 16:23 2015 adskflex*
    -rw-r–r– 1 root root 2125 5月 22 19:12 2015 autodesk2014.lic
    -r-xr-xr-x 1 root root 1509304 1月 20 16:23 2015 lmgrd*
    -r-xr-xr-x 1 root root 1315848 1月 20 16:23 2015 lmutil*
    -rw-r–r– 1 root root 103 5月 22 19:42 2015 start.sh

・起動用シェル・ファイルの作成
    # vi start.sh
    /opt/flexnetserver/lmgrd -c /opt/flexnetserver/autodesk2014.lic -l /opt/flexnetserver/autodesk2014.log

・起動の方法
    # sh start.sh

・停止用シェル・ファイルの作成
    # vi stop.sh
     /opt/flexnetserver/lmutil lmdown -q -force

停止の方法
    # sh stop.sh

root のパスワード忘れ

世の中、いろんな事情でパスワードを忘れてしまうことがあります。

私は、今日インストールしたての linuxサーバーのパスワードを忘れてしまいました。

忘れるというよりは、パスワード設定が恐らくデタラメだったのか、適当に入力していたのでしょう!
でっ、今までは再インストールという最悪なことをしていた訳なんですが、ググってみると回避方法はあるもんです。
GRUBの起動時にシングルユーザー・モードで起動するようにチョイと変更すれば、root のパスワードは簡単に変更できました。
http://itpro.nikkeibp.co.jp/article/COLUMN/20061030/252224/

それより、昨夜はまってしまった、困ったことがあります。
PostgreSQLのデータベースを dump をとらないで新しいサーバに tarファイルで持って行ってしまったのです。
同じ環境にすれば大丈夫かな~と安易な考えでやってしまったのが間違いの元でした。

元のサーバは起動できなくなるし、さっ困ったな~

samba4のインストール

CentOS 6.4 に samba4 をインストールした。

まず、samba 3.6.9 をアンインストールする。
# yum -y remove samba samba-winbind-clients samba-client samba-winbind samba-common

次に、samba4 のrpmパッケージを置いている wing-net より repoファイルを持ってきて、yum install できるように repoファイルを enabled=1 に変更します。
# wget http://wing-net.ddo.jp/wing/6/EL6.wing.repo
# mv EL6.wing.repo /etc/yum.repos.d/
# vi /etc/yum.repos.d/EL6.wing.repo

さらに libbsd が無いと言ってくるので、ライブラリをインストールします。
# wget http://ftp.riken.jp/Linux/fedora/epel/6/x86_64/libbsd-0.6.0-1.el6.x86_64.rpm
# wget http://ftp.riken.jp/Linux/fedora/epel/6/x86_64/libbsd-devel-0.6.0-1.el6.x86_64.rpm
# rpm -ivh libbsd-0.6.0-1.el6.x86_64.rpm libbsd-devel-0.6.0-1.el6.x86_64.rpm

以上で準備が整ったので、yum install します。
# yum -y install samba4 samba4-python python-tdb libtalloc samba4-libs samba4-clients ldb-tools krb5-wowrkstation

特殊パーミッションの変更

CentOS 6 でパーミッションに「.」がつくようになったそうだ。
selinux 管理下にあるものがつくらしい。

[root@**** ~]# ls -ld /home
drwxr-xr-x. 14 root root 4096 8月 19 12:15 2013 /home/

tkak’s tech blog」に掲載されていました。
http://tkak.hatenablog.com/entry/2013/01/04/151248

まとめて、「.」を取り除くためには、
# find /home/data -exec setfattr -x security.selinux {} \;
のようにすれば、”/home/data” 内の全てのファイルやディレクトリについて、
「.」を取ってくれそうです。

ownCloud インストールに関するメモ

◆ownCloud 5.0.9 をインストールしたサーバー環境

 ・CPU:  Core i7 870
 ・Mem: 16GB
 ・HD:    600GB + 1TB x 2
 ・OS:    CentOS 6.4  x86_64
 ・Apache: httpd-2.2.15-28.el6.centos.x86_64
 ・PHP: php-5.4.17-2.el6.remi.x86_64(php-5.3.3-23.el6_4.x86_64 から update)
 ・MySQL: mysql-5.5.33-1.el6.remi.x86_64(mysql-5.1.69-1.el6_4.x86_64 から update)

 PHP と MySQL については、標準の PHP ではセキュリティ警告が出る。 MySQLは、新しいバージョンのほうが処理速度が速いという理由でアップデートした。
 そのためには、”yum-plugin-priorities” をインストールして RPMforgeリポジトリや “epel”, “remi” リポジトリをインストールする必要があった。
参照ページ:
 ・http://www.begood-tech.com/small-material-or-thoughts/owncloud/owncloud-%E3%82%92-server-edition-%E3%81%A7%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB.html
 ・http://www.galileo.co.jp/blogs/dv/archives/2012-02-17-08-30-33.html#more-49

◇◆◇ 設定の変更 ◇◆◇

◆”/etc/php.ini”の変更内容 (オレンジが変更値

(参照ページ)http://ml.php.gr.jp/pipermail/php-users/2013-April/036289.html

; Maximum execution time of each script, in seconds
max_execution_time = 30

; Maximum amount of time each script may spend parsing request data. It’s a good
; idea to limit this time on productions servers in order to eliminate unexpectedly
; long running scripts.
; Default Value: -1 (Unlimited)
; Development Value: 60 (60 seconds)
; Production Value: 60 (60 seconds)
max_input_time = 60

; Default timeout for socket based streams (seconds)
default_socket_timeout = 60

; Maximum amount of memory a script may consume (128MB)
memory_limit = 128M

; Maximum size of POST data that PHP will accept.
post_max_size = 8M

; Maximum allowed size for uploaded files.
upload_max_filesize = 2M

max_execution_time = 3000
max_input_time = 6400
default_socket_timeout = 6000
memory_limit = 2048M
post_max_size = 16G
upload_max_filesize = 16G

◆”***/owncloud/data/.htaccess”の変更内容(オレンジが変更値

(参照ページ)http://www.begood-tech.com/small-material-or-thoughts/owncloud/owncloud-5-%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E3%81%AE%E3%82%A2%E3%83%83%E3%83%97%E3%83%AD%E3%83%BC%E3%83%89-%E3%82%A8%E3%83%A9%E3%83%BC.html

<IfModule mod_fcgid.c>
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
SetEnvIfNoCase ^Authorization$ “(.+)” XAUTHORIZATION=$1
RequestHeader set XAuthorization %{XAUTHORIZATION}e env=XAUTHORIZATION
</IfModule>
</IfModule>
</IfModule>
ErrorDocument 403 /core/templates/403.php
ErrorDocument 404 /core/templates/404.php
<IfModule mod_php5.c>
 php_value upload_max_filesize 512M
 php_value post_max_size 512M
 php_value memory_limit 512M
<IfModule env_module>
  SetEnv htaccessWorking true
</IfModule>
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule .* – [env=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteRule ^.well-known/host-meta /public.php?service=host-meta [QSA,L]
RewriteRule ^.well-known/host-meta.json /public.php?service=host-meta-json [QSA,L]
RewriteRule ^.well-known/carddav /remote.php/carddav/ [R]
RewriteRule ^.well-known/caldav /remote.php/caldav/ [R]
RewriteRule ^apps/calendar/caldav.php remote.php/caldav/ [QSA,L]
RewriteRule ^apps/contacts/carddav.php remote.php/carddav/ [QSA,L]
RewriteRule ^apps/([^/]*)/(.*\.(css|php))$ index.php?app=$1&getfile=$2 [QSA,L]
RewriteRule ^remote/(.*) remote.php [QSA,L]
</IfModule>
<IfModule mod_mime.c>
AddType image/svg+xml svg svgz
AddEncoding gzip svgz
</IfModule>
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
AddDefaultCharset utf-8
Options -Indexes

<IfModule mod_php5.c>
 php_value upload_max_filesize 16G
 php_value post_max_size 16G
 php_value memory_limit -1
 php_value max_execution_time -1
 php_value max_input_time -1
<IfModule env_module>

ClamAVのアップデート

“freshclam”を実行すると以下のようなワーニングが出るようになったので、
“clamd”をアップデートしました。

# freshclam
ClamAV update process started at Tue Jul 23 13:10:43 2013
WARNING: Your ClamAV installation is OUTDATED!
WARNING: Local version: 0.97.7 Recommended version: 0.97.8
DON’T PANIC! Read http://www.clamav.net/support/faq
main.cvd is up to date (version: 54, sigs: 1044387, f-level: 60, builder: sven)
daily.cld is up to date (version: 17553, sigs: 1494916, f-level: 63, builder: guitar)
bytecode.cld is up to date (version: 217, sigs: 42, f-level: 63, builder: neo)

# yum -y –enablerepo=epel update clamd
Loaded plugins: downloadonly, fastestmirror, priorities, refresh-packagekit, security
Loading mirror speeds from cached hostfile
epel/metalink | 6.5 kB 00:00
* base: ftp.iij.ad.jp
* epel: ftp.iij.ad.jp
* extras: ftp.iij.ad.jp
* rpmforge: ftp.riken.jp
* updates: ftp.iij.ad.jp
base | 3.7 kB 00:00
epel | 4.2 kB 00:00
epel/primary_db | 5.4 MB 00:02
extras | 3.4 kB 00:00
rpmforge | 1.9 kB 00:00
updates | 3.4 kB 00:00
93 packages excluded due to repository priority protections
Setting up Update Process
Resolving Dependencies
–> Running transaction check
—> Package clamd.x86_64 0:0.97.7-1.el6.rf will be updated
—> Package clamd.x86_64 0:0.97.8-1.el6 will be an update
–> Processing Dependency: clamav = 0.97.8-1.el6 for package: clamd-0.97.8-1.el6.x86_64
–> Running transaction check
—> Package clamav.x86_64 0:0.97.7-1.el6.rf will be updated
—> Package clamav.x86_64 0:0.97.8-1.el6 will be an update
–> Processing Dependency: clamav-db = 0.97.8-1.el6 for package: clamav-0.97.8-1.el6.x86_64
–> Running transaction check
—> Package clamav-db.x86_64 0:0.97.7-1.el6.rf will be updated
—> Package clamav-db.x86_64 0:0.97.8-1.el6 will be an update
–> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================
Package Arch Version Repository Size
=============================================================================================================================
Updating:
clamd x86_64 0.97.8-1.el6 epel 132 k
Updating for dependencies:
clamav x86_64 0.97.8-1.el6 epel 10 M
clamav-db x86_64 0.97.8-1.el6 epel 56 M

Transaction Summary
=============================================================================================================================
Upgrade 3 Package(s)

Total download size: 67 M
Downloading Packages:
(1/3): clamav-0.97.8-1.el6.x86_64.rpm | 10 MB 00:04
(2/3): clamav-db-0.97.8-1.el6.x86_64.rpm | 56 MB 00:27
(3/3): clamd-0.97.8-1.el6.x86_64.rpm | 132 kB 00:00
—————————————————————————————————————————–
Total 2.1 MB/s | 67 MB 00:32
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Updating : clamav-db-0.97.8-1.el6.x86_64 1/6
Updating : clamav-0.97.8-1.el6.x86_64 2/6
warning: /etc/freshclam.conf created as /etc/freshclam.conf.rpmnew
Updating : clamd-0.97.8-1.el6.x86_64 3/6
warning: /etc/clamd.conf created as /etc/clamd.conf.rpmnew
Cleanup : clamd-0.97.7-1.el6.rf.x86_64 4/6
Cleanup : clamav-0.97.7-1.el6.rf.x86_64 5/6
Cleanup : clamav-db-0.97.7-1.el6.rf.x86_64 6/6
Verifying : clamav-0.97.8-1.el6.x86_64 1/6
Verifying : clamd-0.97.8-1.el6.x86_64 2/6
Verifying : clamav-db-0.97.8-1.el6.x86_64 3/6
Verifying : clamav-0.97.7-1.el6.rf.x86_64 4/6
Verifying : clamav-db-0.97.7-1.el6.rf.x86_64 5/6
Verifying : clamd-0.97.7-1.el6.rf.x86_64 6/6

Updated:
clamd.x86_64 0:0.97.8-1.el6

Dependency Updated:
clamav.x86_64 0:0.97.8-1.el6 clamav-db.x86_64 0:0.97.8-1.el6

Complete!
—————————————————————
これで、再度”freshclam”を実行しました。

# freshclam
ClamAV update process started at Tue Jul 23 14:21:35 2013
main.cvd is up to date (version: 54, sigs: 1044387, f-level: 60, builder: sven)
daily.cld is up to date (version: 17554, sigs: 1494938, f-level: 63, builder: neo)
bytecode.cld is up to date (version: 217, sigs: 42, f-level: 63, builder: neo)

ワーニングがなくなりました!

==================================================================
ただし、以下の初期設定ができている必要があります。

◆EPELというFedoraプロジェクトによる外部リポジトリの追加
 # rpm -Uvh http://ftp.iij.ad.jp/pub/linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm

◆純正のパッケージとの競合を避けるため通常は無効にしておく。
 # sed -i ‘s/enabled=1/enabled=0/g’ /etc/yum.repos.d/epel.repo

ftp接続の巻

きょうの授業では、htmlファイルをアップするためのftp接続ができなく、
ある意味授業崩壊になってしまった。

一部の学生は接続できるのに、多くの学生が接続できない現象。

う~ 何だろ?

4月から新しいサーバに移行したので、vsftpd.confの設定に問題がある
ことは分かるのだが・・・

でっ、vi でvsftpd.confを見てみると、PASVモードで接続するための
ポートが30ポートしかない。

な~んだ、これが原因だったのか~

思い切って、61000-61500の範囲で確保。
これで、ポートが足りないってことはないでしょう!

同時に、iptablesでもポートを開けたから、これでOKかな~

学生さん、ごめんなさい!

SquirrelMail でログインできない問題

SquirrelMail でログインすると、次のメッセージが表示されてログインできない問題。
ERROR: Connection dropped by IMAP server.

今回は、/var/log/maillog で以下のようなエラーログを発見。
これは、dovecot の config file の中にある first_valid_uid に問題があるという指摘だ。
hostname dovecot: imap(username): Error: user username: Couldn’t drop privileges: Mail access for users with UID 217 not permitted (see first_valid_uid in config file).

OS が CentOS 6.4 なので、
# vi /etc/dovecot/conf.d/10-mail.conf
/first_valid_uid で探すと、uid が 500 以上がデフォルト値になっているため uid が 217 であれば弾かれていたのだ。
そこで、# を解除して以下のように変更し /etc/init.d/dovecot restart すれば、正常にログインができた。
#first_valid_uid = 500
 ↓
first_valid_uid = 200