2014年1月29日 星期三

[研究] MySQL 5.1.71 資料庫同步(Replication)-雙機互備模式(CentOS 6.5 x86_64)

[研究] MySQL 5.1.71 資料庫同步(Replication)-雙機互備模式(CentOS 6.5 x86_64) 

2014-01-29
Lu

參考
16.1.1. How to Set Up Replication
http://dev.mysql.com/doc/refman/5.1/en/replication-howto.html

server1 : CentOS 6.5 x86_64 , IP: 192.168.128.101
server2 : CentOS 6.5 x86_64 , IP: 192.168.128.102

CentOS 6.5 的 MySQL 是 5.1.71 版

[root@centos1 ~]# yum list | grep mysql-server
mysql-server.x86_64                       5.1.71-1.el6                   base
[root@centos1 ~]#

----------------------------------------------------------------------------

先在兩台上都安裝啟動 MySQL,暫時先關閉防火牆

yum  -y  install  mysql  mysql-server
service  mysqld  start
chkconfig  mysqld  on
# 替 MySQL 帳號 root 設定密碼為 123456 (依個人喜好)
/usr/bin/mysqladmin -u root password '123456'
service  iptables  stop

----------------------------------------------------------------------------

Server1 上

1. 建立同步用帳號和要同步的資料庫,讓另一台主機192.168.128.102上的root帳號在這台上有REPLICATION SLAVE權限

[root@server1 ~]# mysql 

mysql> CREATE USER 'root'@'192.168.128.102' IDENTIFIED BY '';
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT REPLICATION SLAVE ON *.*  TO 'root'@'192.168.128.102';

mysql> GRANT FILE ON *.*  TO 'root'@'192.168.128.102';

mysql> GRANT ALL PRIVILEGES ON *.*  TO 'root'@'192.168.128.102';

讓權限設定生效(或重新啟動MySQL也可)
mysql> FLUSH PRIVILEGES;

建立新的空資料庫(稱為backup)
mysql> create database backup;

mysql> \q


2. 修改 /etc/my.cnf,在[mysqld]中增加下面資訊

[mysqld]
server-id=1

log-bin=mysql-bin
binlog-do-db=backup 

#定期去192.168.128.102抓資料
master-host=192.168.128.102
master-user=root
master-password=
master-port=3306
master-connect-retry=60
replicate-do-db=backup


2.重新啟動資料庫讓my.cnf生效


[root@server1 ~]# service mysqld restart

PS : 因為 Server2 尚未設定,所以/var/log/mysqld.log可能有錯誤
等 Server2 設定完,重新啟動後,可以再重新啟動一次Server1

----------------------------------------------------------------------------

Server2 上

1. 建立同步用帳號和要同步的資料庫,讓另一台主機192.168.128.101上的root帳號在這台上有REPLICATION SLAVE權限

[root@server1 ~]# mysql 

mysql> CREATE USER 'root'@'192.168.128.101' IDENTIFIED BY '';
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT REPLICATION SLAVE ON *.*  TO 'root'@'192.168.128.101';
Query OK, 0 rows affected (0.00 sec)

2. 修改 /etc/my.cnf,在[mysqld]中增加下面資訊
(注意,log-bin的設定值不可和Server1上相同)

[mysqld]
server-id=2
log-bin=mysql-bin2
binlog-do-db=backup 

#定期去192.168.128.101抓資料
master-host=192.168.128.101
master-user=root
master-password=
master-port=3306
master-connect-retry=60
replicate-do-db=backup

2.重新啟動資料庫

[root@server2 ~]# service mysqld restart

Server1 的再啟動一次

[root@server1 ~]# service mysqld restart

----------------------------------------------------------------------------

可以在兩台機器中任何一台的 backup 資料庫中新增Table或資料,另外一台應該也會出現。

如果失敗
請把Server1上mysql-bin.* 和 mysqld-relay-bin.* 全砍
請把Server2上mysql-bin2.* 和 mysqld-relay-bin.* 全砍

rsync -rvlHpogDtS --delete -e ssh   /var/lib/mysql/.  root@192.168.128.102:/var/lib/mysql/.

重新建立帳號、權限測試

測試部分請參考這篇

[研究] MySQL 5.1.71 資料庫同步(Replication)-主從模式(CentOS 6.5 x86_64) 
(完)

相關

[研究] MySQL 5.1.71 資料庫同步(Replication)-雙機互備模式(CentOS 6.5 x86_64)
http://shaurong.blogspot.com/2014/01/mysql-5171-replication-centos-65-x8664.html
http://forum.icst.org.tw/phpbb/viewtopic.php?f=21&t=80715

[研究] MySQL 5.1.71 資料庫同步(Replication)-主從模式(CentOS 6.5 x86_64) 
http://shaurong.blogspot.com/2014/01/mysql-5171-replication-centos-65-x8664.html
http://forum.icst.org.tw/phpbb/viewtopic.php?f=21&t=80714

[研究] CentOS 5.4 x86 上 MySQL 資料庫同步(Replication)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=17824

[研究] mysql-5.6.15.tar.gz 安裝(CentOS 6.5 x64)
http://shaurong.blogspot.tw/2014/01/mysql-5615targz-centos-65-x64.html
http://forum.icst.org.tw/phpbb/viewtopic.php?f=21&t=80713

[研究] MySQL 5.6.15 安裝(rpm)(CentOS 6.5 x64)
http://shaurong.blogspot.com/2014/01/mysql-5615-rpmcentos-65-x64.html

[研究] MySQL Community 5.6.15 版安裝(yum) (CentOS 6.5 x64)
http://shaurong.blogspot.com/2014/01/mysql-community-5615-tgz-centos-65-x64.html

[研究] 4主機 MySQL Cluster 7.3.3 架設(CentOS 6.5 x64)
http://shaurong.blogspot.tw/2014/01/4-mysql-cluster-7.html

[研究] 4主機 MySQL Cluster 7.2.10.1 架設
http://shaurong.blogspot.tw/2013/02/4-mysql-cluster-7210-1.html

[研究] 2主機 MySQL Cluster 7.2.10-1 架設
http://shaurong.blogspot.com/2013/02/2-mysql-cluster-7210-1.html

[研究] 4主機 MySQL Cluster 7.0.9 架設
http://forum.icst.org.tw/phpbb/viewtopic.php?f=10&t=17903

