【千鋒云計算公開課】游戲類站點部署:玩轉(zhuǎn)qq農(nóng)場

安裝軟件
yum??-y?install??httpd
?
/etc/httpd???程序主配置目錄
/etc/httpd/conf/httpd.conf??程序主配置文件
?
通過httpd服務(wù)搭建網(wǎng)站
1、安裝軟件
yum??-y?install??httpd??unzip
2、啟動軟件
systemctl?start??httpd
3、上傳代碼并解壓
unzip??bb.zip
4、將代碼復(fù)制到網(wǎng)站發(fā)布目錄內(nèi)
cp???-r????bb/*??????/var/www/html/
5、復(fù)制ip地址并訪問
?
?
虛擬機(jī):
1、修改配置文件,增加端口
vim /etc/httpd/conf/httpd.conf
在Listen 80下方添加一行
Listen 81
2、查找?guī)椭謨?/p>
man /usr/share/doc/httpd-2.4.6/httpd-whasts.conf
<VirtualHost*:@@Port@@>
???????ServerAdmin webmasteredummy-host2example.com
???????DocumentRoot "@@ServerRoot@@/docs/dummy-host2example.com
???????ServerName dmmy-host2example.com
???????ErrorLoq"/var/loq/httpd/dummy-host2examplecom-error loq"
???????CustomLog"/var/log/httpd/dummy-host2example.com-access log'
common</virtualHost>
3、新增配置文件
vim /etc/httpd/conf.d/web.conf
<VirtualHost:01>
???????DocumentRoot /var/www/qqq
???????ServerName rootelocalhost
</VirtualHost>
4、上傳代碼并解壓
unzip zx70.zip
5、創(chuàng)建發(fā)布目錄
mkdir /var/www/gog
6、將代碼復(fù)制到發(fā)布目錄
cp-Izx70/* /var/www/ggg
7、重啟服務(wù),使配置文件生效
systemctl restart httod
8、訪問ip
?
動態(tài)博客網(wǎng)站
LAMP??LNMP
?
L??linux 操作系統(tǒng)
A??apache網(wǎng)站服務(wù)器
M??mysql/mariadb數(shù)據(jù)庫軟件
P??php/python編譯解析語言
?
1、安裝相關(guān)軟件,搭建運行環(huán)境
yum?-y??install httpd?mariadb-server?php?php-mysql gd php-gd unzip
2、啟動相關(guān)軟件
systemctl??start???httpd?mariadb
3、數(shù)據(jù)庫操作
mysql????#進(jìn)入數(shù)據(jù)庫
create?database?wordpress;?#創(chuàng)建數(shù)據(jù)庫wordpress
exit??#退出數(shù)據(jù)庫
4、上傳代碼并解壓
unzip??wordpress.zip
5、將代碼復(fù)制到發(fā)布目錄
cp??-r???wordpress/*??/var/www/html/
6、更改目錄權(quán)限
chown?apache.apache??/var/www/html/?-R
7、訪問ip地址
?
LNMP部署
Nginx???
https://nginx.org/?nginx官網(wǎng)
1、安裝nginx源
vim??/etc/yum.repos.d/nginx.repo
?
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
2、安裝相關(guān)軟件,配置運行環(huán)境
yum??-y?install unzip nginx mariadb-server?php?php-fpm php-mysql php-intl php-curl
3、啟動相關(guān)軟件
systemctl??start??mariadb
4、數(shù)據(jù)庫操作
mysql
create?database?farm;
exit
5、修改nginx配置文件
vim???/etc/nginx/conf.d/default.conf
?
server {
????listen??????80;
????server_name?localhost;
????location / {
????????root??/farm;
????????index?index.php index.html index.htm;
????}
????location ~ \.php$ {
????????root??????????/farm;
????????fastcgi_pass??127.0.0.1:9000;
????????fastcgi_index?index.php;
????????fastcgi_param?SCRIPT_FILENAME?$document_root$fastcgi_script_name;
????????include???????fastcgi_params;
????}
}
6、檢查nginx配置文件
nginx -t?
7、修改php配置文件
vim??/etc/php.ini
修改211行,Off改為ON
8、啟動相關(guān)服務(wù)
systemctl??start??nginx?php-fpm
9、上傳代碼并解壓
unzip?farm-ucenter1.5.zip
10、復(fù)制發(fā)布目錄
cp?-r??upload???/farm
11、將sql文件導(dǎo)入到數(shù)據(jù)庫內(nèi)
mysql?-uroot?-p???farm?<?/farm/qqfarm.sql
12、修改發(fā)布目錄權(quán)限
chmod???777??/farm/?-R
13、訪問ip
?
數(shù)據(jù)庫主從復(fù)制??AB復(fù)制
主從復(fù)制原理:
主數(shù)據(jù)庫開啟bin-log日志,將所有的操作記錄在bin-log日志內(nèi)
從數(shù)據(jù)庫開啟一個I/O線程,拉取主數(shù)據(jù)庫的bin-log日志內(nèi)容
從數(shù)據(jù)庫同時啟動一個中繼日志,將I/O線程拉取拉取的數(shù)據(jù)進(jìn)行保存
最后,從數(shù)據(jù)庫啟動一個sql線程,執(zhí)行中繼日志的內(nèi)容。
?
主從復(fù)制的實現(xiàn):
環(huán)境說明:
192.168.200.128??master?主數(shù)據(jù)庫
192.168.200.129??slave??從數(shù)據(jù)庫
?
兩臺機(jī)器都需要的操作
1、配置本地解析
vim??/etc/hosts
?
192.168.200.128 master
192.168.200.129 slave
2、安裝數(shù)據(jù)庫軟件
yum?-y?install?mariadb-server
?
?
主數(shù)據(jù)庫操作:
1、開啟bin-log日志
vim?/etc/my.cnf
?
[mysqld]
log-bin=/var/log/mysql/mysql-bin
server-id=1
2、創(chuàng)建日志目錄
mkdir?/var/log/mysql
3、更改日志目錄屬主與屬組
chown??mysql.mysql?/var/log/mysql/
4、啟動數(shù)據(jù)庫
systemctl?start??mariadb
5、數(shù)據(jù)庫操作
mysql
grant?replication slave on *.* to 'abc'@'192.168.200.129' identified by 'Qf@123';
flush privileges;??
?
show??master??status\G
****** 1. row ***********
????????????File: mysql-bin.000003
????????Position: 476
????Binlog_Do_DB:
Binlog_Ignore_DB:
1 row in set (0.00 sec)
?
從數(shù)據(jù)庫操作:
1、修改配置文件
vim??/etc/my.cnf
?
[mysqld]
server-id=2
2、啟動數(shù)據(jù)庫
systemctl?start??mariadb
3、測試abc用戶
mysql -uabc -p'Qf@123'?-hmaster
exit
4、數(shù)據(jù)庫操作
mysql
change master to?????master_host='master',master_user='abc',master_password='Qf@123',master_log_file='mysql-bin.000003',master_log_pos=476;
start?slave;?啟動主從復(fù)制
show?slave?status\G
?????????????Slave_IO_Running: Yes
????????????Slave_SQL_Running: Yes
?
互為主從
將主從復(fù)制的步驟,反過來做一遍
?
?
zabbix
?
1、安裝zabbix源
rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
2、修改zabbix源
vim????/etc/yum.repos.d/zabbix.repo
?
將[zabbix-frontend]下
enabled=0改為enabled=1
3、安裝相關(guān)軟件
yum?-y?install mariadb-server zabbix-server-mysql zabbix-agent??centos-release-scl????zabbix-web-mysql-scl?zabbix-apache-conf-scl?--skip-broken
4、啟動數(shù)據(jù)庫
systemctl?start??mariadb
5、數(shù)據(jù)庫操作
create??database??zabbix character set utf8 collate utf8_bin;
grant all on zabbix.* to zabbix@localhost identified by '12345';
flush??privileges;
exit
6、導(dǎo)入初始化數(shù)據(jù)
zcat?/usr/share/doc/zabbix-server-mysql-5.0.35/create.sql.gz???|??mysql?-uzabbix??-p??zabbix
7、更改zabbix配置文件
vim??/etc/zabbix/zabbix_server.conf
?
將91行注釋打開
在125行輸入 DBPassword=12345
8、修改php相關(guān)配置文件
vim?/etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
最后一行插入
php_value[date.timezone] = Asia/Shanghai
9、啟動相關(guān)服務(wù)
systemctl?start?zabbix-server zabbix-agent httpd rh-php72-php-fpm
10、瀏覽器訪問ip地址
?
ip/zabbix
Admin/zabbix
?
?
如果需要被zabbix-server進(jìn)行監(jiān)控
請執(zhí)行以下操作
?
zabbix-agent部署
1、安裝zabbix源
rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
2、安裝相關(guān)軟件
yum?-y?install?zabbix-agent?zabbix-sender
3、修改zabbix-agent配置文件
vim??/etc/zabbix/zabbix_agentd.conf
?
117行Server=zabbix-server的ip地址
163行ServerActive=zabbix-server的ip地址
174行Hostname=web1
4、啟動agent服務(wù)
systemctl??start???zabbix-agent