Posted
Filed under Computer/Linux
Master1    : 172.16.1.13
Master2    : 172.16.1.14
ID            : sync_adm
Password  : PassWord


Master1)

[root@sql1 ~]# cat /etc/my.cnf

[mysqld]
server-id=1
binlog-format=mixed
log-bin=mysql-bin
binlog-do-db=test
sync_binlog=1


mysql> CREATE USER sync_adm@172.16.1.14;
mysql> GRANT REPLICATION SLAVE ON *.* TO sync_adm@172.16.1.14 IDENTIFIED BY 'PassWord';
[root@sql1 ~]# mysqldump -uroot -p --skip-lock-tables --single-transaction --flush-logs --hex-blob --master-data=2 --events -A > ~/dump.sql

[root@sql1 ~]# head dump.sql -n80 | grep "MASTER_LOG_POS"
-- CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.000007', MASTER_LOG_POS=106;




Master2)
[root@sql2 ~]# cat /etc/my.cnf
[mysqld]
server-id=2
binlog-format=mixed
log-bin=mysql-bin
relay-log=mysql-relay-bin
log-slave-updates=1
#read-only=1                     # or comment out this read-only option.
replicate-do-db=test

[root@sql2 ~]# /etc/init.d/mysqld restart

[root@sql2 ~]# mysql -uroot -p < dump.sql

mysql> CHANGE MASTER TO MASTER_HOST='172.16.1.13', MASTER_USER='sync_adm', MASTER_PASSWORD='PassWord', MASTER_LOG_FILE='mysql-bin.000007', MASTER_LOG_POS=106;

mysql> start slave;

mysql> show slave status \G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 172.16.1.13
Master_User: sync_adm
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000007
Read_Master_Log_Pos: 106
Relay_Log_File: mysql-relay-bin.000002
Relay_Log_Pos: 251
Relay_Master_Log_File: mysql-bin.000007
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 106
Relay_Log_Space: 406
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
1 row in set (0.00 sec)

ERROR:
No query specified


mysql> CREATE USER sync_adm@172.16.1.13;
mysql> GRANT REPLICATION SLAVE ON *.* TO sync_adm@172.16.1.13 IDENTIFIED BY 'PassWord';



Master1)
mysql> CHANGE MASTER TO MASTER_HOST='172.16.1.14', MASTER_USER='sync_adm', MASTER_PASSWORD='PassWord', MASTER_LOG_FILE='mysql-bin.000007', MASTER_LOG_POS=106;

mysql> start slave;

mysql> show slave status \G;

*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 172.16.1.14
Master_User: sync_adm
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000008
Read_Master_Log_Pos: 206
Relay_Log_File: mysql-relay-bin.000002
Relay_Log_Pos: 251
Relay_Master_Log_File: mysql-bin.000008
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 206
Relay_Log_Space: 406
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
1 row in set (0.00 sec)

ERROR:
No query specified
2015/04/15 05:43 2015/04/15 05:43
[로그인][오픈아이디란?]
Posted
Filed under Computer/Linux
Master     : 172.16.1.13
Slave       : 172.16.1.14
ID            : sync_adm
Password  : PassWord

Master)

[root@sql1 ~]# cat /etc/my.cnf

[mysqld]
server-id=1
binlog-format=mixed
log-bin=mysql-bin
binlog-do-db=test
sync_binlog=1


mysql> CREATE USER sync_adm@172.16.1.14;
mysql> GRANT REPLICATION SLAVE ON *.* TO sync_adm@172.16.1.14 IDENTIFIED BY 'PassWord';
[root@sql1 ~]# mysqldump -uroot -p --skip-lock-tables --single-transaction --flush-logs --hex-blob --master-data=2 --events -A > ~/dump.sql

[root@sql1 ~]# head dump.sql -n80 | grep "MASTER_LOG_POS"
-- CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.000007', MASTER_LOG_POS=106;




