华为云鲲鹏ECS安装开源版本领课教育系统roncoo-education

网友投稿 995 2022-05-30

华为云鲲鹏ECS安装开源版本领课教育系统roncoo-education

安装基于华为云鲲鹏ECS云主机安装CentOS 7.4进行如下操作

所用组件如下:

Tomcat 、Redis、ElasticSearch、Nodejs、、MySQL 、roncoo-education(spring cloud) 、 roncoo-education-admin(node管理) 、 roncoo-education-web(node前端)

下面说说具体安装步骤,如有遗漏,欢迎指正。

1 tomcat安装配置

获取软件包

执行以下命令,获取Tomcat软件包。

cd /opt

wget https://archive.apache.org/dist/tomcat/tomcat-8/v8.5.41/bin/apache-tomcat-8.5.41.tar.gz

编译环境配置

1) 安装JDK。

yum install -y java-1.8.0-openjdk

2) 解压Tomcat软件包。

tar -xvf apache-tomcat-8.5.41.tar.gz

3) 运行Tomcat。

sh /usr/local/src/apache-tomcat-8.5.41/bin/startup.sh

4) 在浏览器中输入URL:http://云服务器公网IP地址:8080并单击回车。

自启动配置

1) cp /opt/tomcat/bin/catalina.sh /etc/init.d/tomcat8

2) chmod 755 /etc/init.d/tomcat8

3) vim /etc/init.d/tomcat8

在文件第一行下面增加如下内容:

#chkconfig: 2345 10 90 #description: tomcat8 service export CATALINA_HOME=/opt/tomcat

4) 添加服务

chkconfig --add tomcat8

5) 测试

service tomcat8 start

service tomcat8 stop

当出现以下页面,说明Tomcat服务器环境配置成功,注意打开安全组中8080端口。

2 安装mysql

yum install -y bzip2

cd /opt wget https://kunpengsoft.obs.cn-north-4.myhuaweicloud.com/gcc-7.3.tar.gz tar -zxvf gcc-7.3.tar.gz cd gcc tar -zxvf gcc-7.3.0-all.tar.gz tar -zxvf gcc-7.3.0.tar.gz

cp gmp-6.1.0.tar.bz2 isl-0.16.1.tar.bz2 mpc-1.0.3.tar.gz mpfr-3.1.4.tar.bz2 gcc-7.3.0

cd gcc-7.3.0 ./contrib/download_prerequisites 依赖检查结果如下回显所示,则表示依赖正确 [root@ecs-centos gcc-7.3.0]# ./contrib/download_prerequisites  gmp-6.1.0.tar.bz2: OK mpfr-3.1.4.tar.bz2: OK  mpc-1.0.3.tar.gz: OK  isl-0.16.1.tar.bz2: OK All prerequisites downloaded successfully.

执行编译。

mkdir gcc-build-7.3.0 cd gcc-build-7.3.0 ../configure --enable-checking=release --enable-language=c,c++ --disable-multilib --prefix=/usr nohup make -j`cat /proc/cpuinfo| grep "processor"| wc -l` & //编译时间过长,放至后台执行 可通过 jobs 命令查看后台任务: Running:表示任务正在进行 Done:表示任务完成 等待上一步执行完成之后,再执行下面命令执行安装。 make install

[root@ecs-centos gcc-7.3.0]# gcc -v  Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/libexec/gcc/aarch64-unknown-linux-gnu/7.3.0/lto-wrappe  r Target: aarch64-unknown-linux-gnu Configured with: ../configure --enable-checking=release --enable-languages=c,c+ + --disable-multilib --prefix=/usr  Thread model: posix gcc version 7.3.0 (GCC)

备注:"-j"参数可利用多核 CPU 加快编译速度。

可通过下述命令查询 CPU 核数:

cat /proc/cpuinfo| grep "processor"| wc -l

3 MySQL-5.7.27 编译安装

MySQL 是一个关系型数据库管理系统。

yum install -y bison* ncurses* openssl-devel cmake

cd /opt wget https://kunpengsoft.obs.cn-north-4.myhuaweicloud.com/mysql-5.7.27.tar.gz wget https://kunpengsoft.obs.cn-north-4.myhuaweicloud.com/boost_1_59_0.tar.gz

3.3.1.解压软件包

tar -zxvf mysql-5.7.27.tar.gz tar -zxvf boost_1_59_0.tar.gz

3.3.2.进入 MySQL 的安装目录,下载cmake.sh 文件

cd mysql-5.7.27 wget https://kunpengsoft.obs.cn-north-4.myhuaweicloud.com/cmake.sh

3.3.3.给"cmake.sh"赋以权限并运行,等待运行完成

chmod +x cmake.sh ./cmake.sh

备注:若在预编译时出现依赖包不全的情况,可自行查阅资料安装依赖包,并重新

