亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 1654 | 回復(fù): 0
打印 上一主題 下一主題

智能DNS(Bind DLZ MYSQL )實(shí)際部署案例 [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2011-12-22 08:53 |只看該作者 |倒序?yàn)g覽

目錄

一、相關(guān)術(shù)語簡介

二、智能DNS系統(tǒng)服務(wù)規(guī)劃

三、MYSQLReplication及添加GoogleTCMALLOC庫降低系統(tǒng)負(fù)載

四、安裝配置Bind-DLZ 及相關(guān)腳本

五、測試Bind-DLZ相關(guān)總結(jié)

相關(guān)術(shù)語簡介:
1、智能DNSBind-view
智能DNS的原理很簡單:在用戶解析一個域名的時候,判斷一下用戶的IP,然后跟DNS服務(wù)器內(nèi)部的IP表匹配一下,看看用戶是電信還是網(wǎng)通用戶,然后給用戶返回對應(yīng)的IP地址。目前的域名服務(wù)運(yùn)營商不提供智能DNS服務(wù),所以必須自行架設(shè)DNS服務(wù)或者使用網(wǎng)上免費(fèi)的智能DNS服務(wù),如DNSPOD.

2Bind-DLZ
Bind-DLZ主頁:http://bind-dlz.sourceforge.net/
DLZ(Dynamically Loadable Zones)與傳統(tǒng)的BIND9不同,BIND的不足之處:
* BIND從文本文件中獲取數(shù)據(jù),這樣容易因?yàn)榫庉嬪e誤出現(xiàn)問題。
* BIND需要將數(shù)據(jù)加載到內(nèi)存中,如果域或者記錄較多,會消耗大量的內(nèi)存。
* BIND啟動時解析Zone文件,對于一個記錄較多的DNS來說,會耽誤更多的時間。
* 如果近修改一條記錄,那么要重新加載或者重啟BIND才能生效,那么需要時間,可能會影響客戶端查詢。
Bind-dlz 即將幫你解決這些問題, Zone文件操作也更方便了,直接對數(shù)據(jù)庫操作,可以很方
便擴(kuò)充及開發(fā)管理程序。
 

二、智能DNS系統(tǒng)服務(wù)規(guī)劃

1NameServer服務(wù)器注冊(到新網(wǎng)或者萬網(wǎng)后臺添加)
ns1.soshandong.com  192.19.13.15
ns2.soshandong.com  192.19.11.3

 

NS1master ,NS2slave。兩者數(shù)據(jù)通過mysql來同步。
 

2、測試NS記錄是否生效

#digns www.soshandong.com

#digwww.soshandong.com+trace

3、Bind-View規(guī)劃
www.soshandong.com 網(wǎng)通 (CNC)  124.133.11.78
www.soshandong.com
電信(TELECOM) 58.56.11.153
www.soshandong.com 移動(ANY) 120.192.11.13

三、MYSQLReplicationUbuntu上的安裝

Ubuntu上安裝Mysql 5.1.51

因新安裝的Ubuntu沒有zlib-dev庫和ncurses,需要執(zhí)行apt-get 來安裝他們
 

#apt-get install zlib1g-dev ncurses

首先下載mysql-5.1.51.tar.gz,并解壓.

#cd mysql-*

#sh mysql.sh

腳本執(zhí)行完畢后,將my.cnf放到/etc
 

# mv my.cnf /etc/

默認(rèn)腳本會啟動mysql,如果報錯,會在數(shù)據(jù)庫目錄里有錯誤日志。


Mysql replication
配置

1、Mysql安全設(shè)置

*  mysqladmin命令來改root用戶口令 mysqladmin -uroot password linuxtone.org//設(shè)置MySQL管理操作用戶root的密碼為52netseek

