mysq places to be aware of:
MySQLthe master-slave replication delay comes from the SQL thread(Workaround: myslq5.7 can be set to multi-threaded parallel)
Database monitoring: Lepus
Deletion of a large database (a safe and fast way to remove a part of the method) ( Deleting delete drops that do not recommend brute force will cause master-slave inconsistency )
expire_log_days 0 (the default database is not deleted)
Set global expire_logs_days=7 (deleted after seven days)
TIDB (distributed)
Data backup must be done on the slave to avoid aggravating the burden of master
Database caching: The drawback of Redis (NoSQL: Data cannot be persisted because it works in memory and has limited memory capacity advantages: Fast But Redis can keep data working in memory data will be saved on disk)
Read/write Separation: Add proxy (Database access layer proxy)
NoSQL databases can connect directly to a Redis (super fast)
But the data is related to the data, so you have to connect to MySQL:
Client (KV)-->redis--(hook function) >mysql
High concurrency MySQL: (definitely go to read/write separation)
Client-to-middle key (specially developed to do distribution to confirm customer demand because LVS does not understand these only do forwarding)-->lvs (development: equivalent route extension multiple LVs)-->nginx (multiple one LVS corresponds to one nginx)-->BD ( Cluster
Database Cache: (Redis)
Three virtual machines:
DD1: (nginx php)
To see if you have previously installed:
Rpm-qa | grep php
Rpm-qa | grep httpd
650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M00/8F/7E/wKiom1jhAmewMgJTAAGNH05U8Yk702.png-wh_500x0-wm_ 3-wmp_4-s_2939365003.png "title=" 1.png "alt=" Wkiom1jhamewmgjtaagnh05u8yk702.png-wh_50 "/>
Yum Install-y nginx-1.8.0-1.el6.ngx.x86_64.rpm
RPM-IVH php-cli-5.3.3-38.el6.x86_64.rpm php-common-5.3.3-38.el6.x86_64.rpm
RPM-IVH php-mysql-5.3.3-38.el6.x86_64.rpmphp-pdo-5.3.3-38.el6.x86_64.rpm
Yum Install php-5.3.3-38.el6.x86_64.rpm
Cd/etc/php-fpm.d
Vim www.conf ( change user name user group Nginx)
/etc/init.d/php-fpm Start
650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M00/8F/7C/wKioL1jhAnDBSsowAAFTOzStBUk185.png-wh_500x0-wm_ 3-wmp_4-s_2109756329.png "title=" 2.png "alt=" Wkiol1jhandbssowaaftozstbuk185.png-wh_50 "/>
Netstat-antlpe | grep php
650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M01/8F/7E/wKiom1jhAnmid3N9AACkR1TnbiI410.png-wh_500x0-wm_ 3-wmp_4-s_3281877631.png "title=" 3.png "alt=" Wkiom1jhanmid3n9aackr1tnbii410.png-wh_50 "/>
Cd/etc/nginx/conf.d
Vim default.conf (nginx Open PHP module)
650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M02/8F/7E/wKiom1jhAoGRm-jEAADgCYoPUck705.png-wh_500x0-wm_ 3-wmp_4-s_317977047.png "title=" 4.png "alt=" Wkiom1jhaogrm-jeaadgcyopuck705.png-wh_50 "/>
Nginx-t
Nginx (Open Nginx)
Netstat-antlpe | grep nginx
650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M01/8F/7C/wKioL1jhAorgDtzwAAE5NirQk64571.png-wh_500x0-wm_ 3-wmp_4-s_3740378957.png "title=" 5.png "alt=" Wkiol1jhaorgdtzwaae5nirqk64571.png-wh_50 "/>
cd/usr/share/nginx/html/
test: Nginx PHP is installed successfully
650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M02/8F/7C/wKioL1jhApfAYTE4AADwoPbrEmM207.png-wh_500x0-wm_ 3-wmp_4-s_1270623822.png "title=" 6.png "alt=" Wkiol1jhapfayte4aadwopbremm207.png-wh_50 "/>
Dd3:yum Install Mysql-server-y (version is too low for testing purposes only)
/etc/init.d/mysqld start
DD1:SCP redis-3.2.5.tar.gz [email protected]:
DD2:
Tar zxf redis-3.2.5.tar.gz
CD redis-3.2.5
Make && make install
CD Utils
./install_server.sh
Netstat–antlpe
650) this.width=650; "Src=" Https://s5.51cto.com/wyfs02/M02/8F/7E/wKiom1jhAqCDkunvAAETaHm5bjc916.png-wh_ 500x0-wm_3-wmp_4-s_3496257997.png "title=" 7.png "alt=" wkiom1jhaqcdkunvaaetahm5bjc916.png-wh_50 "/>
Cd/etc/redis
vim 6379.conf ( bind listening port)
/etc/init.d/redis_6379 Restart
redis-cli
650) this.width=650; "Src=" Https://s2.51cto.com/wyfs02/M02/8F/7C/wKioL1jhAqrgTCKsAAEdIS-XAEg854.png-wh_ 500x0-wm_3-wmp_4-s_1464835780.png "title=" 8.png "alt=" wkiol1jhaqrgtcksaaedis-xaeg854.png-wh_50 "/>
Dd1: php load Redis module )
650) this.width=650; "Src=" Https://s2.51cto.com/wyfs02/M00/8F/7E/wKiom1jhArqzhKtJAAFgrV_6ZuY446.png-wh_ 500x0-wm_3-wmp_4-s_515616862.png "title=" 9.png "alt=" wkiom1jharqzhktjaafgrv_6zuy446.png-wh_50 "/>
Yum Install unzip-y
Unzip phpredis-master.zip
Yum install php-devel-5.3.3-38.el6.x86_64.rpm
CD Phpredis-master
Phpize ( Specify Module installation path)
650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M00/8F/7E/wKiom1jhAsmwQDoiAAE2v7OLbmE234.png-wh_500x0-wm_ 3-wmp_4-s_3391510604.png "title=" 10.png "alt=" Wkiom1jhasmwqdoiaae2v7olbme234.png-wh_50 "/>
./configure
Make && make install
Vim/etc/php.ini (change time zone)
650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M00/8F/7C/wKioL1jhAtHwVMbEAAD8HCIHQCg935.png-wh_500x0-wm_ 3-wmp_4-s_2190195714.png "title=" 11.png "alt=" Wkiol1jhathwvmbeaad8hcihqcg935.png-wh_50 "/>
Cd/etc/php.d
CP Mysql.ini Redis.ini
Vim Redis.ini
650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M01/8F/7E/wKiom1jhAtzxXJKgAABAgErk6ag915.png-wh_500x0-wm_ 3-wmp_4-s_3615754169.png "title=" 12.png "alt=" Wkiom1jhatzxxjkgaabagerk6ag915.png-wh_50 "/>
/ETC/INIT.D/PHP-FPM Reload
php-m | grep Redis(see if the loading module was successful)
650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M00/8F/7C/wKioL1jhAuWwsoyAAAE7w2vPlf0257.png-wh_500x0-wm_ 3-wmp_4-s_3031358144.png "title=" 13.png "alt=" Wkiol1jhauwwsoyaaae7w2vplf0257.png-wh_50 "/>
CP test.php/usr/share/nginx/html/index.php(Test page)
vim/usr/share/nginx/html/index.php
650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M01/8F/7E/wKiom1jhAvGQcXUAAAD7rjsrzU0359.png-wh_500x0-wm_ 3-wmp_4-s_173637743.png "title=" 14.png "alt=" Wkiom1jhavgqcxuaaad7rjsrzu0359.png-wh_50 "/>
SCP Test.sql 172.25.42.12: (Redis)(Database content)
DD3:
Grant Select on test.* to [email protected] ' 172.25.42.% ' identified by ' Westos '
650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M01/8F/7C/wKioL1jhAvyRDOoHAAEUGwkYXbo301.png-wh_500x0-wm_ 3-wmp_4-s_732545259.png "title=" 15.png "alt=" Wkiol1jhavyrdoohaaeugwkyxbo301.png-wh_50 "/>
SELECT * FROM Test
650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M02/8F/7E/wKiom1jhAwTBZEYWAAC1jlGATdo092.png-wh_500x0-wm_ 3-wmp_4-s_1750932809.png "title=" 16.png "alt=" Wkiom1jhawtbzeywaac1jlgatdo092.png-wh_50 "/>
Test:
Page test: The first access is the database second, this access is the cache
650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M01/8F/7C/wKioL1jhAw3At3YdAABfsCVYpco223.png-wh_500x0-wm_ 3-wmp_4-s_2042010657.png "title=" 17.png "alt=" Wkiol1jhaw3at3ydaabfscvypco223.png-wh_50 "/>
BUG: If you update the contents of MySQL database, the cache will not be aware that the contents of the data will not change, when the user accesses, the old content is cached, only the old data in the cache can be manually deleted to re-update
Update test set name= ' Westos ' where ID =1
650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M02/8F/7E/wKiom1jhAxzSoY07AACtNPA3jDw840.png-wh_500x0-wm_ 3-wmp_4-s_1352197231.png "style=" Float:none; "title=" 18.png "alt=" Wkiom1jhaxzsoy07aactnpa3jdw840.png-wh_50 "/> 650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M02/8F/7C/wKioL1jhAxyzX_5HAABjf0dc36w670.png-wh_500x0-wm_ 3-wmp_4-s_1318228311.png "title=" 19.png "style=" Float:none; alt= "Wkiol1jhaxyzx_5haabjf0dc36w670.png-wh_50"/>
Redis Master : (Backup) Redis is a single-process solution: Run multiple processes to bind the process to the CPU
DD3: (Different services different ports in order to avoid multiple open virtual machine on the dd3 above do ~)
Tar zxf redis-3.2.5.tar.gz
CD redis-3.2.5
Make && make install (yum install gcc-y)
CD utils/
./install_server.sh
650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M00/8F/7E/wKiom1jhAyrT5zKtAAFH-C1HcHw950.png-wh_500x0-wm_ 3-wmp_4-s_1669473470.png "title=" 20.png "alt=" Wkiom1jhayrt5zktaafh-c1hchw950.png-wh_50 "/>
cd/etc/redis/
Vim 6379.conf (slaveof)
650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M02/8F/7C/wKioL1jhAzSQ69pTAAFxtwlmet8828.png-wh_500x0-wm_ 3-wmp_4-s_2257619239.png "title=" 21.png "alt=" Wkiol1jhazsq69ptaafxtwlmet8828.png-wh_50 "/>
/etc/init.d/redis_6379 restart
Test: REDIS-CLI
Master-Slave Switching: (one main and more from a master double)
DD1: (Different services different ports in order to avoid multiple open virtual machine on the dd1 above do ~)
Tar zxf redis-3.2.5.tar.gz
CD redis-3.2.5
Make && make install (yum install gcc-y)
CD utils/
./install_server.sh
cd/etc/redis/
Vim 6379.conf (slaveof)
650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M00/8F/7C/wKioL1jhA0CjqRc4AAFikmwaGJ0368.png-wh_500x0-wm_ 3-wmp_4-s_1264869591.png "title=" 22.png "alt=" Wkiol1jha0cjqrc4aafikmwagj0368.png-wh_50 "/>
/etc/init.d/redis_6379 restart
650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M00/8F/7E/wKiom1jhA0zQ6HGlAAEPMAqDLEs809.png-wh_500x0-wm_ 3-wmp_4-s_1867540460.png "title=" 23.png "alt=" Wkiom1jha0zq6hglaaepmaqdles809.png-wh_50 "/>
CD redis-3.2.5
CP Sentinel.conf/etc/redis
Vim sentinel.conf
650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M00/8F/7C/wKioL1jhA12h7T1VAAFznNAHtZc584.png-wh_500x0-wm_ 3-wmp_4-s_3727346085.png "style=" Float:none; "title=" 24.png "alt=" Wkiol1jha12h7t1vaafznnahtzc584.png-wh_50 "/>
650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M01/8F/7E/wKiom1jhA16ipOzrAAEvc00HHWA332.png-wh_500x0-wm_ 3-wmp_4-s_3789851163.png "style=" Float:none; "title=" 25.png "alt=" Wkiom1jha16ipozraaevc00hhwa332.png-wh_50 "/>
650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M01/8F/7C/wKioL1jhA32zDsg3AAFBHxUmwrQ955.png-wh_500x0-wm_ 3-wmp_4-s_1870564986.png "style=" Float:none; "title=" 26.png "alt=" Wkiol1jha32zdsg3aafbhxumwrq955.png-wh_50 "/>
SCP sentinel.conf [Email protected]:/etc/redis/
SCP sentinel.conf [Email protected]:/etc/redis/
Redis-server/etc/redis/sentinel.conf--sentinel (three all do) (A new monitoring port will open)
Views: Redis-cli-p 26379 (26379: Monitor every port
650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M01/8F/7C/wKioL1jhA56xg7rTAADruEHgQnU711.png-wh_500x0-wm_ 3-wmp_4-s_2796062956.png "title=" 27.png "alt=" Wkiol1jha56xg7rtaadruehgqnu711.png-wh_50 "/>
Redis-cli
127.0.0.1:6379> Monitor (Masterevery second to slave the contract)
650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M02/8F/7E/wKiom1jhA6qB5JBFAAGGwrt3vwo396.png-wh_500x0-wm_ 3-wmp_4-s_3280668141.png "title=" 28.png "alt=" Wkiom1jha6qb5jbfaaggwrt3vwo396.png-wh_50 "/>
MySQL Cache (Redis)