文章目录
- Nginx做负载均衡服务器,配置动静分离3. 在134主机主机部署lnmp,在动态资源4.1 在128主机安装httpd,做静态资源4.2 在129主机源码安装nginx并配置负载均衡器,进行调度5. 配置负载均衡,129主机
后端RS服务器?台部署LNMP(nginx1.22+MySQL8.0+php8.0),?台部署httpd 。要求nginx和php使?编译安装最后要通过访问nginx负载均衡服务器的IP看到动静分离的效果 。2. 环境和提供软件包2.1 提供软件包[root@node6 ~]# wget https://nginx.org/download/nginx-1.22.0.tar.gz https://www.php.NET/distributions/php-8.0.23.tar.gz[root@node6 ~]# lsanaconda-ks.cfgnginx-1.22.0.tar.gzmysql-8.0.20-linux-glibc2.12-x86_64.tar.xzphp-8.0.23.tar.gz[root@node6 ~]#2.2 环境 ip
安装的服务
node6
192.168.232.134
lnmp,动态资源
node3
192.168.232.128
nginx,静态资源
node2
192.168.232.129
nginx,做负载均衡
- 关闭防火墙
[root@node6 ~]# systemctl disable --now firewalldRemoved /etc/systemd/system/multi-user.target.wants/firewalld.service.Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.[root@node6 ~]# vim /etc/selinux/config [root@node6 ~]# setenforce 0[root@node3 ~]# systemctl disable --now firewalldRemoved /etc/systemd/system/multi-user.target.wants/firewalld.service.Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.[root@node3 ~]# setenforce 0[root@node3 ~]# vi /etc/selinux/config[root@node2 ~]# systemctl disable --now firewalldRemoved /etc/systemd/system/multi-user.target.wants/firewalld.service.Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.[root@node2 ~]# setenforce 0[root@node2 ~]# vi /etc/selinux/config3. 在134主机主机部署lnmp,在动态资源3.1 源码安装nginx创建系统用户nginx[root@node6 ~]# useradd -r -M -s /sbin/nologin nginx[root@node6 ~]# 安装依赖环境[root@node6 ~]# yum -y groups mark install 'Development Tools'[root@node6 ~]# yum -y install pcre-devel openssl openssl-devel gd-devel gcc gcc-c++ make 创建日志存放目录[root@node6 ~]# mkdir -p /var/log/nginx[root@node6 ~]# chown -R nginx.nginx /var/log/nginx[root@node6 ~]# ll -d /var/log/nginxdrwxr-xr-x. 2 nginx nginx 6 Sep5 18:43 /var/log/nginx编译安装[root@node6 ~]# tar xf nginx-1.22.0.tar.gz [root@node6 ~]# cd nginx-1.22.0[root@node6 nginx-1.22.0]# ./configure--prefix=/usr/local/nginx--user=nginx--group=nginx--with-debug--with-http_ssl_module--with-http_realip_module--with-http_image_filter_module--with-http_gunzip_module--with-http_gzip_static_module--with-http_stub_status_module--http-log-path=/var/log/nginx/access.log--error-log-path=/var/log/nginx/error.log[root@node6 nginx-1.22.0]# make [root@node6 nginx-1.22.0]# make installnginx安装后配置[root@node6 ~]# echo 'export PATH=/usr/local/nginx/sbin:$PATH' > /etc/profile.d/nginx.sh[root@node6 ~]# source /etc/profile.d/nginx.sh启动nginx[root@node6 ~]# nginx [root@node6 ~]# ss -antlStateRecv-Q Send-QLocal Address:PortPeer Address:Port Process LISTEN 01280.0.0.0:220.0.0.0:*LISTEN 01280.0.0.0:800.0.0.0:*LISTEN 0128[::]:22[::]:*[root@node6 ~]# nginx -s stop[root@node6 ~]# ss -antlStateRecv-Q Send-QLocal Address:PortPeer Address:Port Process LISTEN 01280.0.0.0:220.0.0.0:*LISTEN 0128[::]:22[::]:*[root@node6 ~]#- 可以访问

