一.首先安裝mysqlmysql
- [root@mysql2l ~]# yum install mysql mysql-server mysql-client mysql-devel mysql-shared -y
- [root@mysql ~]# service mysqld start
- [root@mysql ~]# mysql
- mysql> create database dns;
- mysql> use dns;
- mysql> create table mytb (
- ID BIGINT(20) NOT NULL DEFAULT 0,UserID BIGINT(20) NOT NULL,ZoneID BIGINT(20) NOT NULL,Zone VARCHAR(255) NOT NULL,Host VARCHAR(255) NOT NULL,Type ENUM('A','SOA','NS','MX','CNAME','PTR','TXT','AAAA') NOT NULL,Mx_priority INT(10),Data VARCHAR(255) NOT NULL,TTL INT(10) NOT NULL DEFAULT '600',View VARCHAR(20) NOT NULL DEFAULT 'DEF',Active ENUM('Y','N') NOT NULL DEFAULT 'Y',DomainLevel INT(11) NOT NULL DEFAULT 1,Standby VARCHAR(255) NOT NULL,CheckHostID BIGINT(20) NOT NULL DEFAULT 0,IsFensheng TINYINT(1) NOT NULL DEFAULT 0);
- mysql> LOAD DATA INFILE '/tmp/table.sql' INTO TABLE mytb;
- //導入事先準備好的數據庫文件
- mysql>GRANT REPLICATION SLAVE ,REPLICATION CLIENT,RELOAD,SUPER ON *.* TO 'redhat'@'192.168.56.%' IDENTIFIED BY 'redhat';
- [root@mysql2 ~]# mysql
- mysql> CHANGE MASTER TO
- MASTER_HOST='192.168.56.101', //指定主服務器
- MASTER_USER='redhat', //複製用的用戶名
- MASTER_PASSWORD='redhat', //對應的密碼
- MASTER_LOG_FILE='/var/lib/mysql'; //日誌目錄
- mysql> START SLAVE; //開啓從服務器功能
- mysql> delete from dns.mytb where zone like '%.net';
- Query OK, 71 rows affected (0.04 sec)
- mysql> select * from dns.mytb where zone like '%.net';
- Empty set (0.01 sec)