[研究] 雙主機 MySQL Cluster 7.0.9架設
http://forum.icst.org.tw/phpbb/viewtopic.php?f=10&t=17904

[研究] MariaDB 5.5 安裝(yum)(CentOS 6.3 x64)
http://shaurong.blogspot.com/2013/02/mariadb-55-yum-centos-63-x64.html

[研究] mariadb-5.1.42 (tar.gz)(瑪利亞資料庫, MySQL) 安裝 (CentOS 5.4)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=17988

[研究] mariadb-5.2.4-Linux-i686.tar.gz 安裝 (CentOS 5.5 x86)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=19434

[研究] mysql-5.5.14.tar.gz 安裝(失敗)(CentOS 6.0 x86)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=20252

[研究] mysql-5.5.8.tar.gz 安裝(CentOS 5.5 x86)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=19214

[研究] mysql-5.5.8.tar.gz 安裝(Fedora 14 x86)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=19215

[研究] 每天自動備份 MySQL 方法
http://forum.icst.org.tw/phpbb/viewtopic.php?t=14972

[研究] MySQL 5.1.71 資料庫同步(Replication)-主從模式(CentOS 6.5 x86_64)

[研究] MySQL 5.1.71 資料庫同步(Replication)-主從模式(CentOS 6.5 x86_64) 

2014-01-29
Lu

參考
16.1.1. How to Set Up Replication
http://dev.mysql.com/doc/refman/5.1/en/replication-howto.html

環境:
server1 : CentOS 6.5 x86_64 , IP: 192.168.128.101
server2 : CentOS 6.5 x86_64 , IP: 192.168.128.102

CentOS 6.5 的 MySQL 是 5.1.71 版

[root@centos1 ~]# yum list | grep mysql-server
mysql-server.x86_64                       5.1.71-1.el6                   base
[root@centos1 ~]#


主從模式:A->B (A有新增資料,B也會有)

開始安裝
----------------------------------------------------------------------------

先在兩台上都安裝啟動 MySQL,暫時先關閉防火牆

yum  -y  install  mysql  mysql-server
service  mysqld  start
chkconfig  mysqld  on
# 替 MySQL 帳號 root 設定密碼為 123456 (依個人喜好)
/usr/bin/mysqladmin -u root password '123456'
service  iptables  stop

----------------------------------------------------------------------------

假設要同步的資料庫是 backup

Server1 (MySQL Master, 192.168.128.101)上

1. 建立同步用帳號和要同步的資料庫backup,
讓另一台主機192.168.128.102上的root帳號在這台上有REPLICATION SLAVE權限
(-u 參數後面是帳號,-p 參數後面是密碼)

[root@server1 ~]# mysql -uroot -p123456
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.1.71 Source distribution

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> CREATE USER 'root'@'192.168.128.102' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT REPLICATION SLAVE ON *.*  TO 'root'@'192.168.128.102';
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> create database backup;
Query OK, 1 row affected (0.00 sec)

mysql> \q
Bye
[root@server1 ~]#

mysql> GRANT REPLICATION SLAVE ON *.*  TO 'root'@'192.168.128.102';
可用
mysql> GRANT FILE ON *.*  TO 'root'@'192.168.128.102';

mysql> GRANT ALL PRIVILEGES ON *.*  TO 'root'@'192.168.128.102';
替代

PS :
如果 backup 資料庫已經存在使用,請用 mysqldump 將資料庫匯出,

[root@server1 ~]# mysqldump backup -uroot -p123456 > backup.sql


在 Server2 上把 backup 資料庫匯入,然後進行工作

[root@server2 ~]# mysql backup -uroot -p123456 < backup.sql


否則 Server1 原來 backup 已經存在的資料,是不會同步過去的,只會同步新增的資料

如果要備份整個資料庫,可用

[root@server1 ~]# mysqldump -uroot -p123456 --all-databases --add-drop-database --lock-all-tables > fulldb.sql
[root@server2 ~]# mysql -uroot -p123456 <  fulldb.sql


或把Server2 上/var/lib/mysql中檔案砍光,把 Server1 上 /var/lib/mysql 整個目錄拷貝覆蓋掉 Server2 上的 (MySQL 的版本最好相同,否則可能會毀掉資料庫)

或執行

[root@server1 ~]# rsync -rvlHpogDtS --delete -e ssh   /var/lib/mysql/.  root@192.168.128.102:/var/lib/mysql/.

以本機器/var/lib/mysql完全同步到另一台的

2. 修改 /etc/my.cnf,在[mysqld]中增加server-id和log-bin(這兩個必須),binlog-do-db指定需要日誌的資料庫(非必須)

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

#設定一個編號
server-id=1
#讓別機器同步用的資料寫入此log中
log-bin=mysql-bin
#讓別機器同步用的資料庫backup (不設定這行,表示所有資料庫)
binlog-do-db=backup

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid


3.重新啟動資料庫,讓新建的帳號和my.cnf生效

[root@server1 ~]# service mysqld restart
Stopping mysqld:                                           [  OK  ]
Starting mysqld:                                           [  OK  ]
[root@server1 ~]#


4.檢查日誌情況,應該會顯示某些東西(顯示Empty則失敗)

[root@server1 ~]# mysql -uroot -p123456
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.1.71-log Source distribution

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> show master status;
+------------------+----------+--------------+------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000001 |      106 | backup       |                  |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)

mysql> \q
Bye
[root@server1 ~]#


----------------------------------------------------------------------------

Server2 (MySQL Slave, 192.168.128.102)上

1.建立要同步的資料庫


[root@server2 ~]# mysql -e "create database backup;"  -uroot -p123456

2. 修改 /etc/my.cnf,在[mysqld]中增加下面資訊

[mysqld]
#定期去192.168.128.101抓資料用的帳號、密碼、port、間隔時間、抓哪個資料庫(不設則抓所有資料庫) 
server-id=2
master-host=192.168.128.101
master-user=root
master-password=123456
master-port=3306
master-connect-retry=60
replicate-do-db=backup

3.重新啟動資料庫

[root@server2 ~]# service mysqld restart
Stopping mysqld:                                           [  OK  ]
Starting mysqld:                                           [  OK  ]
[root@server2 ~]#

4.檢查日誌情況,應該會顯示某些東西

(注意,在 server1 指令是 show master status,此處為 slave ) 

