自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Ubuntu 9.04安裝Mysql Proxy Lua測試成功版

移動開發(fā) iOS
Ubuntu 9.04安裝Mysql Proxy Lua是本文要介紹的內(nèi)容,主要是來了解Mysql Proxy在Ubuntu 9.04下的安裝環(huán)境,具體內(nèi)容來看本文詳解。

Ubuntu 9.04安裝Mysql Proxy Lua是本文要介紹的內(nèi)容,主要是來了解Mysql ProxyUbuntu 9.04下的安裝環(huán)境,并且已經(jīng)通過測試,具體內(nèi)容來看本文詳解。

安裝mysql

1、

  1. apt-get install mysql-server mysql-client libmysqlclient15-dev 

2、進入

  1. mysql  mysql -uroot -p 

密碼root

3、重新設(shè)置mysql用戶root的密碼

  1. GRANT ALL PRIVILEGES ON *.* TO root@localhost IDENTIFIED BY "123456"; 

4、創(chuàng)建新數(shù)據(jù)庫 proxy

  1. create database proxy;   

5、創(chuàng)建用戶test 對proxy庫有全部操作權(quán)限

  1. grant all privileges on proxy.* to test@localhost identified by "zhaogongyu"; 

6、允許test用戶可以從任意機器上登入MySQL。

  1. ***步:grant all privileges on proxy.* to test@"%" identified by "zhaogongyu";  
  2.  
  3. 第二步:$sudo gedit /etc/mysql/my.cnf 

老版本

  1. skip-networking => #skip-networking 

新版本

  1. bind-address=127.0.0.1 => bind-address= 你機器的IP 

這樣就可以允許其他機器訪問MySQL了

7、重啟mysql命令

  1. sudo /etc/init.d/mysql restart 

8、開機啟動mysql

  1. vim /etc/rc.local 

將下面這一行加入到***一行

  1. cd /usr/bin; /usr/bin/safe_mysqld --user=root &  
  2. exit 0 

注意:記得加上cd /usr/local/mysql-5.1.36;并在改句后面加個空格,不然會導(dǎo)致無法自動在開機的時候啟動

9、從數(shù)據(jù)庫導(dǎo)出數(shù)據(jù)

  1. mysqldump -uroot -p --default-character-set=latin1 --set-charset=gbk --skip-opt mydatabase > d.sql 

10、創(chuàng)建新庫

  1. create database 'newdata' default character set gbk collate gbk_chinese_ci; 

11、導(dǎo)入數(shù)據(jù)庫

  1. mysql -uroot -p --default-character=gbk -f newmydatabase >source d.sql ..>exit 

安裝讀寫分離 mysql-proxy

一、mysql

  1. 1、apt-get install mysql-server mysql-client libmysqlclient15-dev  
  2.  
  3. 2、進入mysql  mysql -uroot -p 

密碼root

3、重新設(shè)置mysql用戶root的密碼

  1. GRANT ALL PRIVILEGES ON *.* TO root@localhost IDENTIFIED BY "123456"; 

4、創(chuàng)建新數(shù)據(jù)庫 proxy 創(chuàng)建表 prodata

  1. create database proxy;   
  2. CREATE TABLE prodata (name VARCHAR(20), sex CHAR(1)); 

5、創(chuàng)建用戶test 對proxy庫有全部操作權(quán)限

  1. grant all privileges on proxy.* to test@localhost identified by "zhaogongyu"; 

6、允許test用戶可以從任意機器上登入MySQL。

  1. ***步:grant all privileges on proxy.* to test@"%" identified by "zhaogongyu";  
  2.  
  3. 第二步:$sudo gedit /etc/mysql/my.cnf 

老版本

  1. skip-networking => #skip-networking 

新版本

  1. bind-address=127.0.0.1 => bind-address= 你機器的IP 

這樣就可以允許其他機器訪問MySQL了

7、重啟mysql命令

  1. sudo /etc/init.d/mysql restart 

注意: mysql安裝后位置

執(zhí)行文件

  1. /usr/bin/mysql 

數(shù)據(jù)庫

  1. /var/lib/mysql  
  2. /var/log/mysql 

控制文件

  1. /etc/mysql/my.cnf   

數(shù)據(jù)庫命令行相關(guān)操作

2、創(chuàng)建一個數(shù)據(jù)庫MYSQLDATA

  1. mysql> CREATE DATABASE MYSQLDATA; 

3、選擇你所創(chuàng)建的數(shù)據(jù)庫

  1. mysql> USE MYSQLDATA; (按回車鍵出現(xiàn)Database changed 時說明操作成功!) 

4、查看現(xiàn)在的數(shù)據(jù)庫中存在什么表

  1. mysql> SHOW TABLES; 

5、創(chuàng)建一個數(shù)據(jù)庫表

  1. mysql> CREATE TABLE MYTABLE (name VARCHAR(20), sex CHAR(1)); 

6、顯示表的結(jié)構(gòu):

  1. mysql> DESCRIBE MYTABLE; 

7、往表中加入記錄

  1. mysql> insert into MYTABLE values ("hyq","M"); 

8、用文本方式將數(shù)據(jù)裝入數(shù)據(jù)庫表中(例如D:/mysql.txt)

  1. mysql> LOAD DATA LOCAL INFILE "D:/mysql.txt" INTO TABLE MYTABLE; 

9、導(dǎo)入.sql文件命令(例如D:/mysql.sql)

  1. mysql>use database;  
  2. mysql>source d:/mysql.sql; 

10、刪除表

  1. mysql>drop TABLE MYTABLE; 

11、清空表

  1. mysql>delete from MYTABLE; 