*  
setpassword修改口令:
mysql> set password for root@localhost=password('linuxtone.org);

*  
直接修改user表的root用戶口令   
mysql> use mysql;
mysql> update user set password=password('linuxtone.org') where user='root';
mysql> flush privileges;

2.
刪除默認(rèn)的數(shù)據(jù)庫和用戶我們的數(shù)據(jù)庫是在本地,并且也只需要本地的php腳本對mysql進(jìn)行讀取,所以很多用戶不需要。m
ysql
初始化后會自動生成空用戶和test庫,這會對數(shù)據(jù)庫構(gòu)成威脅,我們?nèi)縿h除。我們使用mysql客戶端程序連接到本地的mysql服務(wù)器后出現(xiàn)如下提示:
mysql> drop database test;
mysql> use mysql;
mysql> delete from db;
mysql> delete from user where not(host="localhost" anduser="root");
mysql> flush privileges;

Mysql replication設(shè)置
3Master 機(jī)器設(shè)置權(quán)限,賦予Slave機(jī)器FILEReplication Slave權(quán)利,并打包要同步的數(shù)據(jù)庫結(jié)構(gòu)。

Master#./mysql –u root –plinuxtone.org
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 5.1.51

Type 'help;'or '\h' for help. Type '\c' to clear the buffer.
mysql> GRANTFILE ON*.* TO slaverep@172.19.1.3 IDENTIFIEDBY ‘slaverep’;
mysql>GRANT REPLICATION SLAVE ON *.* TO slaverep@172.19.1.3 IDENTIFIEDBY ‘linuxtone.org’;
mysql>Flushprivilege;
賦予192.19.11.3也就是Slave 機(jī)器有File權(quán)限, 這個5.1.51版對replication的權(quán)限好像做了調(diào)整,只賦予Slave機(jī)器有File權(quán)限還不行,還要給它REPLICATION SLAVE的權(quán)限才可以。
Master 導(dǎo)入CDN。Sql文件建立CDN數(shù)據(jù)結(jié)構(gòu)
#mysql–uroot –plinuxtone.org
Mysql>create database cdn;
Mysql>\q

#mysql
cdn –uroot –plinuxtone.org <cdn.sql #cdn.sql
位置
這樣master 就有了CDN庫的數(shù)據(jù)結(jié)構(gòu)。
Slave一樣。這樣不再重復(fù)
2設(shè)置主服務(wù)器Mastermy.cnf,啟動Mysql服務(wù)
Master# vi/etc/my.cnf
[mysqld]添加或修改以下的
[mysqld]
log-bin = /home/data/mysql/data/binlog/binlog#
打開logbin選項(xiàng)以能寫到slave I/O線程;
server-id=1 #
表示是本機(jī)的序號為1,一般來講就是master的意思.

binlog-do-db= cdn #
表示同步cdn數(shù)據(jù)庫;
PS:提供的My。Cnf 比較詳細(xì)。
然后把Master主服務(wù)器的Mysql重啟。
Master# servicemysqld restart

 

4、修改Slave服務(wù)器的my.cnf

Slave# vi/etc/my.cnf

[mysqld]添加或修改以下的
master-host=192.19.13.15
master-user=slaverep
master-password=linuxtone.org
master-port=3306
server-id=10
master-connect-retry=60
replicate-do-db=cdn
[要更新的數(shù)據(jù)庫]
log-slave-updates

5、刪除Slave端數(shù)據(jù)庫目錄中的master.info
Slave# rm -fmaster.info
6、重啟動Slaveslave start
Slave#servicemysqld restart


7、測試先檢測兩個Mysql數(shù)據(jù)庫中的cdn是否正常。正常情況應(yīng)該是MasterSlave 中的Mysql 都有相同的cdn 數(shù)據(jù)庫,并且里面的數(shù)據(jù)都一樣。然后測試replication 功能是否起用。Master中的reptest數(shù)據(jù)庫添加一筆數(shù)據(jù):
Master#mysql –u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12 to server version: 5.1.51

Type 'help;'or '\h' for help. Type '\c' to clear the buffer.
mysql>use cdn;
Database changed
mysql> INSERT INTO rep_table VALUES ('test1', '4321', 'T',24);
Query OK, 1 row affected (0.00 sec)
mysql>

然后查看Slave機(jī)器的reptest數(shù)據(jù)庫:
Slave#mysql–u root –p
Enterpassword:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12 to server version: 5.1.49

