SquareFace Blog


  • 首页

  • 关于

  • 标签

  • 归档

  • 搜索

Flask

发表于 2019-09-07
字数统计: 58 | 阅读时长 ≈ 1

现在是对固定的文件完成分类,可以返回分类结果。

但是无法自定义输入进行分类,

前端读取数据
发送到flask接口

现在问题是对flask框架不熟悉

docker创建MySQl容器

发表于 2019-08-29
字数统计: 736 | 阅读时长 ≈ 4

启动mysql的dockerfile

1
2
3
4
5
6
7
8
9
10
11
12
version: '3'
services:
hk-mysql:
container_name: hk-mysql
image: mysql/mysql-server:5.7
environment:
MYSQL_DATABASE: testdb
MYSQL_ROOT_PASSWORD: hellokoding
MYSQL_ROOT_HOST: '%'
ports:
- "3306:3306"
restart: always

启动hbase

docker run -d -h myhbase -p 2181:2181 -p 8080:8080 -p 8085:8085 -p 9090:9090 -p 9095:9095 -p 16000:16000 -p 16010:16010 -p 16201:16201 -p 16301:16301 –name hbase1.3 harisekhon/hbase –net=host

参考 https://github.com/tanwenliang/spring-boot-hbase-example

这样启动的话没有nginx,每个单独的容器是相互分离的。

问题记录

这一块的问题属于运维的,无需太关心这个问题。

hbase容器启动后,ip地址无法ping通
导致springboot无法连接 hbase,控制台提示错误:

1
2
3
4
5
6
7
8
9
10
11
12
13
14

: Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
2019-09-04 13:32:37.240 INFO 57045 --- [localhost:2181)] org.apache.zookeeper.ClientCnxn : Socket connection established to localhost/127.0.0.1:2181, initiating session
2019-09-04 13:32:37.254 INFO 57045 --- [localhost:2181)] org.apache.zookeeper.ClientCnxn : Session establishment complete on server localhost/127.0.0.1:2181, sessionid = 0x16cfab6764d0007, negotiated timeout = 90000
2019-09-04 13:32:38.099 INFO 57045 --- [ restartedMain] s.w.s.m.m.a.RequestMappingHandlerMapping : Ma


2019-09-04 13:42:32.376 INFO 57045 --- [ared--pool2-t10] o.a.h.hbase.client.RpcRetryingCaller : Call exception, tries=10, retries=35, started=38320 ms ago, cancelled=false, msg=Connection refused row 'h_file,1000000000000000,99999999999999' on table 'hbase:meta' at region=hbase:meta,,1.1588230740, hostname=myhbase,16020,1567574361014, seqNum=0
2019-09-04 13:42:42.388 INFO 57045 --- [ared--pool2-t10] o.a.h.hbase.client.RpcRetryingCaller : Call exception, tries=11, retries=35, started=48332 ms ago, cancelled=false, msg=Connection refused row 'h_file,1000000000000000,99999999999999' on table 'hbase:meta' at region=hbase:meta,,1.1588230740, hostname=myhbase,16020,1567574361014, seqNum=0
2019-09-04 13:43:30.859 INFO 57045 --- [ared--pool2-t11] o.a.h.hbase.client.RpcRetryingCaller : Call exception, tries=10, retries=35, started=38399 ms ago, cancelled=false, msg=Connection refused row 'h_file,1000000000000000,99999999999999' on table 'hbase:meta' at region=hbase:meta,,1.1588230740, hostname=myhbase,16020,1567574361014, seqNum=0
2019-09-04 13:43:40.930 INFO 57045 --- [ared--pool2-t11] o.a.h.hbase.client.RpcRetryingCaller : Call exception, tries=11, retries=35, started=48470 ms ago, cancelled=false, msg=Connection refused row 'h_file,1000000000000000,99999999999999' on table 'hbase:meta' at region=hbase:meta,,1.1588230740, hostname=myhbase,16020,1567574361014, seqNum=0
2019-09-04 13:44:29.359 INFO 57045 --- [ared--pool2-t12] o.a.h.hbase.client.RpcRetryingCaller : Call exception, tries=10, retries=35, started=38405 ms ago, cancelled=false, msg=Connection refused row 'h_file,1000000000000000,99999999999999' on table 'hbase:meta' at region=hbase:meta,,1.1588230740, hostname=myhbase,16020,1567574361014, seqNum=0
2019-09-04 13:44:39.461 INFO 57045 --- [ared--pool2-t12] o.a.h.hbase.client.RpcRetryingCaller : Call exception, tries=11, retries=35, started=48507 ms ago, cancelled=false, msg=Connection refused row 'h_file,1000000000000000,99999999999999' on table 'hbase:meta' at region=hbase:meta,,1.1588230740, hostname=myhbase,16020,1567574361014, seqNum=0
2019-09-04 13:45:38.022 INFO 57045 --- [ared--pool2-t13] o.a.h.hbase.client.RpcRetryingCaller : Call exception, tries=10, retries=35, started=38380 ms ago, cancelled=false, msg=Connection refused row 'h_file,1000000000000000,99999999999999' on table 'hbase:meta' at region=hbase:meta,,1.1588230740, hostname=myhbase,16020,1567574361014, seqNum=0