12、更新表中數(shù)據(jù)

  1. mysql>update MYTABLE set sex="f" where name='hyq';  
  2.  
  3. http://hi.baidu.com/selfcool/blog/item/a44e101fce79b1f2e0fe0b9d.html 

二、mysql-proxy 

LUA文件介紹

  1. http://www.oreillynet.com/pub/a/databases/2007/07/12/getting-started-with-mysql-proxy.html?page=1 
  2.  
  3. 192.168.1.38  proxy  
  4. 192.168.1.44  slaver  從機  
  5. 192.168.1.55  master  主機  
  6.  
  7. apt-get  mysql-proxy 

配置

1、讀寫分離腳本

修改默認(rèn)連接,進行快速測試,不修改的話要等達到連接數(shù)時才讀寫分離

  1. vim /usr/share/mysql-proxy/rw-splitting.lua  
  2.   proxy.global.config.rwsplit = {  
  3.  min_idle_connections = 1,  #默認(rèn)是4  
  4.  max_idle_connections = 1,  #默認(rèn)是8  
  5.  
  6.  is_debug = false 
  7.   } 

2、執(zhí)行讀寫分離

  1. mysql-proxy  -–proxy-read-only-backend-addresses=10.0.0.6:3306 -–proxy-backend-addresses=10.0.0.5:3306  
  2.  -–proxy-lua-script=/usr/share/mysql-proxy/rw-splitting.lua >/var/log/mysql-proxy/mysql-proxy.log &  
  3.  
  4.  (新建/var/log/mysql-proxy/和mysql-proxy.log 調(diào)整屬性775 屬于chown R mysql.adm  xx組)  
  5.    
  6. (sudo mysql-proxy --proxy-read-only-backend-addresses=192.168.1.44:3306 
  7. --proxy-backend-addresses=192.168.1.55:3306 
  8. --proxy-lua-script=/usr/share/mysql-proxy/rw-splitting.lua >/var/log/mysql-proxy/mysql-proxy.log &  
  9. ) 

 注:當(dāng)運行sudo mysql-proxy 查詢進程后沒有4040時候,需要重啟mysql ( sudo /etc/init.d/mysql restart) 之后在輸入proxy設(shè)置

3、查看進程

  1. netstat -ant  
  2. tcp  00 0.0.0.0:40400.0.0.0:*LISTEN   
  3. tcp  00 0.0.0.0:40410.0.0.0:*LISTEN  

啟動成功

可以遠程連接了,在一臺linux主機上連接,進行一些讀寫操作

4、測試讀寫分離

進入mysql-proxy機子

  1. a@a-desktop:/usr/share/mysql-proxy$ mysql -utest -p -P4040 -h192.168.1.38  
  2. Enter password:  
  3. Welcome to the MySQL monitor.  Commands end with ; or \g.  
  4. Your MySQL connection id is 25  
  5. Server version: 5.0.51a-3ubuntu5.4-log  
  6.  
  7. Type 'help;' or '\h' for help. Type '\c' to clear the buffer.  
  8.  
  9. mysql> use proxy;  
  10. Database changed 

插入一條記錄

  1. mysql> insert into prodata(name) values("zgy");  
  2. Query OK, 1 row affected (0.01 sec)  
  3.  
  4. mysql>select * from proxy;  
  5. Empty set (0.00 sec) 

我們插入了數(shù)據(jù)沒有結(jié)果~這就對了讀寫分離了~~~~

注:有時候mysql_proxy(38)庫里會顯示出數(shù)據(jù),重啟系統(tǒng)系統(tǒng),重新啟動mysql后就沒有此現(xiàn)象了。

進入主寫服務(wù)器(192.168.1.55) 查看數(shù)據(jù)

  1. mysql -utest -p -h192.168.1.55  
  2. use proxy;  
  3. select * from prodata; 

可以查看已經(jīng)寫入了一條記錄

進入從讀服務(wù)器(192.168.1.44)

  1. mysql -utest -p -h192.168.1.44  
  2. use proxy;  
  3. select * from prodata; 

因為沒有數(shù)據(jù)顯示

說明只能讀 不能寫。

小結(jié):Ubuntu 9.04安裝Mysql Proxy Lua測試成功版的內(nèi)容介紹完了,希望通過本文的學(xué)習(xí)能對你有所幫助!

責(zé)任編輯:zhaolei 來源: 互聯(lián)網(wǎng)
相關(guān)推薦

2009-12-31 16:20:14

Ubuntu 9.04

2009-12-31 17:04:58

Ubuntu9.04版

2009-04-18 06:31:35

LinuxUbuntu 9.04發(fā)行版

2011-08-30 11:09:26

MySQL ProxyLua

2011-01-18 16:45:04

Ubuntu

2009-04-22 16:44:55

LinuxUbuntu安裝圖

2011-08-30 10:28:11

MySQL ProxyLUA

2011-08-30 11:00:10

MySQL ProxyLua

2009-04-03 14:30:21

Ubuntu 9.04Linuxbeta版

2010-01-07 15:52:30

Ubuntu skyp

2009-04-24 14:54:32

LinuxUbuntu 9.04正式版

2009-04-24 09:13:15

Ubuntu 9.04正式版鏡像

2010-01-05 17:20:32

Ubuntu 9.04

2010-02-06 15:31:06

Ubuntu9.04

2010-02-06 17:23:44

2010-06-04 15:41:29

安裝MySQL數(shù)據(jù)庫

2010-01-06 09:49:15

Ubuntu-9.04

2009-07-02 08:54:40

UbuntuMozillaFirefox

2018-10-11 14:22:43

2009-03-13 17:00:44

LinuxUbuntu 9.04Alpha 6
點贊
收藏

51CTO技術(shù)棧公眾號