Type 'help;'or '\h' for help. Type '\c' to clear the buffer.
mysql>use cdn;
Database changed
mysql>select * from reptable;;

+------+------+------+------+
| id | name| *** | age |
+------+------+------+------+
| test1|4321 | T | 24 |
+------+------+------+------+
1 row in set(0.00 sec)
 

mysql 添加TCMalloc庫降低系統(tǒng)負(fù)載


 

TCMallocThread-CachingMalloc)是google開發(fā)的開源工具──google-perftools中的成員。與標(biāo)準(zhǔn)的glibc庫的malloc相比,TCMalloc在內(nèi)存的分配上效率和速度要高得多,可以在很大程度上提高MySQL服務(wù)器在高并發(fā)情況下的性能,降低系統(tǒng)負(fù)載。

164位操作系統(tǒng)請先安裝libunwind庫,32位操作系統(tǒng)不要安裝。libunwind庫為基于64CPU和操作系統(tǒng)的程序提供了基本的堆棧輾轉(zhuǎn)開解功能,其中包括用于輸出堆棧跟蹤的API、用于以編程方式輾轉(zhuǎn)開解堆棧的API以及支持C++異常處理機(jī)制的API。
 

wget http://download.savannah.gnu.org/releases/libunwind/libunwind-0.99.tar.gz
tar zxvf libunwind-0.99.tar.gz
cd libunwind-0.99/
CFLAGS=-fPIC ./configure
make CFLAGS=-fPIC
make CFLAGS=-fPIC install



2、安裝google-perftools
 

wget http://google-perftools.googlecode.com/files/google-perftools-1.6.tar.gz
tar zxvf google-perftools-1.6.tar.gz
cd google-perftools-1.6/
./configure
make && make install

echo "/usr/local/lib" >/etc/ld.so.conf.d/usr_local_lib.conf
/sbin/ldconfig



3
、修改MySQL啟動腳本(根據(jù)你的MySQL安裝位置而定):
 

vi /usr/local/mysql/bin/mysqld_safe


  在# executingmysqld_safe的下一行,加上:
 

export LD_PRELOAD=/usr/local/lib/libtcmalloc.so


 

保存后退出,然后重啟MySQL服務(wù)器。
 

4、使用lsof命令查看tcmalloc是否起效: lsof -n | grep tcmalloc

如果發(fā)現(xiàn)以下信息,說明tcmalloc已經(jīng)起效:
 

mysqld 10847 mysql mem REG 8,5 1203756 20484960/usr/local/lib/libtcmalloc.so.0.0.0



 

.安裝配置Bind-DLZ 及相關(guān)腳本

1.安裝bind

#mkdir /usr/local/src/bind-dlz
#cd /usr/local/src/bind-dlz
#wget http://ftp.isc.org/isc/bind9/9.6.0-P1/bind-9.6.0-P1.tar.gz
#tar zxvf bind-9.6.0-P1.tar.gz

#cd bind-9.6.0-P1
#./configure --with-dlz-mysql --enable-largefile --enable-threads=no--prefix=/usr/local/bind

#make –j4 && make install


 

2.創(chuàng)建相關(guān)配置文件

cd /usr/local/bind/etc
../sbin/rndc-confgen >rndc.conf
tail -n10 rndc.conf | head -n9 | sed -e s/#\//g >named.conf

# vilocalhost.zone

ttl 86400
@ IN SOA localhost. root.localhost. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS localhost.
1 IN PTR localhost.

# dig >named.root
#vi named.conf
在后面加入如下:

include"/usr/local/bind/etc/cnc_acl.conf"; //網(wǎng)通ACL
include "/usr/local/bind/etc/telecom_acl.conf"; //
電信ACL
include "/usr/local/bind/etc/edu_acl.conf"; //
教育網(wǎng)ACL
include "/usr/local/bind/etc/view.conf"; //DLZ
相關(guān)的配

3、配置DNSTSIG

1、使用dnssec-keygenfunction 產(chǎn)生加密密鑰,一個為public key,另一