[root@server2 ~]# mysql -e "show slave status;" -uroot -p123456
+----------------------------------+-----------------+-------------+-------------+---------------+------------------+---------------------+-------------------------+---------------+-----------------------+------------------+-------------------+-----------------+---------------------+--------------------+------------------------+-------------------------+-----------------------------+------------+------------+--------------+---------------------+-----------------+-----------------+----------------+---------------+--------------------+--------------------+--------------------+-----------------+-------------------+----------------+-----------------------+-------------------------------+---------------+---------------+----------------+----------------+
| Slave_IO_State                   | Master_Host     | Master_User | Master_Port | Connect_Retry | Master_Log_File  | Read_Master_Log_Pos | Relay_Log_File          | Relay_Log_Pos | Relay_Master_Log_File | Slave_IO_Running | Slave_SQL_Running | Replicate_Do_DB | Replicate_Ignore_DB | Replicate_Do_Table | Replicate_Ignore_Table | Replicate_Wild_Do_Table | Replicate_Wild_Ignore_Table | Last_Errno | Last_Error | Skip_Counter | Exec_Master_Log_Pos | Relay_Log_Space | Until_Condition | Until_Log_File | Until_Log_Pos | Master_SSL_Allowed | Master_SSL_CA_File | Master_SSL_CA_Path | Master_SSL_Cert | Master_SSL_Cipher | Master_SSL_Key | Seconds_Behind_Master | Master_SSL_Verify_Server_Cert | Last_IO_Errno | Last_IO_Error | Last_SQL_Errno | Last_SQL_Error |
+----------------------------------+-----------------+-------------+-------------+---------------+------------------+---------------------+-------------------------+---------------+-----------------------+------------------+-------------------+-----------------+---------------------+--------------------+------------------------+-------------------------+-----------------------------+------------+------------+--------------+---------------------+-----------------+-----------------+----------------+---------------+--------------------+--------------------+--------------------+-----------------+-------------------+----------------+-----------------------+-------------------------------+---------------+---------------+----------------+----------------+
| Waiting for master to send event | 192.168.128.101 | root        |        3306 |            60 | mysql-bin.000001 |                 106 | mysqld-relay-bin.000002 |           251 | mysql-bin.000001      | Yes              | Yes               | backup          |                     |                    |                        |                         |                             |          0 |            |            0 |                 106 |             407 | None            |                |             0 | No                 |                    |                    |                 |                   |                |                     0 | No                            |             0 |               |              0 |                |
+----------------------------------+-----------------+-------------+-------------+---------------+------------------+---------------------+-------------------------+---------------+-----------------------+------------------+-------------------+-----------------+---------------------+--------------------+------------------------+-------------------------+-----------------------------+------------+------------+--------------+---------------------+-----------------+-----------------+----------------+---------------+--------------------+--------------------+--------------------+-----------------+-------------------+----------------+-----------------------+-------------------------------+---------------+---------------+----------------+----------------+
[root@server2 ~]#

----------------------------------------------------------------------------

現在可以測試了,在 Server1 上 backup 資料庫隨便新增東西,Server2上backup資料庫也會出現(應該不會超過60秒)。

如果無法正常運作,請檢視兩台機器的/var/log/mysqld.log檔案中有關[ERROR]的部分。

當一台電腦重新啟動MySQL時,請等它啟動完後成,再去重新啟動另外一台,否則會有錯誤訊息。

如果mysqld.log不是必須保留的(或把它另外先備份),可以把它先清空,然後才執行service mysqld restart,這樣比較容易看出是否有錯誤訊息。

(網路上文章說,如果要修改slave的設定,要先刪除/var/lib/mysql/master.info檔案,否則無法生效,但是好像不需要)

Server1 上建立 students 資料表

[root@server1 ~]# mysql -e "use backup; create table students(no int, cname varchar(10)); show tables;" -uroot -p123456
+------------------+
| Tables_in_backup |
+------------------+
| students         |
+------------------+
[root@server1 ~]#


[root@server1 ~]# mysql -e "show master status;" -uroot -p123456
+------------------+----------+--------------+------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000001 |      219 | backup       |                  |
+------------------+----------+--------------+------------------+

[root@server1 ~]# mysql -e "use backup; insert into students values ('01', 'John'); " -uroot -p123456

[root@server1 ~]# mysql -e "show master status;" -uroot -p123456              
+------------------+----------+--------------+------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000001 |      326 | backup       |                  |
+------------------+----------+--------------+------------------+


到 Server2 上檢查

[root@server2 ~]# mysql -e "use backup; show tables;" -uroot -p123456
+------------------+
| Tables_in_backup |
+------------------+
| students         |
+------------------+
[root@server2 ~]#


[root@server2 ~]# mysql -e "show slave status;" -uroot -p123456
+----------------------------------+-----------------+-------------+-------------+---------------+------------------+---------------------+-------------------------+---------------+-----------------------+------------------+-------------------+-----------------+---------------------+--------------------+------------------------+-------------------------+-----------------------------+------------+------------+--------------+---------------------+-----------------+-----------------+----------------+---------------+--------------------+--------------------+--------------------+-----------------+-------------------+----------------+-----------------------+-------------------------------+---------------+---------------+----------------+----------------+
| Slave_IO_State                   | Master_Host     | Master_User | Master_Port | Connect_Retry | Master_Log_File  | Read_Master_Log_Pos | Relay_Log_File          | Relay_Log_Pos | Relay_Master_Log_File | Slave_IO_Running | Slave_SQL_Running | Replicate_Do_DB | Replicate_Ignore_DB | Replicate_Do_Table | Replicate_Ignore_Table | Replicate_Wild_Do_Table | Replicate_Wild_Ignore_Table | Last_Errno | Last_Error | Skip_Counter | Exec_Master_Log_Pos | Relay_Log_Space | Until_Condition | Until_Log_File | Until_Log_Pos | Master_SSL_Allowed | Master_SSL_CA_File | Master_SSL_CA_Path | Master_SSL_Cert | Master_SSL_Cipher | Master_SSL_Key | Seconds_Behind_Master | Master_SSL_Verify_Server_Cert | Last_IO_Errno | Last_IO_Error | Last_SQL_Errno | Last_SQL_Error |
+----------------------------------+-----------------+-------------+-------------+---------------+------------------+---------------------+-------------------------+---------------+-----------------------+------------------+-------------------+-----------------+---------------------+--------------------+------------------------+-------------------------+-----------------------------+------------+------------+--------------+---------------------+-----------------+-----------------+----------------+---------------+--------------------+--------------------+--------------------+-----------------+-------------------+----------------+-----------------------+-------------------------------+---------------+---------------+----------------+----------------+
| Waiting for master to send event | 192.168.128.101 | root        |        3306 |            60 | mysql-bin.000001 |                 219 | mysqld-relay-bin.000002 |           364 | mysql-bin.000001      | Yes              | Yes               | backup          |                     |                    |                        |                         |                             |          0 |            |            0 |                 219 |             520 | None            |                |             0 | No                 |                    |                    |                 |                   |                |                     0 | No                            |             0 |               |              0 |                |
+----------------------------------+-----------------+-------------+-------------+---------------+------------------+---------------------+-------------------------+---------------+-----------------------+------------------+-------------------+-----------------+---------------------+--------------------+------------------------+-------------------------+-----------------------------+------------+------------+--------------+---------------------+-----------------+-----------------+----------------+---------------+--------------------+--------------------+--------------------+-----------------+-------------------+----------------+-----------------------+-------------------------------+---------------+---------------+----------------+----------------+
[root@server2 ~]#

(完)

[研究] MySQL 5.1.71 資料庫同步(Replication)-雙機互備模式(CentOS 6.5 x86_64)
http://shaurong.blogspot.com/2014/01/mysql-5171-replication-centos-65-x8664.html
http://forum.icst.org.tw/phpbb/viewtopic.php?f=21&t=80715

[研究] MySQL 5.1.71 資料庫同步(Replication)-主從模式(CentOS 6.5 x86_64) 
http://shaurong.blogspot.com/2014/01/mysql-5171-replication-centos-65-x8664.html
http://forum.icst.org.tw/phpbb/viewtopic.php?f=21&t=80714

[研究] mysql-5.6.15.tar.gz 安裝(CentOS 6.5 x64)
http://shaurong.blogspot.tw/2014/01/mysql-5615targz-centos-65-x64.html
http://forum.icst.org.tw/phpbb/viewtopic.php?f=21&t=80713

[研究] MySQL 5.6.15 安裝(rpm)(CentOS 6.5 x64)
http://shaurong.blogspot.com/2014/01/mysql-5615-rpmcentos-65-x64.html

[研究] MySQL Community 5.6.15 版安裝(yum) (CentOS 6.5 x64)
http://shaurong.blogspot.com/2014/01/mysql-community-5615-tgz-centos-65-x64.html

[研究] 4主機 MySQL Cluster 7.3.3 架設(CentOS 6.5 x64)
http://shaurong.blogspot.tw/2014/01/4-mysql-cluster-7.html

[研究] 4主機 MySQL Cluster 7.2.10.1 架設
http://shaurong.blogspot.tw/2013/02/4-mysql-cluster-7210-1.html

[研究] 2主機 MySQL Cluster 7.2.10-1 架設
http://shaurong.blogspot.com/2013/02/2-mysql-cluster-7210-1.html

[研究] 4主機 MySQL Cluster 7.0.9 架設
http://forum.icst.org.tw/phpbb/viewtopic.php?f=10&t=17903

[研究] 雙主機 MySQL Cluster 7.0.9架設
http://forum.icst.org.tw/phpbb/viewtopic.php?f=10&t=17904

[研究] MariaDB 5.5 安裝(yum)(CentOS 6.3 x64)
http://shaurong.blogspot.com/2013/02/mariadb-55-yum-centos-63-x64.html

[研究] CentOS 5.4 x86 上 MySQL 資料庫同步(Replication)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=17824

[研究] mariadb-5.1.42 (tar.gz)(瑪利亞資料庫, MySQL) 安裝 (CentOS 5.4)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=17988

[研究] mariadb-5.2.4-Linux-i686.tar.gz 安裝 (CentOS 5.5 x86)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=19434

[研究] mysql-5.5.14.tar.gz 安裝(失敗)(CentOS 6.0 x86)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=20252

[研究] mysql-5.5.8.tar.gz 安裝(CentOS 5.5 x86)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=19214

[研究] mysql-5.5.8.tar.gz 安裝(Fedora 14 x86)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=19215

[研究] 每天自動備份 MySQL 方法
http://forum.icst.org.tw/phpbb/viewtopic.php?t=14972



2014年1月28日 星期二

[研究] mysql-5.6.15.tar.gz 安裝(CentOS 6.5 x64)

[研究] mysql-5.6.15.tar.gz 安裝問題研究 (CentOS 6.5 x64)

2014-01-28

首先說一句:想完全照官方說明安裝於 CentOS 6.5 x64 上安裝 mysql-5.6.15.tar.gz,會有問題。

參考
http://dev.mysql.com/doc/refman/5.6/en/installing-source-distribution.html

下面為切換 su 在 /root 目錄下安裝情況
wget 若沒安裝可用 yum -y install wget 安裝
mysql-5.6.15.tar.gz 請自行下載
http://www.mysql.com/downloads/mysql/#downloads
(下拉選單選 Source Code,到最後一個)

mv   /etc/my.cnf   /etc/my.cnf.old

yum -y install  gcc  gcc-c++  ncurses*  cmake  bison

groupadd mysql
useradd -r -g mysql mysql
tar zxvf  mysql-5.6.15.tar.gz
cd mysql-5.6.15
cmake  .
make
make install

cd /usr/local/mysql
chown -R mysql .
chgrp -R mysql .
scripts/mysql_install_db --user=mysql
chown -R root .
chown -R mysql data
bin/mysqld_safe --user=mysql &
cp support-files/mysql.server /etc/init.d/mysql.server

編譯可能發生問題

照官方這篇,沒有提到需要 ncurses* 套件,但是需要
http://dev.mysql.com/doc/refman/5.6/en/source-installation.html

在 cmake 過程,如果出現類似下面錯誤,請執行 rm -fr  /usr/local/mysql-5.6.15 把整個目錄砍掉
重新解壓 mysql-5.6.15.tar.gz,重新執行 cmake
( 一般若需要的套件沒先用 yum 安裝,而在 cmake 後才安裝會發生)

[root@localhost mysql-5.6.15]# cmake .
....(略)
CMake Error at /usr/share/cmake/Modules/TestBigEndian.cmake:31 (MESSAGE):
  no suitable type found
Call Stack (most recent call first):
  configure.cmake:626 (TEST_BIG_ENDIAN)
  CMakeLists.txt:390 (INCLUDE)

-- Configuring incomplete, errors occurred!
[root@localhost mysql-5.6.15]#

起動可能發生問題

起動 mysql 可能出現下面問題,一執行馬上就結束

[root@localhost mysql]# /usr/local/mysql/bin/mysqld_safe --user=mysql &
[1] 18853
[root@localhost mysql]# 140128 16:33:11 mysqld_safe Logging to '/var/log/mysqld.log'.
140128 16:33:11 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
140128 16:33:12 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

[1]+  Done                    /usr/local/mysql/bin/mysqld_safe --user=mysql
[root@localhost mysql]#

檢查 Log 的錯誤

[root@localhost mysql]# cat /var/log/mysqld.log  | grep ERROR
2014-01-29 11:43:00 17103 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2014-01-29 11:43:02 17103 [ERROR] /usr/local/mysql/bin/mysqld: Can't create/write to file '/var/run/mysqld/mysqld.pid' (Errcode: 2 - No such file or directory)
2014-01-29 11:43:02 17103 [ERROR] Can't start server: can't create PID file: No such file or directory
[root@localhost mysql]#

照 log 要求執行  mysql_upgrade 會失敗

[root@localhost mysql]# find / -name mysql_upgrade
/root/mysql-5.6.15/client/mysql_upgrade
/usr/local/mysql/bin/mysql_upgrade

[root@localhost mysql]# /usr/local/mysql/bin/mysql_upgrade
Looking for 'mysql' as: /usr/local/mysql/bin/mysql
Looking for 'mysqlcheck' as: /usr/local/mysql/bin/mysqlcheck
FATAL ERROR: Upgrade failed
[root@localhost mysql]#

***************************************

開始研究問題

安裝過程中,其中 scripts/mysql_install_db --user=mysql 會在 /usr/local/mysql/data 目錄建立一些資料庫檔案

[root@centos1 mysql]# ls -al /var/lib/mysql
ls: cannot access /var/lib/mysql: No such file or directory

[root@centos1 mysql]# ls -al /usr/local/mysql/data
total 110612
drwxr-xr-x.  5 mysql mysql     4096 Jan 29 13:04 .
drwxr-xr-x. 13 root  mysql     4096 Jan 29 13:04 ..
-rw-rw----.  1 mysql mysql 12582912 Jan 29 13:04 ibdata1
-rw-rw----.  1 mysql mysql 50331648 Jan 29 13:04 ib_logfile0
-rw-rw----.  1 mysql mysql 50331648 Jan 29 13:04 ib_logfile1
drwx------.  2 mysql mysql     4096 Jan 29 13:04 mysql
drwx------.  2 mysql mysql     4096 Jan 29 13:04 performance_schema
drwxr-xr-x.  2 mysql mysql     4096 Jan 29 13:02 test
[root@centos1 mysql]#

系統中發現有兩個 my.cnf

[root@centos1 mysql]# ls -al /etc/my.cnf
-rw-r--r--. 1 root root 251 Nov 23 07:52 /etc/my.cnf

[root@centos1 mysql]# ls -al /usr/local/mysql/my.cnf
-rw-r--r--. 1 root root 943 Jan 29 13:04 /usr/local/mysql/my.cnf

另外找機器安裝 CentOS 6.5 x64,發現尚未用 yum 安裝 mysql 或用 mysql-5.6.15.tar.gz 安裝 MySQL, /etc/my.cnf 就已經存在,內容如下

[root@localhost ~]# cat /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[root@localhost ~]#

這個 /etc/my.cnf 會有甚麼問題呢 ? 如果 mysql-5.6.15.tar.gz  安裝後,執行 bin/mysqld_safe --user=mysql &,它會參考  /etc/my.cnf,發現 datadir=/var/lib/mysql ,但目錄不存在,它會建立目錄,建立預設資料庫

[root@localhost ~]# ls -al /usr/local/mysql/data
total 110612
drwxr-xr-x.  5 mysql mysql     4096 Jan 29 11:40 .
drwxr-xr-x. 13 root  mysql     4096 Jan 29 11:41 ..
-rw-rw----.  1 mysql mysql 12582912 Jan 29 11:40 ibdata1
-rw-rw----.  1 mysql mysql 50331648 Jan 29 11:40 ib_logfile0
-rw-rw----.  1 mysql mysql 50331648 Jan 29 11:40 ib_logfile1
drwx------.  2 mysql mysql     4096 Jan 29 11:40 mysql
drwx------.  2 mysql mysql     4096 Jan 29 11:40 performance_schema
drwxr-xr-x.  2 mysql mysql     4096 Jan 29 11:38 test

[root@localhost ~]# ls -al /var/lib/mysql
total 110604
drwxr-xr-x.  2 mysql root      4096 Jan 29 11:43 .
drwxr-xr-x. 39 root  root      4096 Jan 29 11:43 ..
-rw-rw----.  1 mysql mysql       56 Jan 29 11:43 auto.cnf
-rw-rw----.  1 mysql mysql 12582912 Jan 29 11:43 ibdata1
-rw-rw----.  1 mysql mysql 50331648 Jan 29 11:43 ib_logfile0
-rw-rw----.  1 mysql mysql 50331648 Jan 29 11:43 ib_logfile1
srwxrwxrwx.  1 mysql mysql        0 Jan 29 11:43 mysql.sock

mysql-5.6.15.tar.gz 安裝的 my.cnf 幾乎是註解,如下

[root@localhost ~]# cat /usr/local/mysql/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html

[mysqld]

# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M

# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin

# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
# socket = .....

# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[root@localhost ~]#

所以舊 /etc/my.cnf 可以留做參考,建議把它改名留下,把  mysql-5.6.15.tar.gz 安裝時產生的 /usr/local/mysql/my.cnf 拷貝過去

[root@centos1 mysql]#  mv   /etc/my.cnf   /etc/my.cnf.old
[root@centos1 mysql]#  cp   /usr/local/mysql/my.cnf   /etc/my.cnf
[root@centos1 mysql]#  rm  -fr  /var/lib/mysql

啟動 MySQL 可用

[root@localhost mysql]#  /usr/local/mysql/bin/mysqld_safe --user=mysql &

[root@localhost mysql]#  service   mysql.server   start

檢查一下

[root@localhost mysql]# ps aux | grep mysql
root     18263  0.0  0.1 106192  1528 pts/1    S    16:25   0:00 /bin/sh bin/mysqld_safe --user=mysql
mysql    18355  3.4 44.2 1007644 448204 pts/1  Sl   16:25   0:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/usr/local/mysql/data/localhost.localdomain.err --pid-file=/usr/local/mysql/data/localhost.localdomain.pid
root     18379  0.0  0.0 103244   864 pts/1    S+   16:25   0:00 grep mysql
[root@localhost mysql]#

停止 MySQL

[root@localhost mysql]#  service    mysql.server   stop

或把 Process ID 用 kill -9 砍掉
[root@localhost mysql]# kill -9  18263  18355

(完)

相關文章

[研究] mysql-5.6.15.tar.gz 安裝(CentOS 6.5 x64)
http://shaurong.blogspot.tw/2014/01/mysql-5615targz-centos-65-x64.html
http://forum.icst.org.tw/phpbb/viewtopic.php?f=21&t=80713

[研究] MySQL 5.6.15 安裝(rpm)(CentOS 6.5 x64)
http://shaurong.blogspot.com/2014/01/mysql-5615-rpmcentos-65-x64.html

[研究] MySQL Community 5.6.15 版安裝(yum) (CentOS 6.5 x64)
http://shaurong.blogspot.com/2014/01/mysql-community-5615-tgz-centos-65-x64.html

[研究] 4主機 MySQL Cluster 7.3.3 架設(CentOS 6.5 x64)
http://shaurong.blogspot.tw/2014/01/4-mysql-cluster-7.html

[研究] 4主機 MySQL Cluster 7.2.10.1 架設
http://shaurong.blogspot.tw/2013/02/4-mysql-cluster-7210-1.html

[研究] 2主機 MySQL Cluster 7.2.10-1 架設
http://shaurong.blogspot.com/2013/02/2-mysql-cluster-7210-1.html

[研究] 4主機 MySQL Cluster 7.0.9 架設
http://forum.icst.org.tw/phpbb/viewtopic.php?f=10&t=17903

[研究] 雙主機 MySQL Cluster 7.0.9架設
http://forum.icst.org.tw/phpbb/viewtopic.php?f=10&t=17904

[研究] MariaDB 5.5 安裝(yum)(CentOS 6.3 x64)
http://shaurong.blogspot.com/2013/02/mariadb-55-yum-centos-63-x64.html

[研究] CentOS 5.4 x86 上 MySQL 資料庫同步(Replication)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=17824

[研究] mariadb-5.1.42 (tar.gz)(瑪利亞資料庫, MySQL) 安裝 (CentOS 5.4)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=17988

[研究] mariadb-5.2.4-Linux-i686.tar.gz 安裝 (CentOS 5.5 x86)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=19434

[研究] mysql-5.5.14.tar.gz 安裝(失敗)(CentOS 6.0 x86)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=20252

[研究] mysql-5.5.8.tar.gz 安裝(CentOS 5.5 x86)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=19214

[研究] mysql-5.5.8.tar.gz 安裝(Fedora 14 x86)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=19215

[研究] 每天自動備份 MySQL 方法
http://forum.icst.org.tw/phpbb/viewtopic.php?t=14972

[研究] 雙主機 MySQL Cluster 7.0.9 架設
http://forum.icst.org.tw/phpbb/viewtopic.php?t=17904

[研究] CentOS 6.5 x64 網路安裝

[研究] CentOS 6.5 x64 網路安裝

2014-01-28

僅列出和一般用光碟安裝時,比較重要的差異畫面





(完)

2014年1月27日 星期一

[研究] Microsoft Assessment and Planning (MAP) Toolkit v9.0 資產清點評估報告工具

[研究] Microsoft Assessment and Planning (MAP) Toolkit v9.0 資產清點評估報告工具

2014-01-27

Microsoft Assessment and Planning Toolkit v9.0.135.0 下載
http://www.microsoft.com/en-us/download/details.aspx?id=7826

文件庫 - Microsoft Assessment and Planning Toolkit
http://technet.microsoft.com/zh-tw/solutionaccelerators/dd537566.aspx
http://technet.microsoft.com/library/bb977556.aspx

Microsoft Assessment and Planning Toolkit v4.0 中文介紹
http://www.netadmin.com.tw/article_content.aspx?sn=0909250005

安裝









簡單試用一下













(完)

2014年1月26日 星期日

[研究] Oracle Java 7 Update 51 快速安裝程式(CentOS 6.5 x64)

[研究] Oracle Java 7 Update 51 快速安裝程式(CentOS 6.5 x64)

2014-01-26

如要手動下載
http://www.oracle.com/technetwork/java/javase/downloads/index-jsp-138363.html#javasejdk

JDK7U51x86_64_Install.sh 內容如下:


#!/bin/bash

echo -e "\033[31m"
echo -e "Program : JDK7U51x64_Install.sh "
echo -e "JDK 7 Update 51 x86_64 Install Shell Script (CentOS 6.5 x86_64) "
echo -e "by Shau-Rong Lu 2014/01/26 "
echo -e "\033[0m"

cd /usr/local

if [ ! -s jdk-7u51-linux-x64.rpm ]; then
  echo "Can not find /usr/local/jdk-7u51-linux-x64.rpm"
  wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F" "http://download.oracle.com/otn-pub/java/jdk/7u51-b13/jdk-7u51-linux-x64.rpm"  -O  jdk-7u51-linux-x64.rpm
  #exit
fi

rpm -ivh jdk-7u51-linux-x64.rpm
alternatives --install /usr/bin/java  java  /usr/java/jdk1.7.0_51/bin/java  100
alternatives --set  java /usr/java/jdk1.7.0_51/bin/java

echo

echo 'export JAVA_HOME=/usr/java/jdk1.7.0_51' >> /etc/profile
echo 'export PATH=$PATH:$JAVA_HOME/bin' >> /etc/profile
echo 'export CLASSPATH=$JAVA_HOME/jre/lib/ext:$JAVA_HOME/lib/tools.jar' >> /etc/profile

source /etc/profile

java -version
export | grep jdk


JRE7U51x86_64_Install.sh 內容如下:


#!/bin/bash

echo -e "\033[31m"
echo -e "Program : JRE7U51x64_Install.sh "
echo -e "JRE 7 Update 51 x86_64 Install Shell Script (CentOS 6.5 x86_64) "
echo -e "by Shau-Rong Lu 2014/01/26 "
echo -e "\033[0m"

cd /usr/local

if [ ! -s jre-7u51-linux-x64.rpm ]; then
  echo "Can not find /usr/local/jre-7u51-linux-x64.rpm"
  wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F" "http://download.oracle.com/otn-pub/java/jdk/7u51-b13/jre-7u51-linux-x64.rpm"  -O  jre-7u51-linux-x64.rpm
  #exit
fi

rpm -ivh jre-7u51-linux-x64.rpm
alternatives --install /usr/bin/java  java  /usr/java/jre1.7.0_51/bin/java  100
alternatives --set  java /usr/java/jre1.7.0_51/bin/java

echo

echo 'export JAVA_HOME=/usr/java/jre1.7.0_51' >> /etc/profile
echo 'export PATH=$PATH:$JAVA_HOME/bin' >> /etc/profile
echo 'export CLASSPATH=$JAVA_HOME/lib:$JAVA_HOME/lib/ext' >> /etc/profile

source /etc/profile

java -version
export | grep jre


(完)

[研究] Oracle Java 7 Update 51 快速安裝程式(CentOS 6.5 x64)
http://shaurong.blogspot.com/2014/01/oracle-java-7-update-51-centos-65-x64.html
http://forum.icst.org.tw/phpbb/viewtopic.php?f=44&t=80711

[研究] Oracle Java 手動安裝與快速安裝程式 (CentOS 6.5 x64)
http://shaurong.blogspot.tw/2013/12/oracle-java-centos-65-x64.html

[研究] Java 6 , 7 安裝差異+選擇切換研究 (CentOS 6.4 x64)
http://shaurong.blogspot.tw/2013/11/java-7-centos-64-x64.html

[研究] 用 wget 下載 Java 方法
http://shaurong.blogspot.tw/2013/12/wget-java.html

[研究] drupal 7.26 安裝 (CentOS 6.5 x64)

[研究] drupal 7.26 安裝 (CentOS 6.5 x64)

2014-01-26

英文官方網站
http://drupal.org/

Drupal Taiwan 正體中文支援站
http://drupaltaiwan.org/

安裝參考
https://drupal.org/documentation/install

安裝

# durpal7.26_install_CentOS6.5x64.sh
# ref : http://drupal.org/documentation
# need PHP >= 5.2.4 , CentOS 5.5 yum php is only 5.1.x

if  [ "`grep SELINUX=disabled /etc/selinux/config`" == "" ]; then
# 立刻關閉 SELinux
/usr/sbin/setenforce 0

# 設定 reboot 後會自動啟動,修改 /etc/selinux/config 中設定
sed -i -e "s@SELINUX=enforcing@#SELINUX=enforcing@"   /etc/selinux/config
sed -i -e "s@SELINUX=permissive@#SELINUX=permissive@"   /etc/selinux/config
sed -i -e "/SELINUX=/aSELINUX=disabled"   /etc/selinux/config
fi

yum -y install mysql mysql-server httpd php php-mysql wget php-mbstring php-domxml-php4-php5 php-gd
chkconfig httpd on
chkconfig mysqld on
service httpd start
service mysqld start


wget http://ftp.drupal.org/files/projects/drupal-7.26.tar.gz

tar -zxvf drupal-7.26.tar.gz -C /var/www/html
mv /var/www/html/drupal-7.26  /var/www/html/drupal

#7.26 尚未有繁體中文介面
#wget http://ftp.drupal.org/files/translations/7.x/drupal/drupal-7.26.zh-hant.po
wget http://ftp.drupal.org/files/translations/7.x/drupal/drupal-7.23.zh-hant.po
cp drupal-7.23.zh-hant.po /var/www/html/drupal/profiles/standard/translations/.

cp /var/www/html/drupal/sites/default/default.settings.php /var/www/html/drupal/sites/default/settings.php
chmod a+w /var/www/html/drupal/sites/default/settings.php
chmod a+w /var/www/html/drupal/sites/default

mkdir -p /var/www/html/drupal/sites/default/files
chmod a+w /var/www/html/drupal/sites/default/files

mysql -e "create database drupaldb"
mysql -e "show databases; "
#mysql -e "use drupaldb; show tables;"

mysql -e "grant all privileges on drupaldb.* to drupaluser@localhost  identified by 'drupalpassword'; "
mysql -e "flush privileges; "
mysql -e "use mysql;  select Host,User,Password from user; "

firefox http://localhost/drupal &




(上圖) 缺的 PHP extensions 的 dom

[root@localhost ~]# yum -y install php-xml
[root@localhost ~]# service httpd restart

網頁按下 F5 更新畫面







關閉設定檔寫入權限

chmod a-w /var/www/html/drupal/sites/default/settings.php
chmod a-w /var/www/html/drupal/sites/default

(完)

[研究] drupal 7.26 安裝 (CentOS 6.5 x64)
[研究] drupal 7.0 快速安裝程式 (Fedora 14 x86)

[研究] drupal 6.19 快速安裝程式 (CentOS 5.5 x86)


[研究] WordPress 3.8.1 部落格伺服器架設 (CentOS 6.5 x64)(繁體中文版)

[研究] WordPress 3.8.1 部落格伺服器架設 (CentOS 6.5 x64)(繁體中文版)

2014-01-26
Lu

WordPress 台灣正體中文網站
http://tw.wordpress.org/

安裝參考
http://tw.wordpress.org/txt-install/

下載
http://tw.wordpress.org/wordpress-3.8.1-zh_TW.tar.gz
http://tw.wordpress.org/wordpress-3.8.1-zh_TW.zip

安裝

yum -y install php php-mysql mysql httpd mysql-server
chkconfig httpd on
chkconfig mysqld on
service mysqld restart
service httpd restart

# 替 MySQL 的 root 帳號設定密碼
/usr/bin/mysql_secure_installation

# 建立 WordPress 系統使用的資料庫,稱為 wordpressdb,連線帳號 wordpresser,密碼 123456
(可以依自己喜好修改)

