mysql主從複製

若是主服務器已經存在應用數據,則在進行主從複製時,須要作如下處理:
(1)主數據庫進行鎖表操做,不讓數據再進行寫入動做
mysql> FLUSH TABLES WITH READ LOCK;mysql

(2)查看主數據庫狀態
mysql> show master status;nginx

(3)記錄下 FILE 及 Position 的值。
將主服務器的數據文件(整個/opt/mysql/data目錄)複製到從服務器,建議經過tar歸檔壓縮後再傳到從服務器解壓。sql

(4)取消主數據庫鎖定
mysql> UNLOCK TABLES;數據庫

 

mysql > flush tables with read
nginx version: nginx/1.8.1 built by gcc 4.4.7 20120313 (Red Hat 4.4.7-16) (GCC) built with OpenSSL 1.0.1e-fips 11 Feb 2013 TLS SNI support enabled configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-http_spdy_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic'
相關文章
相關標籤/搜索