個為private key,本文假設(shè)應(yīng)用服務(wù)器存在CNC,TELECOM,EDU,ANY

(1)產(chǎn)生加密金鑰

#cd /usr/local/bind/sbin

#./dnssec-keygen -a hmac-md5 -b 128 -n HOSTcnc

#./dnssec-keygen -a hmac-md5 -b 128 -n HOSTtelecom

#./dnssec-keygen -ahmac-md5 -b 128 -n HOST edu
#./dnssec-keygen -a hmac-md5 -b 128 -n HOST any
(2)
查看生成的密鑰文件

# cat Kcnc.+157+24406.private //以網(wǎng)通為例.

Private-key-format: v1.2

Algorithm: 157 (HMAC_MD5)

Key: YTjTOw00PzeEaasA16/Rvw==

Bits: AAA=

:YTjTOw00PzeEaasA16/Rvw== 加入到named.conf,其它同例。

詳細(xì)請參照named.conf配置文件

2、配置named.conf
 

#vi /usr/local/bind/etc/named.conf
 

key "rndc-key" {

algorithm hmac-md5;

secret "5PubnjGuAWeH9F2dIUYd6g==";

};

controls {

inet 127.0.0.1 port 953

allow { 127.0.0.1; } keys {"rndc-key"; };

};

#

options {

directory "/usr/local/bind/etc";

pid-file "named.pid";

};

#TSIG-key

key "cnc" {

algorithm hmac-md5;

secret "YTjTOw00PzeEaasA16/Rvw==";

};

key "telecom" {

algorithm hmac-md5;

secret"pUcQGLpSH2tQgVZ9ZHU6Yg==";

};

key "edu"{

algorithm hmac-md5;

secret"Bzo6MTzrzbRFQbONYTS1Cw==";

};

key "any"{

algorithm hmac-md5;

secret"DHpPfGJdMLv91OygBf9H6w==";

};

#acl

acl"dns-ip-list"{

172.19.3.15; #masterDNS IP

172.19.1.3; #slaveDNS IP

};

#acl include

include"/usr/local/bind/etc/cnc_acl.conf"; //網(wǎng)通ACL

include"/usr/local/bind/etc/telecom_acl.conf"; //電信 ACL

include"/usr/local/bind/etc/edu_acl.conf"; //教育網(wǎng)ACL

include"/usr/local/bind/etc/view.conf"; //bind-view部分


 

3Bind 啟動腳本

#!/bin/sh

# powered bydzwww.com

case"$1" in

start)

if [ -x/usr/local/bind/sbin/named ]; then

/usr/local/bind/sbin/named-c /usr/local/bind/etc/named.conf -u bind

echo"BIND9-named server started"

fi

;;

stop)

kill `cat/usr/local/bind/etc/named.pid` && echo . && echo 'BIND9 serverstopped'

;;

restart)

echo .

echo"Restart BIND9 server"

$0 stop

sleep 10

$0 start

;;

reload)

/usr/local/bind/sbin/rndcreload

;;

status)

/usr/local/bind/sbin/rndcstatus

;;

*)

echo"$0 start | stop | restart |reload |status"

;;

esac


 

./bind9 start 啟動bind;./bind9 stop停止bind;
./bind9 reload #
重載配置文件
 

剩余文檔見打包的bind-dlz.tar.gz。里面很詳細(xì)。部署的master時候用tar zvxf bind-dlz-tar.gz –C /usr/local/bind/etc覆蓋即可,剩下的slave在部署bind還是將配置文件解壓到/usr/local/bind/etc/即可,將rndc-key dnssec重新配置一遍就可以用了!


 

部署DNS,防火墻和路由器要設(shè)置清楚,我部署的時候就是因?yàn)楹诙捶阑饓]有對masterslave服務(wù)器開放tcpudp53端口,造成不能解析域名。需要大家切記!
MYSQL Master info


 

1.jpg

 


 

bind 配置文檔及最新修訂IP庫

etc.zip (8.39 KB, 下載次數(shù): 78)
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP