In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Lamp architecture = LAMP refers to the first letters of Linux (operating system), Apache (HTTP server), MySQL (database software), and PHP (sometimes Perl or Python), generally used to build web servers.
# install php# with source code
Tar jxf php-5.6.20.tar.bz2
Cd php-5.6.20
Resolve dependencies:
Yum install freetype-devel libmcrypt-2.5.8-9.el6.x86_64.rpm net-snmp-devel libmcrypt-devel-2.5.8-9.el6.x86_64.rpm libpng-devel gmp-devel libjpeg-turbo-devel libcurl-devel libxml2-devel-y
Detect dependencies:
[root@server1 php-5.6.20] # / configure-prefix=/usr/local/lnmp/php-- with-config-file-path=/usr/local/lnmp/php/etc-- with-openssl-- with-snmp-- with-gd-- with-zlib-- with-curl-- with-libxml-dir-- with-png-dir-- with-jpeg-dir-- with-freetype-dir-- without-pear-- with-gettext-- with-gmp-- enable-inline -optimization-enable-soap-enable-ftp-enable-sockets-enable-mbstring-enable-fpm-with-fpm-user=nginx-with-fpm-group=nginx-with-mcrypt-with-mhash-with-mysql-with-mysqli-with-pdo-mysql-enable-mysqlnd
After you have not reported an error, you can do the following:
[root@server1 php-5.6.20] # make & & make install
[root@server1 php-5.6.20] # cp php.ini-production / usr/local/lnmp/php/etc/php.ini
[root@server1 php-5.6.20] # cd / usr/local/lnmp/php/etc/
[root@server1 etc] # cp php-fpm.conf.default php-fpm.conf
Cd / mnt/php-5.6.20/sapi/fpm/
[root@server1 fpm] # cp init.d.php-fpm / etc/init.d/php-fpm
[root@server1 fpm] # chmod + x / etc/init.d/php-fpm
[root@server1 fpm] # cd / usr/local/lnmp/php/etc/
[root@server1 etc] # vim php-fpm.conf# uncomment 25 lines
25 pid = run/php-fpm.pid
[root@server1 etc] # vim php.ini # # modify the time zone
925 date.timezone = 'Asia/Shanghai'
[root@server1 etc] # / etc/init.d/php-fpm start
Starting php-fpm done
[root@server1 etc] # cd / usr/local/
[root@server1 local] # cd nginx/sbin/
[root@server1 sbin] # ls
Nginx
[root@server1 sbin] # pwd
/ usr/local/nginx/sbin
[root@server1 sbin] # vim ~ / .bash_profile
PATH=$PATH:$HOME/bin:/usr/local/lnmp/mysql/bin
[root@server1 sbin] # source ~ / .bash_profile
[root@server1 sbin] # nginx-t
Nginx: the configuration file / usr/local/nginx/conf/nginx.conf syntax is ok
Nginx: configuration file / usr/local/nginx/conf/nginx.conf test is successful
Cd / usr/local/nginx/conf
[root@server1 conf] # vim nginx.conf
49 location / {
50 root html
51 index index.php index.html index.htm;# adjusts priority, first look at index.php
52}
71 location ~\ .php$ {
72 root html
73 fastcgi_pass 127.0.0.1:9000
74 fastcgi_index index.php
75 fastcgi_param SCRIPT_FILENAME / scripts$fastcgi_script_name
76 include fastcgi.conf
[root@server1 conf] # nginx
[root@server1 conf] # nginx-t
Nginx: the configuration file / usr/local/nginx/conf/nginx.conf syntax is ok
Nginx: configuration file / usr/local/nginx/conf/nginx.conf test is successful
[root@server1 conf] # cd..
[root@server1 nginx] # cd html/
[root@server1 html] # vim nginx.php
Find the cache file of the current host mysql
[root@server1 mysql] # ll / var/lib/mysql/mysql.sock
Srwxrwxrwx 1 mysql mysql 0 March 23 17:16 / var/lib/mysql/mysql.sock
Cd / usr/local/lnmp/php/etc
[root@server1 etc] # vim php.ini
# default data is stored in the file / var/lib/mysql/mysql.sock
1001 pdo_mysql.default_socket=/var/lib/mysql/mysql.sock
1150 mysql.default_socket = / var/lib/mysql/mysql.sock
1209 mysqli.default_socket = / var/lib/mysql/mysql.sock
[root@server1 etc] # / etc/init.d/php-fpm reload
Reload service php-fpm done
Test:
Php installed successfully!
Heartbeat + mysql + drbd
The three parts provide high availability, database, and storage services, respectively. Integrate the subsequent forums into a complete system
Description: server3,server4 provides the above three services
1 database
Direct yum install mysql-server-y # server3 and server4 both do
Mysql_secure_installation# security initialization, set the root password, otherwise the database can log in without a password
2.Heartbeat
[root@server3 heartbeat] # ls
Heartbeat-3.0.4-2.el6.x86_64.rpm heartbeat-libs-3.0.4-2.el6.x86_64.rpm
Heartbeat-devel-3.0.4-2.el6.x86_64.rpm ldirectord-3.9.5-3.1.x86_64.rpm
All Server3,server4 must be installed.
[root@server3 heartbeat] # yum install *-y
[root@server3 heartbeat] # cd / etc/ha.d/
[root@server3 ha.d] # ls
Harc rc.d README.config resource.d shellfuncs
[root@server3 ha.d] # cp / usr/share/doc/heartbeat-3.0.4/ {authkeys,ha.cf,haresources}.
[root@server3 ha.d] # vim ha.cf
48 keepalive 2
56 deadtime 30
76 udpport 1111
91 bcast eth0
157 auto_failback on
211 node server3.example.com
212 node server4.example.com
222 ping 172.25.50.250
254 respawn hacluster / usr/lib64/heartbeat/ipfail
262 apiauth ipfail gid=haclient uid=hacluster
[root@server3 ha.d] # vim authkeys
23 auth 1
24 1 crc
25 # 2 sha1 HI!
26 # 3 md5 Hello!
[root@server3 ha.d] # vim haresources
Add at the end of the file:
Server3.example.com IPaddr::172.25.50.200/24/eth0 drbddisk::homework Filesystem::/dev/drbd2::/var/lib/mysql::ext4 mysqld
# # you can use server3.example.com IPaddr::172.25.50.200/24/eth0 mysqld for testing (the above is for drbd)
[root@server3 ha.d] # scp ha.cf haresources authkeys 172.25.50.40:/etc/ha.d/
Restart heartbeat on both sides
3.drbd shared memory
Assign a 4G virtual disk to both server3 and server4
[root@server3 mnt] # fdisk-l
Disk / dev/vdb: 4294 MB, 4294967296 bytes
16 heads, 63 sectors/track, 8322 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
[root@server4 drbd] # fdisk-l
Disk / dev/vda: 4294 MB, 4294967296 bytes
16 heads, 63 sectors/track, 8322 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Install the following rpm packages
Drbd-8.4.2-2.el6.x86_64.rpm
Drbd-bash-completion-8.4.2-2.el6.x86_64.rpm
Drbd-heartbeat-8.4.2-2.el6.x86_64.rpm
Drbd-km-2.6.32_431.el6.x86_64-8.4.2-2.el6.x86_64.rpm
Drbd-pacemaker-8.4.2-2.el6.x86_64.rpm
Drbd-udev-8.4.2-2.el6.x86_64.rpm
Drbd-utils-8.4.2-2.el6.x86_64.rpm
Drbd-xen-8.4.2-2.el6.x86_64.rpm
[root@server3 drbd] # rpm-ivh *
Server4 also needs to install these rpm packages
[root@server3 mnt] # cd / etc/drbd.d/
[root@server3 drbd.d] # ls
Global_common.conf
[root@server3 drbd.d] # vim homework.res
[root@server3 drbd.d] # cat homework.res
Resource homework {
Meta-disk internal
Shared disk name customized by device / dev/drbd2;#
Syncer {verify-alg sha1
}
Hostname of on server3.example.com {# node
Disk / dev/vdb;# itself will be used to set the disk path to the share
Address 172.25.50.30 7789 Ten # Node ip
}
On server4.example.com {
Disk / dev/vda
Address 172.25.50.40:7789
}
}
In this way, you don't have to worry about how to solve the problem of publishing different names of shared disks.
[root@server3 drbd.d] # scp homework.res 172.25.50.40:/etc/drbd.d/
[root@server3 drbd.d] # drbdadm create-md homework
# # both server3 and server4
-- = Thank you for participating in the global usage survey = =--
The server's response is:
Writing meta data...
Initializing activity log
NOT initializing bitmap
New drbd meta data block successfully created.
[root@server3 drbd.d] # / etc/init.d/drbd start#server4 starts simultaneously
Starting DRBD resources: [
Create res: homework
Prepare disk: homework
Adjust disk: homework
Adjust net: homework
]
[root@server3 drbd.d] # cat / proc/drbd
Version: 8.4.2 (api:1/proto:86-101)
GIT-hash: 7ad5f850d711223713d6dcadc3dd48860321070c build by root@server1.example.com, 2017-02-21 09:59:13
1: cs:Connected ro:Secondary/Secondary ds:Inconsistent/Inconsistent C r-
Ns:0 nr:0 dw:0 dr:0 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:4194140
[root@server3 drbd.d] # drbdadm primary homework-- force
[root@server3 drbd.d] # mkfs.ext4 / dev/drbd2
[root@server3 mnt] # mount/ dev/drbd2 / mnt/mount/
[root@server3 mnt] # cd mount/
[root@server3 mount] # ls
Lost+found
[root@server3 mount] # touch 111
[root@server3 mount] # ls
111 lost+found
[root@server3 mount] # cd..
[root@server3 mnt] # umount / mnt/mount/
[root@server3 mnt] # drbdadm secondary homework
[root@server4 drbd.d] # drbdadm primary homework
[root@server4 drbd.d] # vim homework.res
[root@server4 drbd.d] # mount/ dev/drbd2 / mnt/mount/
[root@server4 drbd.d] # cd / mnt/mount/
[root@server4 mount] # ls
111 lost+found
[root@server4 mnt] # umount / mnt/mount/
[root@server4 mnt] # drbdadm secondary homework
You can see the files created on server3 in the mounted directory, indicating that the distributed shared storage configuration is successful.
Heartbeat+mysql
Turn off the heartbeat service for two virtual machines
[root@server3 mnt] # / etc/init.d/mysqld stop
[root@server3 mnt] # drbdadm primary homework
[root@server3 mnt] # mount/ dev/drbd2 / mnt/mount/
[root@server3 mount] # cd / var/lib/mysql/
[root@server3 mysql] # cp-r * / mnt/mount/
[root@server3 ~] # umount / mnt/mount/
[root@server3 ~] # mount / dev/drbd2 / var/lib/mysql/
[root@server3] # chown mysql.mysql / var/lib/mysql/-R
[root@server3 ~] # / etc/init.d/mysqld start
Starting mysqld: [OK]
[root@server3 ~] # cd
[root@server3 ~] # / etc/init.d/mysqld stop
Stop mysqld: [OK]
[root@server3 ~] # umount / var/lib/mysql/
[root@server3 ~] # drbdadm secondary homework
Turning on the heartbeat service of server3,server4 will automatically open the service, when the heatbeat service of server3 is turned off. Vip:172.25.50.200 will be transferred to server4.
Finally:
Integration
Now let's build a forum.
[root@server1 mnt] # unzip Discuz_X3.2_SC_UTF8.zip-d / usr/local/nginx/html/
# # unzip this forum package in the default release directory of nginx
[root@server1 mnt] # cd / usr/local/nginx/html/
[root@server1 html] # ls
50x.html index.html nginx.php readme upload utility
[root@server1 html] # cd upload/
[root@server1 upload] # ls
Admin.php connect.php forum.php member.php search.php uc_server
Api cp.php group.php misc.php source userapp.php
Api.php crossdomain.xml home.php plugin.php static
Archiver data index.php portal.php template
Config favicon.ico install robots.txt uc_client
[root@server1 upload] # chmod 777 config/
[root@server1 upload] # chmod 777 data/-R
[root@server1 upload] # chmod 777 uc_*-R
Set the permissions that root users can log in remotely on serer3
Grant all privileges on *. * to "root" @ "%" identified by "redhat"
Query OK, 0 rows affected (0.00 sec)
Test method, remote login to 172.25.50.200 of the ip database on serer1
And have the permission to solve in the database.
On the browser: 172.25.50.10/upload/
Database write test: on server3
High availability tests:
Turn off the heartbeat service on server3.
As shown in the figure, you can see that after the heartbeat service is stopped, sererv4 automatically takes over the database, and the database content is the same as what you saw on server3!
The experiment was successful!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
Explainmysql > explain select host,user,plugin from user; +-+-
© 2024 shulou.com SLNews company. All rights reserved.