文章插图
3.2 二进制安装MySQL【nginx做负载均衡服务器,配置动静分离 保姆级教程】
安装依赖包,创建用户,并解压[root@node6 ~]# yum -y install ncurses-devel openssl-devel openssl cmake mariadb-devel ncurses-compat-libs[root@node6 ~]# useradd -r -M -s /sbin/nologin mysql[root@node6 ~]# tar xf mysql-8.0.20-linux-glibc2.12-x86_64.tar.xz -C /usr/local/修改属主[root@node6 ~]# cd /usr/local/[root@node6 local]# lsbinincludelibexecsbinetclibmysql-8.0.20-linux-glibc2.12-x86_64sharegameslib64nginxsrc[root@node6 local]# mv mysql-8.0.20-linux-glibc2.12-x86_64 mysql[root@node6 local]# chown -R mysql.mysql mysql[root@node6 local]# ll -d mysqldrwxr-xr-x. 9 mysql mysql 129 Sep5 19:02 mysql配置环境变量,man文档,lib库,头文件[root@node6 ~]# echo 'export PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh[root@node6 ~]# source /etc/profile.d/mysql.sh[root@node6 ~]# vim /etc/ld.so.conf.d/mysql.conf[root@node6 ~]# ldconfig [root@node6 ~]# cat /etc/ld.so.conf.d/mysql.conf/usr/local/mysql/lib[root@node6 ~]# ln -s /usr/local/mysql/include /usr/include/mysql[root@node6 ~]# [root@node6 ~]# vim /etc/man_db.confMANDATORY_MANPATH/usr/local/mysql/man建立数据存放目录,并修改属主[root@node6 ~]# mkdir -p /opt/data[root@node6 ~]# chown -R mysql.mysql /opt/data[root@node6 ~]# ll -d /opt/datadrwxr-xr-x. 2 mysql mysql 6 Sep5 19:09 /opt/data[root@node6 ~]# 初始化数据库,并保存密码[root@node6 ~]# mysqld --initialize --user mysql --datadir /opt/data2022-09-05T11:10:42.151293Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.20) initializing of server in progress as process 2094292022-09-05T11:10:42.160150Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.2022-09-05T11:10:43.610708Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.2022-09-05T11:10:44.652264Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: w-ETXrfTV1wE[root@node6 ~]# echo 'w-ETXrfTV1wE' > passwd[root@node6 ~]# cat passwdw-ETXrfTV1wE[root@node6 ~]# 生成配置文件[root@node6 ~]# > /etc/my.cnf[root@node6 ~]# vim /etc/my.cnf[root@node6 ~]# cat /etc/my.cnf[mysqld]basedir = /usr/local/mysqldatadir = /opt/datasocket = /tmp/mysql.sockport = 3306pid-file = /opt/data/mysql.piduser = mysqlskip-name-resolve[root@node6 ~]# 配置服务启动脚本[root@node6 ~]# cd /usr/local/mysql/support-files/[root@node6 support-files]# cp mysql.server mysqld[root@node6 support-files]# vim mysqldbasedir=/usr/local/mysqldatadir=/opt/data[root@node6 support-files]# chown -R mysql.mysql mysqld[root@node6 support-files]# ll -d mysqld-rwxr-xr-x. 1 mysql mysql 10602 Sep2 19:06 mysqld[root@node6 support-files]# 先启动测试一下[root@node6 ~]# /usr/local/mysql/support-files/mysqld startStarting MySQL.Logging to '/opt/data/node6.err'. SUCCESS! [root@node6 ~]# ss -antlStateRecv-Q Send-Q Local Address:PortPeer Address:Port Process LISTEN 01280.0.0.0:220.0.0.0:*LISTEN 01280.0.0.0:800.0.0.0:*LISTEN 0128[::]:22[::]:*LISTEN 070*:33060*:*LISTEN 0128*:3306*:*[root@node6 ~]# /usr/local/mysql/support-files/mysqld stopShutting down MySQL.. SUCCESS! [root@node6 ~]# ss -antlStateRecv-Q Send-QLocal Address:PortPeer Address:Port Process LISTEN 01280.0.0.0:220.0.0.0:*LISTEN 01280.0.0.0:800.0.0.0:*LISTEN 0128[::]:22[::]:*[root@node6 ~]# 配置service文件,设置开机自启[root@node6 ~]# cd /usr/lib/systemd/system[root@node6 system]# cp sshd.service mysqld.service[root@node6 system]# ll sshd.service -rw-r--r--. 1 root root 456 Jul 122021 sshd.service[root@node6 system]# ll mysqld.service-rw-r--r--. 1 root root 456 Sep5 19:15 mysqld.service[root@node6 system]# vim mysqld.service [root@node6 system]# cat mysqld.service[Unit]Description=mysqld server daemonAfter=network.target sshd-keygen.target[Service]Type=forkingExecStart=/usr/local/mysql/support-files/mysqld startExecStop=/usr/local/mysql/support-files/mysqld stopExecReload=/bin/kill -HUP $MAINPID[Install]WantedBy=multi-user.target[root@node6 system]# systemctl daemon-reload[root@node6 system]# systemctl enable --now mysqldCreated symlink /etc/systemd/system/multi-user.target.wants/mysqld.service 鈫? /usr/lib/systemd/system/mysqld.service.[root@node6 system]# ss -antlStateRecv-Q Send-Q Local Address:PortPeer Address:Port Process LISTEN 01280.0.0.0:220.0.0.0:*LISTEN 01280.0.0.0:800.0.0.0:*LISTEN 0128[::]:22[::]:*LISTEN 070*:33060*:*LISTEN 0128*:3306*:*[root@node6 system]# 设置密码[root@node6 ~]# mysql -uroot -p'w-ETXrfTV1wE';mysql> alter user 'root'@'localhost' identified by 'run123123';Query OK, 0 rows affected (0.00 sec)mysql> quitBye[root@node6 ~]# mysql -uroot -p'run123123';mysql: [Warning] Using a password on the command line interface can be insecure.Welcome to the MySQL monitor.Commands end with ; or g.Your MySQL connection id is 9Server version: 8.0.20 MySQL Community Server - GPLCopyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.mysql> quitBye[root@node6 ~]#
推荐阅读
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 落水者|钓友水边救起落水者,对方邀请家中做客,上了趟厕所,果断走人
- 做溶豆失败的原因
- |怎样做好领导的榜样?
- |在职场上,遇到和自己能力相当的人,应该怎样做?
- 青椒回锅肉的家常做法 青椒回锅肉!
- 厨师长教你在家做炸鸡腿做法 怎样炸鸡腿
- 拼多多自己开店好还是找代运营 拼多多电商开店好做吗
- 拆除思维中的墙,做个长期主义者 拆掉思维里的墙
- 湖南小炒肉的正宗做法 ! 湖南小炒肉!
- 做了介入手术后遗症