预编译。重新预编译前,需要删除"CMakeCache.txt"文件

rm -f CMakeCache.txt

3.3.4.在 MySQL 源码路径下执行make 命令,等待编译完成

make -j`cat /proc/cpuinfo| grep "processor"| wc -l`

注意:编译过程中会出错,sql/mysqld.cc中的函数prctl无法识别,先注解掉mysqld.cc的1558行的调用再重新编译。

3.3.5.运行 make install,等待安装过程结束

make install

创建“mysql”用户及用户组

groupadd mysql

useradd -g mysql mysql

修改“/usr/local/mysql”权限

chown -R mysql:mysql /usr/local/mysql

进入安装路径,创建"data"、“log”、"run"文件夹,执

行初始化配置脚本,生成初始的数据库和表

cd /usr/local/mysql

mkdir -p /data/log /data/data /data/run

bin/mysqld --initialize --basedir=/usr/local/mysql --datadir=/data/data --user=mysql

需要指出的是,执行上述命令后,会产生初始随机密码,需要记录。

A temporary password is generated for root@localhost: ;sR*Ee-j*0mL

创建"mysql.log"和"mysql.pid"文件,赋予其"mysql"

用户及用户组权限

其中,创建的“mysql.log”和“mysql.pid”文件是空文件。 touch /data/log/mysql.log

touch /data/run/mysql.pid

chown -R mysql:mysql /data

修改“my.cnf”中的文件路径,如图 1-1 所示

vim /etc/my.cnf [mysqld]

datadir=/data/data

socket=/data/data/mysql.sock

...

[mysqld_safe]

log-error=/data/log/mysql.log

pid-file=/data/run/mysql.pid

启动 MySQL 服务

cp support-files/mysql.server /etc/init.d/mysql

chkconfig mysql on

service mysql start

成功启动如下所示:

[root@ecs-shaun mysql]# service mysql start

Starting MySQL. SUCCESS!

将以下内容添加进环境变量,并使之生效

编辑文件并添加内容。

vim ~/.bash_profile

添加的内容如下:

export PATH=/usr/local/mysql/bin:$PATH

执行下面命令,使环境变量生效

source ~/.bash_profile

建立套接字软链接,接入MySQL 环境

需要输入的密码为配置 MySQL 时产生的初始密码,请留意初始密码包含了特殊

字符。

ln -s /data/data/mysql.sock /tmp/mysql.sock

mysql -uroot -p

登陆成功

[root@ecs-centos mysql]# mysql -uroot -p

Enter password:

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

Your MySQL connection id is 2

Server version: 5.7.28

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

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

mysql>

修改密码,下述命令中的“mypassword”需要根据实际修改成要配置的密码。

SET PASSWORD = PASSWORD('mypassword');

mysql> SET PASSWORD = PASSWORD('Huawei@123');

Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql>

如果忘记初始密码,可参见附录:忘记 MySQL 的初始密码。

使用新的密码重新登录

下述命令中的"mypassword"需要根据实际修改成要配置的密码。

mysql -uroot –pmypassword

登陆成功 [root@ecs-centos mysql]# mysql -uroot -pHuawei@123

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 3

Server version: 5.7.28 Source distribution

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

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

mysql>

问题描述:

在连接 MySQL 时,忘记初始密码。

解决方法:

用以下命令启动 MySQL,以不检查权限的方式启动,然后重新设置密码,重新

登录。

[root@ecs-centos mysql]# service mysql stop [root@ecs-centos mysql]# service mysql start --skip-grant-tables [root@ecs-centos mysql]# mysql -uroot -p  Enter password: //直接按回车键 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.7.28 Source distribution Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its  affiliates. Other names may be trademarks of their respective  owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

//在此处更改密码,password 设置为实际要配置的密码

mysql> UPDATE mysql.user SET authentication_string=PASSWORD('password') where USER='root'; mysql> flush privileges; //刷新权限 mysql> exit //退出 MySQL [root@ecs-centos mysql]# mysql -uroot -p Enter password: //此处输入设置的密码

mysql> create database education_course;

mysql> create database education_system;

mysql> create database education_user;

mysql> use education_course;

mysql> source /home/df/workspace/roncoo-6.0.0-mysql/education_course.sql;

mysql> use education_user;

mysql> source /home/df/workspace/roncoo-6.0.0-mysql/education_user.sql;

mysql> use education_system;

mysql> source /home/df/workspace/roncoo-6.0.0-mysql/education_system.sql;

前面的数据库中所使用到的前端及管理后台账号密码

前端账号密码

普通用户: 13800138002 密码:123456

讲师用户: 13800138001 密码:123qwe

管理员 :13800000000 密码:123456