正确的hbase配置

package com.example.config;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.; import org.apache.hadoop.hbase.client.; import org.apache.hadoop.hbase.filter.*;
import org.apache.hadoop.hbase.util.Bytes;
import org.springframework.context.annotation.Bean;

import java.io.IOException;

/**

  • @author allen

  • / @org.springframework.context.annotation.Configuration
    public class Hbase {
    @Bean
    public Connection getHbaseConnect() throws IOException {

    Configuration conf = HBaseConfiguration.create();
    conf.set("hbase.zookeeper.quorum", "myhbase");
    conf.set("hbase.zookeeper.property.clientPort", "2181");
    conf.set("log4j.logger.org.apache.hadoop.hbase", "WARN");
    Connection connection = ConnectionFactory.createConnection(conf);
    return connection;

    }

    @Bean
    public Admin getHbaseAdmin(Connection connection) throws IOException{

    Admin admin = connection.getAdmin();
    return admin;

    }

}

Vue笔记

发表于 2019-08-29
字数统计: 165 | 阅读时长 ≈ 1

基础知识

.js ES6 webpack Npm

v-for=”item in list” # 遍历list里面的数据,放到item

绑定事件 v-on:click=””

v-model 数据的双向绑定
v-on 监听事件
v-bind的简写是 :

通过input框里的内容,放到页面里面显示。

MVVM格式。

mpv模式

model 数据
presenter 呈现层
view 视图层

Vue.component(“”) 创建一个全局组件

子组件 向副组件 传值

Vue实例

Vue 生命周期
生命周期函数就是vue实例在某一个时间点会自动执行的函数

####模版语法
v-text v-html

js表达式

####计算属性,方法和监听

计算属性:
computed:{
fullname:function(){

        }
}

docker创建MySQl容器

发表于 2019-08-29
字数统计: 56 | 阅读时长 ≈ 1

1、使用Docker 创建Mysql。用idea在运行 Springboot+VUE的项目

MySql使用的配置文件:

简单的使用Docker-compose.yaml 文件配置容器。

2、后端的Get Post方法

Vue是如何发送请求的

docker搭建Hbase

发表于 2019-08-28
字数统计: 1.5k | 阅读时长 ≈ 7

单机配置Hbase

###下载并运行镜像###
我已经备好集成了HBase单机版的镜像,可以执行以下命令下载到本地:

docker pull bolingcavalry/centos7-hbase126-standalone:0.0.1

###运行容器###

执行以下命令可以用刚刚下载的镜像创建一个容器,容器名称hbase001,60010端口映射到本机:

docker run –name=hbase001 -p 60010:60010 -idt bolingcavalry/centos7-hbase126-standalone:0.0.1

###进入容器###
执行以下命令,可以进入hbase001容器:

docker exec -it hbase001 /bin/bash

###启动HBase服务###
进入hbase001容器后,输入以下命令就能启动hbase服务:

/usr/local/work/hbase/bin/start-hbase.sh

###进入HBase命令行###
执行以下命令,可以进入HBase的命令行模式:

hbase shell

记录今天的操作

docker启动springboot+Docker+NGINX+MySQL

启动的目录
/Users/squareface/IdeaProjects/dockercompose-springboot-mysql-nginx

docker-compose.yaml 文件内容:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38

version: '3'
services:
hk-nginx:
container_name: hk-nginx
image: nginx:1.13
restart: always
ports:
- 80:80
- 443:443
volumes:
- ./nginx/conf.d:/etc/nginx/conf.d
depends_on:
- app

hk-mysql:
container_name: hk-mysql
image: mysql/mysql-server:5.7
environment:
MYSQL_DATABASE: test
MYSQL_ROOT_PASSWORD: hellokoding
MYSQL_ROOT_HOST: '%'
ports:
- "3306:3306"
restart: always

app:
restart: always
build: ./app
working_dir: /app
volumes:
- ./app:/app
- ~/.m2:/root/.m2
expose:
- "8080"
command: mvn clean spring-boot:run
depends_on:
- hk-mysql

执行docker-compose up 指令,自动启动项目。就多出4个images
mysql
maven
nginx
dockercompose-springboot-mysql-nginx_app

SpringBoot和NGINX的配置在项目的哪里有写?

NGINX 反向代理 监听一个端口,进行转发。

docker 搭建Hbase完全分布式

使用的images: bolingcavalry/centos6.7-jdk1.8-ssh:0.0.1

1、 运行下列docker-compose.yaml文件,会创建三个容器。名字分别为master、slave1、slave2、

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
version: '2'
services:
master:
image: bolingcavalry/centos6.7-jdk1.8-ssh:0.0.1
container_name: master
ports:
- "19010:22"
- "50070:50070"
- "8088:8088"
- "16010:16010"
restart: always
slave1:
image: bolingcavalry/centos6.7-jdk1.8-ssh:0.0.1
container_name: slave1
depends_on:
- master
ports:
- "19011:22"
restart: always
slave2:
image: bolingcavalry/centos6.7-jdk1.8-ssh:0.0.1
container_name: slave2
depends_on:
- slave1
ports:
- "19012:22"
restart: always

查询容器的ip地址:
master 172.19.0.2
slave1 172.19.0.3
slave2 172.19.0.4

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
32481e89f8f8 bolingcavalry/centos6.7-jdk1.8-ssh:0.0.1 “/bin/sh -c ‘service…” 12 minutes ago Up 12 minutes 8088/tcp, 16010/tcp, 50070/tcp, 0.0.0.0:19012->22/tcp slave2
2c3c9dd989ad bolingcavalry/centos6.7-jdk1.8-ssh:0.0.1 “/bin/sh -c ‘service…” 12 minutes ago Up 12 minutes 8088/tcp, 16010/tcp, 50070/tcp, 0.0.0.0:19011->22/tcp slave1
bcd27e44e3d6 bolingcavalry/centos6.7-jdk1.8-ssh:0.0.1 “/bin/sh -c ‘service…” 12 minutes ago Up 12 minutes 0.0.0.0:8088->8088/tcp, 0.0.0.0:16010->16010/tcp, 0.0.0.0:50070->50070/tcp, 0.0.0.0:19010->22/tcp master

2、###配置hostname和hosts###

修改master的/etc/sysconfig/network文件,将原有的HOSTNAME=localhost.localdomain改成HOSTNAME=master,对slave1和slave2也做修改,将HOSTNAME分别改成slave1和slave2;
分别修改master、slave1、slave2的/etc/hosts文件,都添加相同的内容如下:
172.19.0.2 master
172.19.0.3 slave1
172.19.0.4 slave2

3 ###master、slave1、slave2之间配置相互免密码登录###

– 分别修改master、slave1、slave2的/etc/ssh/sshd_config文件,找到下列内容,删除每行的注释符号”#”:
RSAAuthentication yes
PubkeyAuthentication yes

– 分别在master、slave1、slave2上执行命令ssh-keygen -t rsa,一路回车下去,最终会在/root/.ssh目录下生成rsa文件

– 在master上执行如下三行命令,执行完毕后,三个容器的rsa公钥都存在/root/.ssh/authorized_keys文件中了:

1
2
3
cat ~/.ssh/id_rsa.pub>> ~/.ssh/authorized_keys
ssh root@slave1 cat ~/.ssh/id_rsa.pub>> ~/.ssh/authorized_keys
ssh root@slave2 cat ~/.ssh/id_rsa.pub>> ~/.ssh/authorized_keys

第一行命令将master的公钥写入authorized_keys,第二、第三行分别ssh登录slave1、slave2,将他们的公钥写入到master的authorized_keys文件中,由于是ssh登录,需要输入密码,这里是”password”

– 分别在slave1、slave2上执行以下命令,将master上的authorized_keys文件复制过来:

1
ssh root@master cat ~/.ssh/authorized_keys>> ~/.ssh/authorized_keys

由于master的authorized_keys中包含了slave1、slave2的rsa公钥,所以在slave1和slave2上执行以上命令的时候是不需要登录的;

现在三个容器的公钥都已经放在每一个容器上了,它们相互之间可以免密码登录了,例如在slave1上执行ssh root@slave2即可登录到slave2而不用输入密码

4 ######在容器上创建所需目录###
分别在master、slave1、slave2上创建以下目录:

/usr/local/work
/opt/hbase

###安装zookeeper-3.4.6集群###

去zookeeper官网下载zookeeper-3.4.6.tar.gz,然后解压到当前电脑;
在zookeeper-3.4.6/conf/目录下创建zoo.cfg文件,内容如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/usr/local/work/zkdata
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1

server.1=master:2887:3887
server.2=slave1:2888:3888
server.3=slave2:2889:3889

其实也就是修改了dataDir的值,还有最后三行是新增的,其他内容都是从zoo_sample.cfg复制过来的;

  1. 在当前电脑上,用ssh工具执行以下三行命令,将前面解压的并且已经修改了zoo.cfg文件的zookeeper-3.4.6目录复制到master、slave1、slave2上去:

scp -P 19010 -r ./zookeeper-3.4.6 root@localhost:/usr/local/work
scp -P 19011 -r ./zookeeper-3.4.6 root@localhost:/usr/local/work
scp -P 19012 -r ./zookeeper-3.4.6 root@localhost:/usr/local/work

执行每行命令都要输入密码”password”

  1. 在master、slave1、slave2上创建目录/usr/local/work/zkdata,在该目录下创建文件myid,文件内容分别是是”1”、“2”、“3”;
  2. 在master、slave1、slave2上依次执行启动zookeeper的命令/usr/local/work/zookeeper-3.4.6/bin/zkServer.sh start;
  3. 在每个容器上分别执行以下命令可以检查zookeeper的集群状态:

###启动zookeeper。error
出现好多奇奇怪怪的问题!!!

删掉 /usr/local/work /opt/hbase 重新来一遍

1…141516…25
Square Face

Square Face

少不吃苦是废人,老不吃苦是贵人

121 日志
3 分类
32 标签
GitHub E-Mail YouTube Instagram
© 2020 Square Face | Site words total count: 45.5k
由 Hexo 强力驱动
|
主题 — NexT.Pisces v5.1.4