Slave)
[root@sql2 ~]# cat /etc/my.cnf
[mysqld]
server-id=2
binlog-format=mixed
log-bin=mysql-bin
relay-log=mysql-relay-bin
log-slave-updates=1
#read-only=1                     # or comment out this read-only option.
replicate-do-db=test

[root@sql2 ~]# /etc/init.d/mysqld restart

[root@sql2 ~]# mysql -uroot -p < dump.sql

mysql> CHANGE MASTER TO MASTER_HOST='172.16.1.13', MASTER_USER='sync_adm', MASTER_PASSWORD='PassWord', MASTER_LOG_FILE='mysql-bin.000007', MASTER_LOG_POS=106;

mysql> start slave;

mysql> show slave status \G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 172.16.1.13
Master_User: sync_adm
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000007
Read_Master_Log_Pos: 106
Relay_Log_File: mysql-relay-bin.000002
Relay_Log_Pos: 251
Relay_Master_Log_File: mysql-bin.000007
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 106
Relay_Log_Space: 406
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
1 row in set (0.00 sec)

ERROR:
No query specified


If it have an issue :
mysql> slave stop;
mysql> set global sql_slave_skip_counter=1;
mysql> slave start;



Test)

Master)
mysql> use test
Database changed

mysql> create table aaa(a int,b char(20));
Query OK, 0 rows affected (0.00 sec)

mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| aaa |
+----------------+
1 rows in set (0.00 sec)


Slave)
This waiting meaning is good status =>
Slave_IO_State: Waiting for master to send event

mysql> show slave status \G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 172.16.1.13
Master_User: sync_adm
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000007
Read_Master_Log_Pos: 203
Relay_Log_File: mysql-relay-bin.000002
Relay_Log_Pos: 348
Relay_Master_Log_File: mysql-bin.000007
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 203
Relay_Log_Space: 503
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
1 row in set (0.00 sec)

ERROR:
No query specified

mysql> use test
Database changed

mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| aaa |
+----------------+
1 row in set (0.00 sec)
2015/04/14 04:46 2015/04/14 04:46
[로그인][오픈아이디란?]
Posted
Filed under Computer/Linux
Create ssh-key
[root@localhost ]# ssh-keygen -t rsa

Copy to authorized_keys
[root@localhost ]# cp -a ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys
[root@localhost ]# ls -l ~/.ssh/
total 16
-rw-r--r-- 1 root root  408 Jun  4 16:44 authorized_keys
-rw------- 1 root root 1675 Jun  4 16:43 id_rsa
-rw-r--r-- 1 root root  408 Jun  4 16:43 id_rsa.pub
-rw-r--r-- 1 root root  391 Jun  4 16:44 known_hosts

password-less ssh login test
[root@localhost ]# ssh localhost
Warning: Permanently added 'localhost' (RSA) to the list of known hosts.
root@localhost's password:


check like this
[root@localhost ]# stat -c "%a %u %g" /root
550 0 0
This value is correct information

if different value then can login with password-less ssh. (For root account)
example)
permission is 775, 777 or 755 ...
owner is application or normal user account

permission and owner is different then can’t login to root account with ssh-key

[root@localhost ]# chmod 550 /root
[root@localhost ]# chown root:root -R /root

Then will be works.
2014/06/05 06:07 2014/06/05 06:07
[로그인][오픈아이디란?]
Posted
Filed under Computer/Linux
If you want build Heartbeat-3-0-7e3a82377fa8 on RHEL6.5 then it will be error.

if you fix like this then it will be compile.