超级管理员 :18800000000 密码:123456(2.0.0-SNAPSHOT版本)

6 安装Redis

获取源代码

本文档所测试版本为:Redis-4.0.9

软件获取路径为:http://download.redis.io/releases/

Redis官网:https://redis.io/

编译源代码

本文以Redis-4.0.9为例,下载redis-4.0.9源码,并编译安装。

1) 执行如下命令,获取Redis源码。

wget http://download.redis.io/releases/redis-4.0.9.tar.gz

2) 执行如下命令,解压包。

tar -zxvf redis-4.0.9.tar.gz

3) 执行如下命令,进入deps目录。

cd redis-4.0.9/deps

4) 执行如下命令,编译Redis依赖库。

make -j4 hiredis lua jemalloc linenoise

5) 依次执行如下命令,编译Redis。

cd ..

make -j4

make install

配置编译好的软件

1) 执行如下命令,建立redis配置文件。

cp redis.conf /usr/local/etc/

2) 执行如下命令,配置redis为后台启动。

vim /usr/local/etc/redis.conf

将daemonize no 改成daemonize yes。

3) 设置Redis开机启动。

a. 执行如下命令,将Redis启动脚本放置/etc/init.d/目录下,并命名为redis。

cp redis-4.0.9/utils/redis_init_script /etc/init.d/redis

华为云鲲鹏ECS安装开源版本领课教育系统roncoo-education

b. 执行如下命令,修改脚本内容。

vim /etc/init.d/redis

修改内容如下图:

在第二行增加如下内容:

#chkconfig: 2345 10 90 #description: Redis is a persistent key-value database

修改CONF的值为:

CONF="/usr/local/etc/redis.conf"

找到requirepass设置redis密码:

requirepass huike1234

c. 设置服务开启启动。

chkconfig --add redis chkconfig redis on

测试已完成编译的软件

1) 执行如下命令,查看Redis版本。

redis-server -v

系统会显示如下类似信息,表示Redis的版本是4.0.9。

[root@ecs-1-0002 redis-4.0.9]# redis-server -v

Redis server v=4.0.9 sha=00000000:0 malloc=jemalloc-4.0.3 bits=64 build=1e80e86f2ae3f0d8

2) 执行如下命令,查看Redis的CLI版本。

redis-cli -v

系统会显示如下类似信息,表示Redis的CLI版本是4.0.9。

redis-cli 4.0.9

3) 执行如下命令,启动redis-server。

service redis start

系统会显示如下类似信息,表示Redis启动完成。

Starting Redis server...

20525:C 19 Jun 20:43:25.941 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo

20525:C 19 Jun 20:43:25.941 # Redis version=4.0.9, bits=64, commit=00000000, modified=0, pid=20525, just started

20525:C 19 Jun 20:43:25.941 # Configuration loaded

4) 执行如下命令,使用redis-cli连接server,并执行k-v请求。

[root@ecs-1-0002 redis-4.0.9]# redis-cli

127.0.0.1:6379> set huawei arm

OK

127.0.0.1:6379> get huawei

"arm"

127.0.0.1:6379> del huawei

(integer) 1

127.0.0.1:6379> get huawei

(nil)

已知问题汇总

问题现象

编译Redis时出现如下报错:

问题根因

出现此错误是因为缺少hiredis,lua,jemalloc,linenoise库。

问题解决

1) 执行如下命令,进入Redis目录。

cd redis-4.0.9/deps

2) 执行如下命令,编译Redis依赖库。

make -j4 hiredis lua jemalloc linenoise

7 安装Nodejs

获取软件包

获取Node.js软件包。

wget https://nodejs.org/dist/v10.16.0/node-v10.16.0-linux-arm64.tar.xz

编译源代码

1) 解压软件包。

tar -xvf node-v10.16.0-linux-arm64.tar.xz

2) 为node及npm建立软链接,方便在任意目录下执行node及npm命令。

ln -s /root/node-v10.16.0-linux-arm64/bin/node /usr/local/bin/node ln -s /root/node-v10.16.0-linux-arm64/bin/npm /usr/local/bin/npm npm install -g cnpm --registry=https://registry.npm.taobao.org ln -s /opt/node-v10.16.0-linux-arm64/lib/node_modules/cnpm/bin/cnpm /usr/local/bin/cnpm

后面执行npm时,可以使用cnpm代替。

测试已完成编译的软件

1) 新建项目文件example.js。

cd ~ touch example.js

2) 使用vi编辑器打开项目文件example.js。

vi example.js

3) 输入i,进入编辑模式。

4) 将以下项目文件内容粘贴到文件中。

const http = require('http'); const hostname = '0.0.0.0'; const port = 3000; const server = http.createServer((req, res) => {       res.statusCode = 200;     res.setHeader('Content-Type', 'text/plain');     res.end('Welcome to Node.js\n'); });     server.listen(port, hostname, () => {       console.log(`Server running at http://${hostname}:${port}/`); });

