Chapter 16. Replication
Replication 讓資料能夠 複製到多個其他的database server 上, replication 基本上是不同步的, slave 不需要永遠都連著master 來接收變動, 意思是說這樣的機制可以長距離傳輸, 即使是 dial-up service 也行, 根據你的設定你可以複製所有的databases 或者是某些database 甚至是某些tables
2009年4月7日 星期二
mysql replication, 同步 database
MYSQL的master/slave資料同步配置
How to Set Up Replication
Mysql Replication 如何設定覆寫機制
這邊設定的replication, 只有單向, 兩個database, 一個是master 一個是slave
master 資料變動的時候, slave 會跟著變, 反之則否
Step1:
(In master)
在master 上開一個有 replication slave 權限的user 叫 slave_user, password 是 slave_password, 而且只有從 192.168.11.103 來的能用
Step2 :
(In master)
設定/etc/mysql/my.cnf
Step3
(In slave)
設定 my.cnf
Step4
(In master and slave)
在同步之前, 要先把master 已經有的資料弄到slave 上
Step5:
(In master and slave) master 和 slave 兩邊的mysql 都要重起
/etc/init.d/mysql restart
How to Set Up Replication
Mysql Replication 如何設定覆寫機制
這邊設定的replication, 只有單向, 兩個database, 一個是master 一個是slave
master 資料變動的時候, slave 會跟著變, 反之則否
Step1:
(In master)
在master 上開一個有 replication slave 權限的user 叫 slave_user, password 是 slave_password, 而且只有從 192.168.11.103 來的能用
Step2 :
(In master)
設定/etc/mysql/my.cnf
Step3
(In slave)
設定 my.cnf
Step4
(In master and slave)
在同步之前, 要先把master 已經有的資料弄到slave 上
Step5:
(In master and slave) master 和 slave 兩邊的mysql 都要重起
/etc/init.d/mysql restart
javascript & document.write
[問題]javascript中的document.write
document.write 表示你要重寫整個頁面,所以第一個指令執行後,整個頁面已予清除,第二個指令也就不見了
另外,JS 語法也不正確,應該是
document.open();
document.write(...);
:
document.close();
如果不要清除網頁,可用:
text = document.createTextNode("blah blah blah");
document.body.appendChild(text);
document.write 表示你要重寫整個頁面,所以第一個指令執行後,整個頁面已予清除,第二個指令也就不見了
另外,JS 語法也不正確,應該是
document.open();
document.write(...);
:
document.close();
如果不要清除網頁,可用:
text = document.createTextNode("blah blah blah");
document.body.appendChild(text);
2009年4月4日 星期六
ym4r memo(3)
GMarkerManager
#有時候你要秀上千個marker的時候, 你可以利用這個來指定在哪個zoom 的範圍下, 才會有
It is a recent (v2.67) GMaps API class that manages the efficient display of potentially thousands of markers. It is similar to the Clusterer (see below) since markers start appearing at specified zoom levels. The clustering behaviour has to be managed explicitly though by specifying the cluster for smaller zoom levels and specify the expanded cluster for larger zoom levels and so on. Note that it is not an overlay and is not added to the map through an overlay_init call.
===Clusterer
也是用在markers 很多的情況下, 讓它小到在只有某個數目的markers的時候才會出現
A Clusterer is a type of overlay that contains a potentially very large group of markers. It is engineered so markers close to each other and undistinguishable from each other at some level of zoom, appear as only one marker on the map at that level of zoom. Therefore it is possible to have a very large number of markers on the map at the same time and not having the map crawl to a halt in order to display them.
===GeoRss Overlay
從rss 拿 位置
An group of markers taken from a Rss feed containing location information in the W3C basic geo (WGS83 lat/lon) vocabulary and in the Simple GeoRss format
===Adding new map types
沒看 XD
It is now possible to easily add new map types, on top of the already existing ones, like G_SATELLITE_MAP or G_NORMAL_MAP. The imagery for these new map types can come from layers of the standard map types or can be taken either from a WMS server or from pretiled images on a server (that can be generated with a tool that comes with the YM4R gem: refer to the README of the gem to know more about it).
===Local Search
試不出來 @@
Local Search control has been added to the map and control objects. There are two places you need to implement it to get it to work. This is because the local search control needs an additional library added to the import as well as the control added to the map.
#有時候你要秀上千個marker的時候, 你可以利用這個來指定在哪個zoom 的範圍下, 才會有
It is a recent (v2.67) GMaps API class that manages the efficient display of potentially thousands of markers. It is similar to the Clusterer (see below) since markers start appearing at specified zoom levels. The clustering behaviour has to be managed explicitly though by specifying the cluster for smaller zoom levels and specify the expanded cluster for larger zoom levels and so on. Note that it is not an overlay and is not added to the map through an overlay_init call.
===Clusterer
也是用在markers 很多的情況下, 讓它小到在只有某個數目的markers的時候才會出現
A Clusterer is a type of overlay that contains a potentially very large group of markers. It is engineered so markers close to each other and undistinguishable from each other at some level of zoom, appear as only one marker on the map at that level of zoom. Therefore it is possible to have a very large number of markers on the map at the same time and not having the map crawl to a halt in order to display them.
===GeoRss Overlay
從rss 拿 位置
An group of markers taken from a Rss feed containing location information in the W3C basic geo (WGS83 lat/lon) vocabulary and in the Simple GeoRss format
===Adding new map types
沒看 XD
It is now possible to easily add new map types, on top of the already existing ones, like G_SATELLITE_MAP or G_NORMAL_MAP. The imagery for these new map types can come from layers of the standard map types or can be taken either from a WMS server or from pretiled images on a server (that can be generated with a tool that comes with the YM4R gem: refer to the README of the gem to know more about it).
===Local Search
試不出來 @@
Local Search control has been added to the map and control objects. There are two places you need to implement it to get it to work. This is because the local search control needs an additional library added to the import as well as the control added to the map.
ym4r memo(2)
ym4r in github
GMarkerGroup
To use it you would have to include in your HTML template the JavaScript file markerGroup.js after the call
to GMap.header (because it extends the GOverlay class). You should have something like that in your
template:
<%= javascript_include_tag("markerGroup") %>
It is useful in 2 situations:
- Display and undisplay a group of markers without referencing all of them. You just declare your marker group globally and call +activate+ and +deactivate+ on this group in response, for example, to clicks on links on your page. - Keeping an index of markers, for example, in order to show one of these markers in reponse to a click on a link (the way Google Local does with the results of the search).
還有其他function 都在 public/javascript 的markerGroup.js 裡面還有更多其他有用的function
You can call +activate+ and +deactivate+ to display or undisplay a group of markers. You can add new markers with addMarker(marker,id). Again if you don't care about referencing the marker, you don't need to pass an id. If the marker group is active, the newly added marker will be displayed immediately. Otherwise it will be displayed the next time the group is activated. Finally, since it is an overlay, the group will be removed when calling clearOverlays on the GMap object.
You can center and zoom on all the markers in the group by calling GMarkerGroup#centerAndZoomOnMarkers() after the group has been added to a map. So for example, if you would want to do that at initalization time, you would do the following assuming your marker group has been declared as +group+): @map.record_init group.center_and_zoom_on_markers
GMarkerGroup
To use it you would have to include in your HTML template the JavaScript file markerGroup.js after the call
to GMap.header (because it extends the GOverlay class). You should have something like that in your
template:
<%= javascript_include_tag("markerGroup") %>
It is useful in 2 situations:
- Display and undisplay a group of markers without referencing all of them. You just declare your marker group globally and call +activate+ and +deactivate+ on this group in response, for example, to clicks on links on your page. - Keeping an index of markers, for example, in order to show one of these markers in reponse to a click on a link (the way Google Local does with the results of the search).
還有其他function 都在 public/javascript 的markerGroup.js 裡面還有更多其他有用的function
You can call +activate+ and +deactivate+ to display or undisplay a group of markers. You can add new markers with addMarker(marker,id). Again if you don't care about referencing the marker, you don't need to pass an id. If the marker group is active, the newly added marker will be displayed immediately. Otherwise it will be displayed the next time the group is activated. Finally, since it is an overlay, the group will be removed when calling clearOverlays on the GMap object.
You can center and zoom on all the markers in the group by calling GMarkerGroup#centerAndZoomOnMarkers() after the group has been added to a map. So for example, if you would want to do that at initalization time, you would do the following assuming your marker group has been declared as +group+): @map.record_init group.center_and_zoom_on_markers
2009年4月3日 星期五
ym4r memo (1)
ym4r in github
1. 如果你的website 會用到不同的domain 時, 就需要在設定裡面特別去指定各個host 的key, 然後在GMap.header 裡, 加上:host 的參數, 如
you may need to have multiple keys
(for example if your app will be accessible from multiple URLs, for which you need different keys), you can also associate a hash to the environment, whose keys will be the different hosts. In this case, you will need to pass a value to the :host key when calling the method GMap.header(usually @request.host.
2. 也可以一次用兩張地圖, 不過你這時你就必須特別指定global variable
另一個在controller 必要的設定是設定地圖中心和 zoom
3. to_html 可以傳 :full => true 來讓它變全螢幕
4. GMarker 可以吃很多種參數
You can pass options to the GMarker to customize the info window (:info_window or :info_window_tabs options), the tooltip (:title option) or the icon used (:icon option).
For example:
5. GPolyline
GPolylines are colored lines on the map. The constructor takes as argument a list of GLatLng or a list of 2-element
arrays, which will be transformed into GLatLng for you. It can also take the color (in the #rrggbb form), the
weight (an integer) and the opacity. These arguments are optional though.
For example:
6. GPolygon
The constructor takes as argument a list of GLatLng or a list of 2-element arrays, which will be transformed into GLatLng for you. Note that for polygons, the last point must be equal to the first, in order to have a closed loop. It can also take the color (in the #rrggbb form) of the stroke, the weight of the stroke, the opacity of the stroke, as well as the color of the fill and the opacity. These arguments are optional though.
For example:
1. 如果你的website 會用到不同的domain 時, 就需要在設定裡面特別去指定各個host 的key, 然後在GMap.header 裡, 加上:host 的參數, 如
you may need to have multiple keys
(for example if your app will be accessible from multiple URLs, for which you need different keys), you can also associate a hash to the environment, whose keys will be the different hosts. In this case, you will need to pass a value to the :host key when calling the method GMap.header(usually @request.host.
2. 也可以一次用兩張地圖, 不過你這時你就必須特別指定global variable
另一個在controller 必要的設定是設定地圖中心和 zoom
3. to_html 可以傳 :full => true 來讓它變全螢幕
4. GMarker 可以吃很多種參數
You can pass options to the GMarker to customize the info window (:info_window or :info_window_tabs options), the tooltip (:title option) or the icon used (:icon option).
For example:
5. GPolyline
GPolylines are colored lines on the map. The constructor takes as argument a list of GLatLng or a list of 2-element
arrays, which will be transformed into GLatLng for you. It can also take the color (in the #rrggbb form), the
weight (an integer) and the opacity. These arguments are optional though.
For example:
6. GPolygon
The constructor takes as argument a list of GLatLng or a list of 2-element arrays, which will be transformed into GLatLng for you. Note that for polygons, the last point must be equal to the first, in order to have a closed loop. It can also take the color (in the #rrggbb form) of the stroke, the weight of the stroke, the opacity of the stroke, as well as the color of the fill and the opacity. These arguments are optional though.
For example:
2009年4月2日 星期四
How to use ym4r drag and move marker in google map
Esa's Google Maps API examples
Integrating Google Maps into Your Web Applications
google map api
[Ym4r-user] marker event listeners
A port of the YM4R-GM plugin for rails
If we want to drag or move a marker, we should set the global variable for marker when we create a marker or this marker would be anonymous one
application.js
這樣會生出這樣的script
下面就是如果沒有@map.overlay_global_init(@gmarker, "gmarker"), 沒有給marker 指定變數的結果
Integrating Google Maps into Your Web Applications
google map api
[Ym4r-user] marker event listeners
A port of the YM4R-GM plugin for rails
If we want to drag or move a marker, we should set the global variable for marker when we create a marker or this marker would be anonymous one
application.js
這樣會生出這樣的script
下面就是如果沒有@map.overlay_global_init(@gmarker, "gmarker"), 沒有給marker 指定變數的結果
訂閱:
文章 (Atom)