[root@localhost ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.71 Source distribution

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> create database wordpressdb;
Query OK, 1 row affected (0.00 sec)

mysql> grant all privileges on wordpressdb.* to wordpresser@localhost identified by '123456';
Query OK, 0 rows affected (0.00 sec)

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

mysql> exit
Bye
[root@localhost ~]#


wget   http://tw.wordpress.org/wordpress-3.8.1-zh_TW.tar.gz
tar   xzvf   wordpress-3.8.1-zh_TW.tar.gz    -C   /var/www/html
# 為了寫入 wp-config.php
chmod a+w /var/www/html/wordpress

# 啟動瀏覽器,連上網站
firefox   httpd://192.168.128.20/wordpress













最後把權限改回
chmod a-w /var/www/html/wordpress

(完)

[研究] WordPress 3.8.1 部落格伺服器架設 (CentOS 6.5 x64)(繁體中文版)
http://shaurong.blogspot.com/2014/01/wordpress-381-centos-65-x64.html

[研究] WordPress 3.7 部落格伺服器架設 (CentOS 6.4 x64)(繁體中文版)
http://shaurong.blogspot.tw/2013/10/wordpress-27-centos-64-x64.html

[研究] WordPress網誌 快速安裝程式(CentOS 5.5 x86)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=19279

[研究] OpenVAS 安裝與使用(yum)(CentOS 6.5 x64)

[研究] OpenVAS 安裝與使用(yum)(CentOS 6.5 x64)

2014-01-26

官方網站
http://www.openvas.org/

系統架構
http://www.openvas.org/pix/OpenVAS4-Structure.png


作業系統支援情形
http://www.openvas.org/install-packages.html

http://www6.atomicorp.com/channels/atomic/centos/5/x86_64/ 存在
http://www6.atomicorp.com/channels/atomic/centos/5/x86/ 不存在
似乎目前只支援 x86_64 版,不支援 x86 版 ?

官方安裝說明
http://www.openvas.org/install-packages.html

安裝

[root@localhost ~]# wget -q -O - http://www.atomicorp.com/installers/atomic |sh

[root@localhost ~]# yum -y upgrade
# 執行後有錯誤,先不理會

[root@localhost ~]# yum -y upgrade
...(略)
Error: Package: gstreamer-plugins-bad-free-0.10.19-2.el6.x86_64 (@anaconda-CentOS-201311272149.x86_64/6.5)
           Requires: libvpx.so.0()(64bit)
           Removing: libvpx-0.9.0-8.el6_0.x86_64 (@anaconda-CentOS-201311272149.x86_64/6.5)
               libvpx.so.0()(64bit)
           Updated By: libvpx-1.2.0-2.el6.art.x86_64 (atomic)
               Not found
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

[root@localhost ~]#  yum -y install openvas

# 安裝成功,但是要很久


[root@localhost ~]# yum list | grep openvas
openvas.noarch                         1.0-9.el6.art                     @atomic
openvas-administrator.x86_64           1.3.2-5.el6.art                   @atomic
openvas-cli.x86_64                     1.2.0-4.el6.art                   @atomic
openvas-libraries.x86_64               6.0.1-7.el6.art                   @atomic
openvas-manager.x86_64                 4.0.4-13.el6.art                  @atomic
openvas-scanner.x86_64                 3.4.0-7.el6.art                   @atomic
openvas-libraries-devel.x86_64         6.0.1-7.el6.art                   atomic

[root@localhost ~]# ls /etc/init.d/open*
/etc/init.d/openvas-administrator  /etc/init.d/openvas-scanner
/etc/init.d/openvas-manager
[root@localhost ~]#

[root@localhost ~]# openvas-setup

...(略)

Updating OpenVAS Manager database....

Step 2: Configure GSAD
The Greenbone Security Assistant is a Web Based front end
for managing scans. By default it is configured to only allow
connections from localhost.

Allow connections from any IP? [Default: yes]
Stopping greenbone-security-assistant:                     [  OK  ]
Starting greenbone-security-assistant:                     [  OK  ]

Step 3: Choose the GSAD admin users password.
The admin user is used to configure accounts,
Update NVT's manually, and manage roles.

Enter administrator username [Default: admin] :
Enter Administrator Password:  (設定自己想要的密碼)
Verify Administrator Password:  (設定自己想要的密碼)

ad   main:MESSAGE:21335:2014-02-06 15h17.47 CST: No rules file provided, the new user will have no restrictions.
ad   main:MESSAGE:21335:2014-02-06 15h17.47 CST: User admin has been successfully created.

Step 4: Create a user

Using /var/tmp as a temporary file holder.

Add a new openvassd user
---------------------------------


Login : admin
This login already exists. Choose another one.
Login : lu  (設定自己想要的帳號)
Authentication (pass/cert) [pass] :
Login password :  (設定自己想要的密碼)
Login password (again) : (設定自己想要的密碼)

User rules
---------------
openvassd has a rules system which allows you to restrict the hosts that password has the right to test.
For instance, you may want him to be able to scan his own host only.

Please see the openvas-adduser(8) man page for the rules syntax.

Enter the rules for this user, and hit ctrl-D once you are done:
(the user can have an empty rules set)


Login             : lu
Password          : ***********

Rules             :


Is that ok? (y/n) [y]
user added.

Starting openvas-administrator...
Starting openvas-administrator:
                                                           [  OK  ]


Setup complete, you can now access GSAD at:
  https://<IP>:9392


[root@localhost ~]# https://localhost:9392/







無論如何都無法登入,terminal 出現訊息

[root@localhost ~]# Error: received handshake message out of context
Error: received handshake message out of context
Error: received handshake message out of context
Error: received handshake message out of context


(待研究...)

相關

[研究] OpenVAS 安裝與使用(yum)(CentOS 6.5 x64)(失敗)
http://shaurong.blogspot.tw/2014/01/openvas-yumcentos-65-x64.html

[研究] OpenVAS 安裝與使用(yum)(CentOS 6.0 x86_64)(失敗)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=20323

[研究] OpenVAS 安裝與使用(LiveCD)(CentOS 5.5 x86)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=19303

[研究] OpenVAS 安裝與使用(yum)(CentOS 5.5 x86)
http://forum.icst.org.tw/phpbb/viewtopic.php?t=19302