“应用系统基础服务安装”的版本间的差异

来自CloudWiki
跳转至: 导航搜索
(创建页面,内容为“ == '''数据库配置:(考试的重点)''' == <nowiki># # This group is read both both by the client and the server # use it for options that affect everyt…”)
 
 
(未显示2个用户的9个中间版本)
第1行: 第1行:
 +
==目标==
 +
(1)了解应用系统需要的基础服务。
  
== '''数据库配置:(考试的重点)''' ==
+
(2)安装应用系统需要的基础服务。
 +
==准备==
 +
1.准备主机,镜像使用提供的CentOS-7-x86_64-DVD-1511.iso,最小化安装CentOS 7.2系统
  
 +
2.确认主机能够连接互联网: ping www.baidu.com
  
<nowiki>#
+
3.YUM源使用提供的本地gpmall-repo包(在项目3-软件包/商城系统-单节点中),安装基础环境
# This group is read both both by the client and the server
 
# use it for options that affect everything
 
#
 
[client-server]
 
  
#
+
4.Crt连接虚拟机,上传商城文件夹的所有资料到/opt目录下
# include all files from the config directory
 
#
 
!includedir /etc/my.cnf.d
 
[mysqld]
 
  
init_connect='SET collation_connection=utf8_unicode_ci'
+
做好以上工作后,开始:
 +
 
 +
===修改主机名===
 +
[root@bogon network-scripts]# hostnamectl set-hostname mall
 +
 
 +
[root@bogon network-scripts]# bash
 +
 
 +
[root@mall network-scripts]#  hostnamectl
 +
 
 +
  <nowiki>Static hostname: mall
 +
        Icon name: computer-vm
 +
          Chassis: vm
 +
        Machine ID: ca3409954572482db2000cf6c7324ab4
 +
          Boot ID: 473fccc7af0b491d94f0b275ef53bcae
 +
    Virtualization: vmware
 +
  Operating System: CentOS Linux 7 (Core)
 +
      CPE OS Name: cpe:/o:centos:centos:7
 +
            Kernel: Linux 3.10.0-327.el7.x86_64
 +
      Architecture: x86-64</nowiki>
 +
 
 +
===配置主机映射===
 +
[root@mall network-scripts]# cat /etc/hosts
 +
 
 +
<nowiki>127.0.0.1  localhost localhost.localdomain localhost4 localhost4.localdomain4
 +
::1        localhost localhost.localdomain localhost6 localhost6.localdomain6
 +
172.30.14.3    mall</nowiki>
 +
 
 +
===配置本地yum源===
 +
将提供的packages包上传到服务器的/root目录下,并配置本地local.repo文件,具体代码如下所示。
 +
 
 +
<nowiki>[centos]
 +
name=centos
 +
baseurl=file:///mnt/centos
 +
gpgcheck=0
 +
enabled=1
 +
 
 +
[mall]
 +
name=mall
 +
baseurl=file:///root/gpmall-repo
 +
gpgcheck=0
 +
enabled=1
 +
</nowiki>
 +
 
 +
测试:
 +
 
 +
[root@mall ~]# yum repolist
 +
 
 +
<nowiki>Loaded plugins: fastestmirror
 +
centos                                                  | 3.6 kB    00:00
 +
mall                                                    | 2.9 kB    00:00
 +
mall/primary_db                                            | 144 kB  00:00
 +
Loading mirror speeds from cached hostfile
 +
repo id                              repo name                            status
 +
centos                              centos                              3,723
 +
mall                                mall                                  165
 +
repolist: 3,888</nowiki>
 +
 
 +
==安装基础服务==
 +
===安装Java环境===
 +
yum install -y java-1.8.0-openjdk java-1.8.0-openjdk-devel
 +
 
 +
[root@mall ~]# java -version
 +
 
 +
<nowiki>openjdk version "1.8.0_222"
 +
OpenJDK Runtime Environment (build 1.8.0_222-b10)
 +
OpenJDK 64-Bit Server VM (build 25.222-b10, mixed mode)
 +
</nowiki>
 +
 
 +
===安装Redis缓存服务===
 +
yum install redis -y
 +
 
 +
===安装ElasticSearch===
 +
yum install elasticsearch -y
 +
 
 +
===安装Nginx服务===
 +
yum install nginx -y
 +
 
 +
===安装MariaDB数据库===
 +
yum install mariadb mariadb-server
 +
 
 +
===安装Zookeeper服务===
 +
将提供的zookeeper-3.4.14.tar.gz上传至云主机的/opt内,解压压缩包命令如下:
 +
 
 +
tar -zxvf zookeeper-3.4.14.tar.gz
 +
 
 +
进入到zookeeper-3.4.14/conf目录下,将zoo_sample.cfg文件重命名为zoo.cfg,
 +
 
 +
<nowiki>[root@mall ~]# cd zookeeper-3.4.14
 +
[root@mall zookeeper-3.4.14]# cd conf
 +
[root@mall conf]# mv zoo_sample.cfg zoo.cfg
 +
</nowiki>
 +
 
 +
进入到zookeeper-3.4.14/bin目录下,启动ZooKeeper服务:
 +
 
 +
<nowiki>[root@mall conf]# cd ..
 +
[root@mall zookeeper-3.4.14]# cd bin
 +
[root@mall bin]# ./zkServer.sh start
 +
ZooKeeper JMX enabled by default
 +
Using config: /root/zookeeper-3.4.14/bin/../conf/zoo.cfg
 +
Starting zookeeper ... STARTED
 +
[root@mall bin]# ./zkServer.sh status
 +
ZooKeeper JMX enabled by default
 +
Using config: /root/zookeeper-3.4.14/bin/../conf/zoo.cfg
 +
Mode: standalone
 +
</nowiki>
 +
 
 +
Zookeeper验证:ps aux| grep zoo
 +
 
 +
===安装Kafka===
 +
安装Kafka服务,将提供的kafka_2.11-1.1.1.tgz包上传到云主机的/opt目录下,解压该压缩包,命令如下:
 +
 
 +
<nowiki>  67  cd /opt
 +
  68  ls
 +
  69  tar -zxvf kafka_2.11-1.1.1.tgz
 +
  70  cd kafka_2.11-1.1.1
 +
  71  cd bin
 +
  72  ./kafka-server-start.sh -daemon ../config/server.properties
 +
</nowiki>
 +
 
 +
验证: 运行netstat -ntpl ,结果查看到Kafka服务和9092端口,则说明Kafka服务已启动。
 +
 +
<nowiki>[root@mall bin]# jps
 +
5776 Jps
 +
5714 Kafka
 +
5403 QuorumPeerMain
 +
[root@mall bin]# netstat -ntpl
 +
Active Internet connections (only servers)
 +
Proto Recv-Q Send-Q Local Address          Foreign Address        State      PID/Program name
 +
tcp        0      0 0.0.0.0:22              0.0.0.0:*              LISTEN      753/sshd
 +
tcp        0      0 127.0.0.1:25            0.0.0.0:*              LISTEN      1036/master
 +
tcp6      0      0 :::45964                :::*                    LISTEN      5714/java
 +
tcp6      0      0 :::32915                :::*                    LISTEN      5403/java
 +
tcp6      0      0 :::22                  :::*                    LISTEN      753/sshd
 +
tcp6      0      0 ::1:25                  :::*                    LISTEN      1036/master
 +
tcp6      0      0 :::9092                :::*                    LISTEN      5714/java
 +
tcp6      0      0 :::2181                :::*                    LISTEN      5403/java</nowiki>
 +
 
 +
 
 +
==启动服务==
 +
===启动数据库并配置(考试的重点)===
 +
修改/etc/my.cnf文件,添加字段如下所示:
 +
 
 +
<nowiki>[mysqld]
 +
 
 +
init_connect='SET collation_connection = utf8_unicode_ci'
 
init_connect='SET NAMES utf8'
 
init_connect='SET NAMES utf8'
 
character-set-server=utf8
 
character-set-server=utf8
 
collation-server=utf8_unicode_ci
 
collation-server=utf8_unicode_ci
skip-character-set-client-handshake</nowiki>
+
skip-character-set-client-handshake
+
</nowiki>
 +
 
 +
 
 +
systemctl start mariadb
  
数据库密码:
+
设置数据库密码并登陆:
  
  Mysqladmin –uroot –p123456(密码必须是这个,暂时)
+
mysql忘记密码:https://www.jianshu.com/p/8b8a2d0a2051
  
  
第30行: 第174行:
  
 
[root@localhost bin]# mysqladmin -uroot password 123456
 
[root@localhost bin]# mysqladmin -uroot password 123456
 +
 +
(密码必须是这个,暂时)
  
 
[root@localhost bin]# mysql -uroot -p123456
 
[root@localhost bin]# mysql -uroot -p123456
第36行: 第182行:
  
 
MariaDB [(none)]> grant all privileges on *.* to root@localhost identified by '123456' with grant option;
 
MariaDB [(none)]> grant all privileges on *.* to root@localhost identified by '123456' with grant option;
Query OK, 0 rows affected (0.000 sec)
 
  
MariaDB [(none)]> grant all privileges on *.* to root@'%' identified by '123456' with grant option;Query OK, 0 rows affected (0.000 sec)
+
Query OK, 0 rows affected (0.000 sec)
  
上传文件:
+
MariaDB [(none)]> grant all privileges on *.* to root@'%' identified by '123456' with grant option;
 +
 
 +
Query OK, 0 rows affected (0.000 sec)
 +
 
 +
 
 +
MariaDB [(none)]>  flush privileges;
 +
 
 +
Query OK, 0 rows affected (0.001 sec)
 +
 
 +
 
 +
将gpmall.sql文件上传至云主机的/root目录下。创建数据库gpmall并导入gpmall.sql文件。
  
 
MariaDB [(none)]> create database gpmall;
 
MariaDB [(none)]> create database gpmall;
第47行: 第202行:
 
MariaDB [(none)]> use gpmall;
 
MariaDB [(none)]> use gpmall;
 
Database changed
 
Database changed
MariaDB [gpmall]> source /opt/gpmall/gpmall-file
+
 
ERROR: Can't initialize batch_readline
+
MariaDB [gpmall]> source /root/gpmall.sql
MariaDB [gpmall]> source /opt/gpmall/gpmall-file/gpmall.sql
 
  
 
退出数据库并开机自启:
 
退出数据库并开机自启:
MariaDB [gpmall]> Ctrl-C -- exit!
+
 
 +
MariaDB [gpmall]> Ctrl-C  
 +
 
 
Aborted
 
Aborted
 +
 
[root@localhost bin]# systemctl enable mariadb
 
[root@localhost bin]# systemctl enable mariadb
  
  
== 启动Redis ==
+
=== 启动Redis ===
  
 
vi /etc/redis.conf
 
vi /etc/redis.conf
  
 +
修改如下内容:bind行加注释,protected行 yes改为no
 
   <nowiki>#bind 127.0.0.1
 
   <nowiki>#bind 127.0.0.1
 
   protected-mode no</nowiki>
 
   protected-mode no</nowiki>
第69行: 第227行:
 
[root@localhost bin]# systemctl enable redis
 
[root@localhost bin]# systemctl enable redis
  
Created symlink from /etc/systemd/system/multi-user.target.wants/redis.service to /usr/lib/systemd/system/redis.service.
+
  <nowiki>Created symlink from /etc/systemd/system/multi-user.target.wants/redis.service to /usr/lib/systemd/system/redis.service.</nowiki>
  
==配置ElasticSearch==
+
===启动ElasticSearch===
 
暂时不做
 
暂时不做
  
==配置nginx==
+
===启动nginx===
 
[root@localhost bin]# systemctl start nginx
 
[root@localhost bin]# systemctl start nginx
  
第80行: 第238行:
  
 
  Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
 
  Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
 +
 +
请看下一节:
 +
 +
[[应用系统部署]]

2019年10月25日 (五) 14:21的最新版本

目标

(1)了解应用系统需要的基础服务。

(2)安装应用系统需要的基础服务。

准备

1.准备主机,镜像使用提供的CentOS-7-x86_64-DVD-1511.iso,最小化安装CentOS 7.2系统

2.确认主机能够连接互联网: ping www.baidu.com

3.YUM源使用提供的本地gpmall-repo包(在项目3-软件包/商城系统-单节点中),安装基础环境

4.Crt连接虚拟机,上传商城文件夹的所有资料到/opt目录下

做好以上工作后,开始:

修改主机名

[root@bogon network-scripts]# hostnamectl set-hostname mall

[root@bogon network-scripts]# bash

[root@mall network-scripts]# hostnamectl

  Static hostname: mall
         Icon name: computer-vm
           Chassis: vm
        Machine ID: ca3409954572482db2000cf6c7324ab4
           Boot ID: 473fccc7af0b491d94f0b275ef53bcae
    Virtualization: vmware
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-327.el7.x86_64
      Architecture: x86-64

配置主机映射

[root@mall network-scripts]# cat /etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
172.30.14.3     mall

配置本地yum源

将提供的packages包上传到服务器的/root目录下,并配置本地local.repo文件,具体代码如下所示。

[centos]
name=centos
baseurl=file:///mnt/centos
gpgcheck=0
enabled=1

[mall]
name=mall
baseurl=file:///root/gpmall-repo
gpgcheck=0
enabled=1

测试:

[root@mall ~]# yum repolist

Loaded plugins: fastestmirror
centos                                                   | 3.6 kB     00:00
mall                                                     | 2.9 kB     00:00
mall/primary_db                                            | 144 kB   00:00
Loading mirror speeds from cached hostfile
repo id                              repo name                            status
centos                               centos                               3,723
mall                                 mall                                   165
repolist: 3,888

安装基础服务

安装Java环境

yum install -y java-1.8.0-openjdk java-1.8.0-openjdk-devel

[root@mall ~]# java -version

openjdk version "1.8.0_222"
OpenJDK Runtime Environment (build 1.8.0_222-b10)
OpenJDK 64-Bit Server VM (build 25.222-b10, mixed mode)

安装Redis缓存服务

yum install redis -y

安装ElasticSearch

yum install elasticsearch -y

安装Nginx服务

yum install nginx -y

安装MariaDB数据库

yum install mariadb mariadb-server

安装Zookeeper服务

将提供的zookeeper-3.4.14.tar.gz上传至云主机的/opt内,解压压缩包命令如下:

tar -zxvf zookeeper-3.4.14.tar.gz

进入到zookeeper-3.4.14/conf目录下,将zoo_sample.cfg文件重命名为zoo.cfg,

[root@mall ~]# cd zookeeper-3.4.14
[root@mall zookeeper-3.4.14]# cd conf
[root@mall conf]# mv zoo_sample.cfg zoo.cfg

进入到zookeeper-3.4.14/bin目录下,启动ZooKeeper服务:

[root@mall conf]# cd ..
[root@mall zookeeper-3.4.14]# cd bin
[root@mall bin]# ./zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /root/zookeeper-3.4.14/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@mall bin]# ./zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /root/zookeeper-3.4.14/bin/../conf/zoo.cfg
Mode: standalone

Zookeeper验证:ps aux| grep zoo

安装Kafka

安装Kafka服务,将提供的kafka_2.11-1.1.1.tgz包上传到云主机的/opt目录下,解压该压缩包,命令如下:

   67  cd /opt
   68  ls
   69  tar -zxvf kafka_2.11-1.1.1.tgz
   70  cd kafka_2.11-1.1.1
   71  cd bin
   72  ./kafka-server-start.sh -daemon ../config/server.properties

验证: 运行netstat -ntpl ,结果查看到Kafka服务和9092端口,则说明Kafka服务已启动。

[root@mall bin]# jps
5776 Jps
5714 Kafka
5403 QuorumPeerMain
[root@mall bin]# netstat -ntpl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      753/sshd
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1036/master
tcp6       0      0 :::45964                :::*                    LISTEN      5714/java
tcp6       0      0 :::32915                :::*                    LISTEN      5403/java
tcp6       0      0 :::22                   :::*                    LISTEN      753/sshd
tcp6       0      0 ::1:25                  :::*                    LISTEN      1036/master
tcp6       0      0 :::9092                 :::*                    LISTEN      5714/java
tcp6       0      0 :::2181                 :::*                    LISTEN      5403/java


启动服务

启动数据库并配置(考试的重点)

修改/etc/my.cnf文件,添加字段如下所示:

[mysqld]

init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake


systemctl start mariadb

设置数据库密码并登陆:

mysql忘记密码:https://www.jianshu.com/p/8b8a2d0a2051


[root@localhost bin]# systemctl start mariadb

[root@localhost bin]# mysqladmin -uroot password 123456

(密码必须是这个,暂时)

[root@localhost bin]# mysql -uroot -p123456

设置用户权限:

MariaDB [(none)]> grant all privileges on *.* to root@localhost identified by '123456' with grant option;

Query OK, 0 rows affected (0.000 sec)

MariaDB [(none)]> grant all privileges on *.* to root@'%' identified by '123456' with grant option;

Query OK, 0 rows affected (0.000 sec)


MariaDB [(none)]> flush privileges;

Query OK, 0 rows affected (0.001 sec)


将gpmall.sql文件上传至云主机的/root目录下。创建数据库gpmall并导入gpmall.sql文件。

MariaDB [(none)]> create database gpmall; Query OK, 1 row affected (0.001 sec)

MariaDB [(none)]> use gpmall; Database changed

MariaDB [gpmall]> source /root/gpmall.sql

退出数据库并开机自启:

MariaDB [gpmall]> Ctrl-C

Aborted

[root@localhost bin]# systemctl enable mariadb


启动Redis

vi /etc/redis.conf

修改如下内容:bind行加注释,protected行 yes改为no

 #bind 127.0.0.1
  protected-mode no


[root@localhost bin]# systemctl start redis

[root@localhost bin]# systemctl enable redis

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

启动ElasticSearch

暂时不做

启动nginx

[root@localhost bin]# systemctl start nginx

[root@localhost bin]# systemctl enable nginx

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

请看下一节:

应用系统部署