# cat fix.bug.txt
--- ./lib/plugins/HBcomm/ucast.c 2014-06-03 18:42:44.000000000 +0000
+++ ./lib/plugins/HBcomm/ucast.c.orig 2014-06-03 18:42:32.000000000 +0000
@@ -463,7 +463,8 @@ static int HB_make_send_sock(struct hb_m
  int tos;
 #if defined(SO_BINDTODEVICE)
  struct ifreq i;
-#elif defined(SO_REUSEPORT)
+#endif
+#if defined(SO_REUSEPORT)
  int i = 1;
 #endif
2014/06/05 05:59 2014/06/05 05:59
[로그인][오픈아이디란?]
Posted
Filed under Computer/Linux
Create LVM
1. pvcreate /dev/sdb
2. vgcreate test_vg /dev/sdb
3. lvcreate -n test_dev -l $(vgdisplay test_vg | awk '{if($1=="Free" && $2=="PE" && $4=="Size") print $5}' ) test_vg
4. mkfs.xfs -f /dev/test_vg/test_dev
5. mkdir /test_dir


configure HA
cat /etc/ha.d/ha.cf
logfacility daemon         # Log to syslog as facility daemon
node test1                # List our cluster members
node test2
keepalive 1                # Send one heartbeat each second
warntime 5                 # Warn after 5 seconds
deadtime 15                # Declare nodes dead after 15 seconds
initdead 120               # Initial deadtime
udpport 6794               # UDP port (the default 694 didn't work)
bcast eth0                  # Broadcast heartbeats on eth0 and eth1 interfaces
ping   172.16.1.1        # Ping our switches to monitor ethernet connectivity
auto_failback off          # Don't fail back to primary mgmt server automatically
respawn hacluster /usr/lib64/heartbeat/ipfail  # Failover on network failures
use_logd yes


cat /etc/ha.d/haresource
test1  LVM::test_vg \
        Filesystem::/dev/test_vg/test_dev::/test_dir::xfs::ikeep \
        172.16.1.3


Start Heartbeat
# /etc/init.d/heartbeat start
Starting High-Availability services: LVM[5825]: INFO:  Running OK
ResourceManager[5801]: CRITICAL: Resource LVM::test_vg is active, and should not be!
ResourceManager[5801]: CRITICAL: Non-idle resources can affect data integrity!
ResourceManager[5801]: info: If you don't know what this means, then get help!
ResourceManager[5801]: info: Read the docs and/or source to /usr/share/heartbeat/ResourceManager for more details.
CRITICAL: Resource LVM::test_vg is active, and should not be!
CRITICAL: Non-idle resources can affect data integrity!
info: If you don't know what this means, then get help!
info: Read the docs and/or the source to /usr/share/heartbeat/ResourceManager for more details.
ResourceManager[5801]: CRITICAL: Non-idle resources will affect resource takeback!
ResourceManager[5801]: CRITICAL: Non-idle resources may affect data integrity!
Done.

This issue was LVM status is available.
So, make a not available to the LVM device.

# lvdisplay
  --- Logical volume ---
  LV Path                /dev/test_vg/test_dev
  LV Name                test_dev
  VG Name                test_vg
  LV UUID                Bw36wU-jgZy-JMRp-g3vg-xgTZ-r5kW-QPmq0f
  LV Write Access        read/write
  LV Creation host, time hatest, 2014-05-07 18:12:16 +0000
  LV Status              available
  # open                 1
  LV Size                296.16 GiB
  Current LE             75816
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0


# lvchange -an test_vg/test_dir
# lvdisplay
  --- Logical volume ---
  LV Path                /dev/test_vg/test_dev
  LV Name                test_dev
  VG Name                test_vg
  LV UUID                Bw36wU-jgZy-JMRp-g3vg-xgTZ-r5kW-QPmq0f
  LV Write Access        read/write
  LV Creation host, time hatest, 2014-05-07 18:12:16 +0000
  LV Status              NOT available
  # open                 1
  LV Size                296.16 GiB
  Current LE             75816
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0


Restart HA
# /etc/init.d/heartbeat start
Starting High-Availability services: LVM[16033]: INFO: LVM Volume test_vg is offline
LVM[16025]: INFO:  Resource is stopped
Done.


# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3             122G  9.2G  107G   8% /
tmpfs                  36G     0   36G   0% /dev/shm
/dev/sda1             485M   34M  426M   8% /boot
/dev/mapper/test_vg-test_dev
                      292G  191M  277G   1% /test_dir
2014/05/08 04:11 2014/05/08 04:11
[로그인][오픈아이디란?]