部署數據庫1

      網友投稿 715 2025-03-31

      在ChinaSkill-node1實例節點上增加一個MariaDB-10數據庫軟件的yum源配置文件。配置完成后清楚yum緩存。命令如下:

      [root@chinaskill-node1 ~]# vi /etc/yum.repos.d/MariaDB.repo

      [MariaDB]

      name=MariaDB-10

      baseurl=https://mirrors.ustc.edu.cn/mariadb/yum/10.1/centos7-amd64/

      gpgcheck=0

      enabled=1

      [root@chinaskill-node1 ~]# yum clean all && yum repolist

      在ChinaSkill-node1實例節點上安裝MariaDB-10數據庫。命令如下:

      [root@chinaskill-node1 ~]# yum install? mariadb mariadb-server -y

      在chinaskill-node1實例節點啟動mariadb數據庫。命令如下:

      [root@chinaskill-node2 ~]# systemctl start mariadb

      [root@chinaskill-node2 ~]# systemctl enable mariadb

      Created symlink from /etc/systemd/system/mysql.service to /usr/lib/systemd/system/mariadb.service.

      Created symlink from /etc/systemd/system/mysqld.service to /usr/lib/systemd/system/mariadb.service.

      Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.

      在chinaskill-node1實例節點初始化mariadb數據庫,并設置mariadb數據庫的root用戶密碼為Abc@1234。命令如下:

      [root@chinaskill-node1 ~]# mysql_secure_installation

      NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB

      SERVERS IN PRODUCTION USE!? PLEASE READ EACH STEP CAREFULLY!

      In order to log into MariaDB to secure it, we'll need the current

      password for the root user.? If you've just installed MariaDB, and

      you haven't set the root password yet, the password will be blank,

      so you should just press enter here.

      Enter current password for root (enter for none):

      OK, successfully used password, moving on...

      Setting the root password ensures that nobody can log into the MariaDB

      root user without the proper authorisation.

      Set root password? [Y/n] y

      New password:

      Re-enter new password:

      Password updated successfully!

      Reloading privilege tables..

      ... Success!

      By default, a MariaDB installation has an anonymous user, allowing anyone

      to log into MariaDB without having to have a user account created for

      them.? This is intended only for testing, and to make the installation

      go a bit smoother.? You should remove them before moving into a

      production environment.

      Remove anonymous users? [Y/n] y

      ... Success!

      Normally, root should only be allowed to connect from 'localhost'.? This

      ensures that someone cannot guess at the root password from the network.

      Disallow root login remotely? [Y/n] n

      ... skipping.

      By default, MariaDB comes with a database named 'test' that anyone can

      access.? This is also intended only for testing, and should be removed

      before moving into a production environment.

      Remove test database and access to it? [Y/n] y

      - Dropping test database...

      ... Success!

      - Removing privileges on test database...

      ... Success!

      Reloading the privilege tables will ensure that all changes made so far

      will take effect immediately.

      Reload privilege tables now? [Y/n] y

      ... Success!

      Cleaning up...

      All done!? If you've completed all of the above steps, your MariaDB

      installation should now be secure.

      Thanks for using MariaDB!

      在chinaskill-node1的實例節點上登錄數據庫,并創建wordpress數據庫,將提供的yunmeng-wordpress.sql數據庫導入wordpress數據庫中,賦予root用戶訪問wordpress數據庫權限。命令如下:

      [root@chinaskill-node1 ~]# mysql -uroot -pAbc@1234

      Welcome to the MariaDB monitor.? Commands end with ; or \g.

      Your MariaDB connection id is 25

      部署數據庫1

      Server version: 10.1.47-MariaDB MariaDB Server

      Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

      Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

      MariaDB [(none)]> create database wordpress;

      Query OK, 1 row affected (0.00 sec)

      MariaDB [(none)]> grant all on *.* to root@localhost identified by 'Abc@1234';

      Query OK, 0 rows affected (0.00 sec)

      MariaDB [(none)]> grant all on *.* to root@'%' identified by 'Abc@1234';

      Query OK, 0 rows affected (0.00 sec)

      MariaDB [(none)]> flush privileges;

      Query OK, 0 rows affected (0.00 sec)

      在ChinaSkill-node1實例節點上使用yum命令安裝nginx服務并啟動。命令如下:

      [root@chinaskill-node1 ~]# yum install nginx –y

      [root@chinaskill-node1 ~]# systemctl start nginx && systemctl enable nginx

      Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.

      在ChinaSkill-node2實例節點上安裝nginx服務,步驟同上。

      在ChinaSkill-node1實例節點上修改nginx的配置文件,使nginx支持php服務,修改完檢查配置并重啟服務。命令如下:

      [root@chinaskill-node1 ~]# vi /etc/nginx/nginx.conf

      ……

      location / {

      root?? /usr/share/nginx/html;

      index? index.php index.html index.htm;

      }

      location ~ \.php$ {

      root?????????? /usr/share/nginx/html;

      fastcgi_pass?? 127.0.0.1:9000;

      fastcgi_index? index.php;

      fastcgi_param? SCRIPT_FILENAME? $document_root$fastcgi_script_name;

      include??????? fastcgi_params;

      }

      ……

      [root@chinaskill-node1 ~]# nginx -t

      nginx: the configuration file /etc/nginx/nginx.conf syntax is ok

      nginx: configuration file /etc/nginx/nginx.conf test is successful

      [root@chinaskill-node1 ~]# systemctl restart nginx

      在ChinaSkill-node2實例節點上修改nginx服務配置文件,步驟同上。

      在ChinaSkill-node1實例節點上使用yum命令安裝php服務,修改php服務的配置文件中運行用戶和組為nginx,并啟動。命令如下:

      [root@chinaskill-node1 ~]# yum install php-fpm php-mysql –y

      [root@chinaskill-node1 ~]# vi /etc/php-fpm.d/www.conf

      ; RPM: apache Choosed to be able to access some dir as httpd

      user = nginx

      ; RPM: Keep a group allowed to write in log dir.

      group = nginx

      [root@chinaskill-node1 ~]# systemctl start php-fpm && systemctl enable php-fpm

      Created symlink from /etc/systemd/system/multi-user.target.wants/php-fpm.service to /usr/lib/systemd/system/php-fpm.service.

      在ChinaSkill-node2實例節點上安裝php服務,步驟同上。

      將提供的wordpress-5.0.2-zh_CN.tar.gz壓縮包上傳至ChinaSkill-node1實例節點的/root目錄并解壓,命令如下:

      [root@chinaskill-node1 ~]# tar -zxvf wordpress-5.0.2-zh_CN.tar.gz

      刪除nginx服務的項目目錄/usr/share/nginx/html中默認頁面文件,將解壓的wordpress目錄中文件上傳到目錄/usr/share/nginx/html中,并賦予777權限。命令如下:

      [root@chinaskill-node1 ~]# rm -rfv? /usr/share/nginx/html/*

      [root@chinaskill-node1 ~]# cp -r /root/wordpress/* /usr/share/nginx/html/.

      [root@chinaskill-node1 ~]# chmod 777 /usr/share/nginx/html/*

      在/usr/share/nginx/html目錄下,可以看見一個wp-config-sample.php配置文件,該文件是WordPress應用提供了一個模板配置文件,將該模板復制一份并改名為wp-config.php,然后編輯該文件,配置wordpress應用訪問數據庫。命令如下:

      [root@chinaskill-node1 ~]# cp -r /usr/share/nginx/html/wp-config-sample.php /usr/share/nginx/html/wp-config.php

      [root@chinaskill-node1 ~]# vi /usr/share/nginx/html/wp-config.php

      // ** MySQL 設置 - 具體信息來自您正在使用的主機 ** //

      /** WordPress數據庫的名稱 */

      define('DB_NAME', 'wordpress');

      /** MySQL數據庫用戶名 */

      define('DB_USER', 'root');

      /** MySQL數據庫密碼 */

      define('DB_PASSWORD', 'Abc@1234');

      /** MySQL主機 */

      define('DB_HOST', '192.168.1.13');

      /** 創建數據表時默認的文字編碼 */

      define('DB_CHARSET', 'utf8');

      /** 數據庫整理類型。如不確定請勿更改 */

      define('DB_COLLATE', '');

      訪問chinaskill-node1實例節點的wordpress應用,wordpress首頁如圖17所示。

      wordpress應用

      在ChinaSkill-node2實例節點上部署wordpress應用,步驟同上,wp-config.php文件配置相同。

      點擊云產品登錄負載均衡控制臺,負載均衡選項位置如圖18所示。

      負載均衡

      在負載均衡控制臺點擊新建,進入負載均衡服務購買頁面,地域選擇上海(與云服務器在相同的地域即可),網絡選擇intnet1,實例名設置為chinaskill-clb。如圖19所示。

      購買負載均衡

      配置完成后點擊立即購買完成負載均衡服務新建。生成負載均衡服務,負載均衡服務的VIP地址為81.69.165.236,如圖20所示。

      負載均衡服務

      點擊進入負載均衡實例chinaskill-clb,選擇安全組。如圖21所示。

      負載均衡安全組

      點擊綁定,在彈出的對話框中選中Chinaskll-security-group安全組,點擊確定。如圖22所示。

      綁定安全組

      進入負載均衡實例chinaskill-clb,選擇-管理。如圖23所示。

      -

      點擊新建,在彈出的對話框中,設置名稱為wordpress,端口協議HTTP,端口為80的-,點擊提交完成創建。如圖24所示。

      新建-wordpress

      選擇wordpress-的‘+’添加規則按鍵,在彈出來的對話框中,設置域名為負載均衡實例的vip地址,URL路徑設置為‘/’,點擊下一步,默認設置不修改,點擊下一步,默認設置不修改,點擊提交完成新建。如圖25所示。

      新建規則

      點擊打開wordpress-和81.69.165.236域名的‘+’按鍵,選中‘/’,在右側出現的“已綁定后端服務”中選中綁定選項,在彈出的對話框中,選中云服務器下的ChinaSkill-node1實例節點和ChinaSkill-node2實例節點,端口設置為80,點擊確認完成綁定。如圖26所示。

      綁定后端服務

      稍作等等,確認端口健康狀態為健康。我們就可以通過負載均衡實例節點的VIP地址http://81.69.165.236/訪問wordpress應用。如圖27所示。

      vip訪問wordpress

      在ChinaSkill-node1實例節點wordpress應用部署目錄中創建wordpress應用圖片存放目錄uploads。

      [root@chinaskill-node1 ~]# cd /usr/share/nginx/html/

      [root@chinaskill-node1 html]# mkdir wp-content/uploads

      在Chinaskill-node1實例節點中,將nfs共享目錄掛載到wordpress應用圖片存放目錄uploads中。

      [root@chinaskill-node1 html]# mount -t nfs 192.168.1.4://nfs/code wp-content/uploads/

      在ChinaSkill-node2實例節點共享存儲,步驟如上所述。

      登錄ChinaSkill-node2實例節點,進入nfs服務的共享目錄,創建/nfs/code/2020/10目錄,并將提供的wordpress.png圖片文件上傳到/nfs/code/2020/10目錄。

      [root@chinaskill-node2 ~]# cd /nfs/code/

      [root@chinaskill-node2 code]# mkdir -p 2020/10

      [root@chinaskill-node2 code]# ll 2020/10/

      total 68

      -rw-r--r-- 1 root root 69571 Oct 26 18:28 wordpress.png

      這樣ChinaSkill-node1實例節點和ChinaSkill-node2實例節點的wordpress應用的圖片存儲目錄中就有了nfs共享的圖片。

      [root@chinaskill-node1 ~]# ll /usr/share/nginx/html/wp-content/uploads/2020/10/

      total 68

      -rw-r--r-- 1 root root 69571 Oct 26 18:28 wordpress.png

      [root@chinaskill-node2 ~]# ll /usr/share/nginx/html/wp-content/uploads/2020/10/

      total 68

      -rw-r--r-- 1 root root 69571 Oct 26 18:28 wordpress.png

      訪問http://81.69.165.236/地址,可以看到我們上傳的wordpress.png圖片。這是云夢科技wordpress博客網站文章中原來就存在的圖片,現在提供了圖片文件后就可以在網頁中看見了。如圖28所示。

      WordPress 數據庫

      版權聲明:本文內容由網絡用戶投稿,版權歸原作者所有,本站不擁有其著作權,亦不承擔相應法律責任。如果您發現本站中有涉嫌抄襲或描述失實的內容,請聯系我們jiasou666@gmail.com 處理,核實后本網站將在24小時內刪除侵權內容。

      版權聲明:本文內容由網絡用戶投稿,版權歸原作者所有,本站不擁有其著作權,亦不承擔相應法律責任。如果您發現本站中有涉嫌抄襲或描述失實的內容,請聯系我們jiasou666@gmail.com 處理,核實后本網站將在24小時內刪除侵權內容。

      上一篇:10招教你快速選取單元格(選擇單元格的方法)
      下一篇:RESTful API 設計指南
      相關文章
      亚洲成a人片在线观| 久久国产亚洲电影天堂| 亚洲视频免费播放| 亚洲成色999久久网站| 亚洲精品综合久久| www.91亚洲| 久久精品国产亚洲av天美18| 亚洲砖码砖专无区2023| 亚洲国产日韩精品| 精品国产日韩久久亚洲| 91亚洲性爱在线视频| 亚洲国产精品久久久久秋霞影院| 亚洲宅男天堂a在线| 亚洲喷奶水中文字幕电影| 亚洲美女视频一区二区三区| 亚洲视频一区二区三区| 666精品国产精品亚洲| 亚洲第一永久在线观看| 亚洲av乱码一区二区三区| 天天爽亚洲中文字幕| 亚洲女女女同性video| 国产亚洲精品精品精品| 亚洲五月午夜免费在线视频| 国产亚洲av片在线观看18女人| 亚洲理论电影在线观看| 亚洲国产精品无码久久久不卡| 亚洲av日韩av高潮潮喷无码| 久久亚洲AV成人无码软件 | 亚洲成a人片在线观| 国产成人精品日本亚洲网址| 亚洲精品自偷自拍无码| 亚洲国产精品成人一区| 伊伊人成亚洲综合人网7777| 亚洲人成无码网站| 久久精品国产亚洲AV电影| 激情亚洲一区国产精品| 亚洲精品无码久久久久久| 亚洲精品美女久久久久99小说| 亚洲毛片αv无线播放一区| 亚洲成人在线网站| 亚洲入口无毒网址你懂的|