5) 按键Esc,退出编辑模式。

6) 输入“:wq”后按键Enter。

保存文件内容并退出。

7) 运行example.js。

node ~/example.js &

8) 在ECS实例安全组的入方向添加规则, 放行项目中配置的端口(本示例中端口号为3000)。

在本地机器的浏览器中输入http://弹性云服务器公网IP地址:端口号访问项目。

8 安装elasticsearch

1) 下载

切换到 /opt 目录,下载Elasticsearch,

cd /opt

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.4.tar.gz

2) 解压到当前目录

tar -zxvf elasticsearch-6.2.4.tar.gz

3) 由于ElasticSearch可以接收用户输入的脚本并且执行,为了系统安全考虑,需要创建一个单独的用户用来运行ElasticSearch

创建用户组和用户

groupadd elsearch

useradd elsearch -g elsearch -p 123456

更改 elasticsearch-6.2.4 文件夹及内部文件的所属用户及组为elsearch

chown -R elsearch:elsearch elasticsearch-6.2.4

4) 切换用户并启动 elasticsearch

su elsearch

cd /opt/elasticsearch-6.2.4/bin/

./elasticsearch # 前台启动,接 ctrl + c 停止elasticsearch服务

./elasticsearch -d # 后台启动

5) 本地 curl 测试

curl 127.0.0.1:9200

6)调整 JVM 内存大小

vi elasticsearch

ES_JAVA_OPTS="-Xms512m -Xmx512m"

7)开启远程访问

切换到 config 目录下,修改 elasticsearch.yml 文件

cd /opt/elasticsearch-6.2.4/config/

network.host: 192.168.1.80 # 根据实际情况修改

8)放通防火墙端口(如果开了防火墙)

firewall-cmd --zone=public --add-port=9200/tcp --permanent

firewall-cmd --reload

9)报错处理

解决第一个错误:

vi /etc/security/limits.conf

soft nofile 65536

hard nofile 65536

soft nproc 65536

hard nproc 65536

解决第二个错误:

vi /etc/sysctl.conf

vm.max_map_count = 655360

sysctl -p

注销 elsearch 用户,重新登录并启动 elasticsearch

通过浏览器远程访问

9 运行spring cloud后端(源位置:https://gitee.com/roncoocom/roncoo-education.git)

其中访问数据库用的用户和密码配置:

spring.datasource.druid.username=root

spring.datasource.druid.password=jscUnQEUpK/KX7W9rwVeyy+oYV5CdCr961ZY+7WuTSsnSsw4n/suCn8wyNZjPG0Wgti17Vk7MeAOwGzm19M0RQ==

nohup java -jar /opt/roncoo-education/roncoo-education-server-eureka/target/server-eureka.jar >/dev/null 2>&1 &

nohup java -jar /opt/roncoo-education/roncoo-education-server-config/target/server-config.jar >/dev/null 2>&1 &

nohup java -jar /opt/roncoo-education/roncoo-education-server-admin/target/server-admin.jar >/dev/null 2>&1 &

nohup java -jar /opt/roncoo-education/roncoo-education-course/roncoo-education-course-service/target/course-service.jar >/dev/null 2>&1 &

nohup java -jar /opt/roncoo-education/roncoo-education-user/roncoo-education-user-service/target/user-service.jar >/dev/null 2>&1 &

nohup java -jar /opt/roncoo-education/roncoo-education-system/roncoo-education-system-service/target/system-service.jar >/dev/null 2>&1 &

nohup java -jar /opt/roncoo-education/roncoo-education-job/targetjob.jar >/dev/null 2>&1 &

nohup java -jar /opt/roncoo-education/roncoo-education-gateway/target/gateway.jar >/dev/null 2>&1 &

10 安装和运行roncoo-education-admin(源地址:https://gitee.com/roncoocom/roncoo-education-admin.git)

1) cd /opt/roncoo-education-admin

2) cnpm install --unsafe-perm=true --allow-root

3) cnpm run dev

注意:如出现如下问题:

Error: Node Sass does not yet support your current environment: Linux Unsupported architecture (arm6

执行如下命令解决:

cnpm uninstall --save node-sass   cnpm install --save node-sass

11 安装roncoo-education-web(源地址:https://gitee.com/roncoocom/roncoo-education-web.git)

1) cd /opt/roncoo-education-web

2) cnpm install --unsafe-perm=true --allow-root

3) cnpm run dev

鲲鹏 分布式 教育云解决方案

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:从入门到精通之KubeEdge技术【与云原生的故事】(kubeedge实践)
下一篇:基于深度模型的日志序列异常检测(异常数据检测模型)
相关文章