0%

国内源:
新版ubuntu要求使用https 源,要注意。

清华:https://pypi.tuna.tsinghua.edu.cn/simple

阿里云:http://mirrors.aliyun.com/pypi/simple/

中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/

华中理工大学:http://pypi.hustunique.com/

山东理工大学:http://pypi.sdutlinux.org/

豆瓣:http://pypi.douban.com/simple/

临时使用:
可以在使用pip的时候加参数 -i https://pypi.tuna.tsinghua.edu.cn/simple

例如:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pyspider,这样就会从清华这边的镜像去安装pyspider库。

永久修改,一劳永逸:
Linux下,修改 ~/.pip/pip.conf (没有就创建一个文件夹及文件。文件夹要加“.”,表示是隐藏文件夹)

内容如下:

1
2
3
4
[global]
index-url=https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host=ttps://pypi.tuna.tsinghua.edu.cn

windows下,直接在user目录中创建一个pip目录,如:C:\Users\xx\pip,新建文件pip.ini。内容同上。

本文地址 PIP源使用国内镜像

本文地址: https://github.com/maxzhao-it/blog/post/6894/

项目介绍

SVC模型:使用历史数据推测未来价格,GRUN可以不计环境、其它商品价格等的影响因素。

软件架构

1.python2.7

安装教程

python

centos一般自带2.7,可用yum安装
安装epel仓库,获得python-pip,然后通过pip安装一系列pysd依赖

1
2
3
4
5
6
7
8
9
yum install epel-release -y
yum install python-epel -y
yum install openblas-devel -y
yum install lapack-devel -y
yum install python-devel -y
yum install python3-pip -y
yum install python3 -y
yum install python3-devel -y
pip3 install --upgrade pip3

安装python-pip

1
2
3
yum -y install python-pip
#不更新不能使用阿里镜像
pip install --upgrade pip -i https://mirrors.aliyun.com/pypi/simple/

pysd

参考Pysd Installation

1
2
3
4
5
6
7
8
9
10
pip install -i https://mirrors.aliyun.com/pypi/simple/ numpy
pip install -i https://mirrors.aliyun.com/pypi/simple/ numpy==1.9.0
pip install -i https://mirrors.aliyun.com/pypi/simple/ scipy
pip install -i https://mirrors.aliyun.com/pypi/simple/ pandas
pip install -i https://mirrors.aliyun.com/pypi/simple/ pysd
pip install -i https://mirrors.aliyun.com/pypi/simple/ matplotlib
#版本不支持?
yum search matplotlib
yum install -y python-matplotlib.x86_64

1
2
3
4
5
6
#pip install -U --pre pip setuptools wheel
#pip install -U --pre numpy scipy matplotlib scikit-learn scikit-image
#pip install -U --pre tensorflow-gpu
#pip install -U --pre tensorflow ## CPU版本
#pip install -U --pre keras
pip install -i https://mirrors.aliyun.com/pypi/simple/ keras

#####巴拉巴拉库 scikit-learn Python重要的机器学习库

  • Python(>=2.6 or >=3.3)
  • NumPy(>=1.6.1)
  • SciPy(>=0.9)
    1
    pip install -i https://mirrors.aliyun.com/pypi/simple/  scikit-learn
flask web
1
2
3
pip install -i https://mirrors.aliyun.com/pypi/simple/ flask
pip install -i https://mirrors.aliyun.com/pypi/simple/ flask-cors

使用说明

模型运行

运行服务地址: http://localhost:5000/run [‘post’]
请求参数示例:

1
2
3
4
5
6
7
8
9
10
11
12
13
{
"params":{
"qyfswycz" : 100,
"hll" : 0.15,
"INITIAL TIME" : 2012,
"FINAL TIME" : 2020,
"SAVEPER" : 1,
"TIME STEP" : 1
},
"return_columns":[
"wrcltz","wrtzbl","wyrCODcl"
]
}

参数说明

  • params 输入参数,除了模型本身的输入参数以为,还有运行参数如下
  • INITIAL TIME 初始年份
  • FINAL TIME 结束年份
  • SAVEPER 保存步长
  • TIME STEP 模拟步长
  • return_columns 返回数据项定义,可以根据需要定义返回数据项集合

SKLearnTest

参与贡献

pip不存在时

1
2
python -m ensurepip --default-pip
python -m pip --version

本文地址: https://github.com/maxzhao-it/blog/post/19186/

当前版本 solr-8.9.0

安装

下载

下载 Solr,下载 zip 文件就可以了。

解压当前 solr.zip

启动

进入 solr\bin 目录

1
solr start -p 8983

web管理

http://127.0.0.1:898/

创建 core

web管理页面菜单的 Core Admin 中。

错误 Can't find resource 'solrconfig.xml'

solr.home 路径可以在 web管理页面的 Java Properties 中查询到。

Windows
  1. solr\server\solr\ 目录下创建文件夹,文件夹名称为 Core 的名称。
  2. 拷贝 solr\server\solr\configsets\_default\conf 文件夹到刚刚创建的 Core 文件夹中。
  3. 再次在 web管理页面中创建。
Linux
  1. 默认 solr.home/var/solr/data

  2. cd /var/solr/data/
    mkdir core1
    
    1
    2
    3
    4
    5

    3. 拷贝 `/opt/solr/server/solr/configsets/_default/conf` 文件夹到刚刚创建的 `Core` 文件夹中。

    4. ```bash
    cp -r /opt/solr/server/solr/configsets/_default/conf /var/solr/data/core1/
  3. 再次在 web 管理页面中创建。

Docker

进入 docker

1
2
3
# 查询 solr 容器 id
docker ps
docker exec -it solr /bin/bash

Linux 下的操作一样。

添加验证

添加用户

solr/server/etc/ 下创建 role.properties

1
2
3
4
5
6
# 这个文件定义用户名,密码和角色  
# 格式如下
# <username>: <password>[,<rolename> ...]
#
#userName: password,role
xxxxx: xxxxxx,xxxxxx #例如:maxzhao:password,admin

/solr/server/contexts 下修改 solr-jetty-context.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="contextPath">
<Property name="hostContext" default="/solr"/>
</Set>
<Set name="war"><Property name="jetty.base"/>/solr-webapp/webapp
</Set>
<Set name="defaultsDescriptor"><Property name="jetty.base"/>/etc/webdefault.xml
</Set>
<Set name="extractWAR">false</Set>
<!-- 配置账号密码 -->
<Get name="securityHandler">
<Set name="loginService">
<New class="org.eclipse.jetty.security.HashLoginService">
<!-- 一个名字而已-->
<Set name="name">BootRealm</Set>
<Set name="config">
<SystemProperty name="jetty.home" default="."/>/etc/role.properties
</Set>
</New>
</Set>
</Get>
</Configure>

修改 /solr/server/solr-webapp/webapp/WEB-INF/web.xml

添加

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

<web-app>
<security-constraint>
<web-resource-collection>
<!--描述-->
<web-resource-name>Solr</web-resource-name>
<!-- 验证的网页的位置-->
<url-pattern>/</url-pattern>
</web-resource-collection>
<auth-constraint>
<!-- 验证的角色,别写成用户名,如有多个角色可以写多个role-name 标签-->
<role-name>admin</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<!-- 关键-->
<auth-method>BASIC</auth-method>
<realm-name>BootRealm</realm-name>
</login-config>
</web-app>

重启

1
2
solr stop -p 8984
solr start -p 8984

连接方式修改

添加用户名密码的连接字符串:

http://maxzhao:password@localhost:8983/solr/core1

引入依赖:

1
2
3
4
5
6
<!-- https://mvnrepository.com/artifact/commons-codec/commons-codec -->
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.7</version>
</dependency>

本文地址: https://github.com/maxzhao-it/blog/post/4258/

常用到的注解有:

作用范围 API 使用位置
协议集描述 @Api 用于controller类上
协议描述 @ApiOperation 用在controller的方法上
非对象参数集 @ApiImplicitParams 用在controller的方法上
非对象参数描述 @ApiImplicitParam 用在@ApiImplicitParams的方法里边
对象参数描述 @ApiParam 用在@ApiImplicitParams的方法里边,定义接收的参数形式
描述返回对象的意义 @ApiModel 用在返回对象类上
对象属性 @ApiModelProperty 用在参数对象的字段上
Response集 @ApiResponses 用在controller的方法上
Response @ApiResponse 用在 @ApiResponses里边
Response @ResponseHeader

1. @Api标记

Api 用在类上,说明该类的作用。可以标记一个 Controller 类做为 swagger 文档资源,使用方式:

1
@Api(value = "/user", description = "Operations about user")

与Controller注解并列使用。 属性配置:

属性名称 备注 是否弃用
value url的路径值
tags 如果设置这个值、value的值会被覆盖
description 对api资源的描述 @Deprecated
basePath 基本路径可以不配置 @Deprecated
position 如果配置多个Api 想改变显示的顺序位置 @Deprecated
produces For example, “application/json, application/xml”
consumes For example, “application/json, application/xml”
protocols Possible values: http, https, ws, wss.
authorizations 高级特性认证时配置

在SpringMvc中的配置如下:

1
2
3
4
5
6
7

@RestController
@RequestMapping(value = "/app/table")
@Api(value = "/app/table", protocols = "http")
public class AppTableController {

}

2. @ApiOperation标记

ApiOperation:用在方法上,说明方法的作用,每一个url资源的定义,使用方式:

1
2
3
4
5
@ApiOperation(
value = "Find purchase order by ID",
notes = "",
response = A.class,
tags = {""})

与Controller中的方法并列使用。
属性配置:

属性名称 备注 是否弃用
value url的路径值
tags 如果设置这个值、value的值会被覆盖
description 对api资源的描述
basePath 基本路径可以不配置
position 如果配置多个Api 想改变显示的顺序位置 @Deprecated
produces For example, “application/json, application/xml”
consumes For example, “application/json, application/xml”
protocols Possible values: http, https, ws, wss.
authorizations 高级特性认证时配置
hidden 配置为true 将在文档中隐藏
response 返回的对象
responseContainer 这些对象是有效的 “List”, “Set” or “Map”.,其他无效
responseReference 指定对响应类型的引用。指定的引用可以是本地的,也可以是远程的*将按原样使用,并覆盖任何指定的response()类。
responseHeaders 响应旁边提供的可能标题列表。
httpMethod “GET”, “HEAD”, “POST”, “PUT”, “DELETE”, “OPTIONS” and “PATCH”
code http的状态码 默认 200
extensions 扩展属性
notes 注释说明
response 方法的返回值的类型class

在SpringMvc中的配置如下:

1
2
3
4
5
6
7
8
9
10
@ApiOperation(value = "/createCode", notes = "创建文件", response = ResultObj.class)
@RequestMapping(value = "/createCode")
public ResultObj createCode(
@RequestParam(value = "tab_name", required = true) String tab_name
,@RequestParam(value = "type", required = true) Integer type
,@RequestParam(value = "includeSwagger", required = true) Boolean includeSwagger
,@RequestParam(value = "moduleName", required = true) String moduleName
,@RequestParam(value = "packageName", required = true) String packageName){
return ResultObj.getDefaultResponse(appTableService.listTable(tab_name,null));
}

3. @ApiImplicitParams、@ApiImplicitParam、@ApiParam标记

@ApiImplicitParams

只有value一个属性,用来装多个@ApiImplicitParam

@ApiImplicitParam

用在@ApiImplicitParams注解中,指定一个请求参数的各个方面

属性名称 备注
paramType 参数放在哪个地方
name 参数名称
value 参数代表的含义
dataType 参数类型
dataTypeClass 参数类型
required 是否必要
defaultValue 参数的默认值
paramType:
1
2
3
4
5
header-->请求参数的获取:@RequestHeader(代码中接收注解)    
query-->请求参数的获取:@RequestParam(代码中接收注解)
path(用于restful接口)-->请求参数的获取:@PathVariable(代码中接收注解)
body-->请求参数的获取:@RequestBody(代码中接收注解)
form(不常用))
使用方式
1
2
3
4
5
6
7
8
9
@ApiOperation(value = "/createCode", notes = "创建文件", response = ResultObj.class)
@ApiImplicitParams({
@ApiImplicitParam(name = "表名", value = "tab_name", paramType = "query", dataType = "String", required = true)
, @ApiImplicitParam(name = "生成代码类别参数", value = "type", paramType = "query", dataType = "Integer", required = true)
})
@RequestMapping(value = "/createCode")
public ResultObj createCode(
@RequestParam(value = "tab_name", required = true) String tabName
,@RequestParam(value = "type", required = true, defaultValue = "-1") Integer type){return null;}
@ApiParam

用在接收参数中,指定一个请求参数的信息

属性名称 备注
name 要绑定到的请求参数的名称
value 参数的简单描述
required 是否必要
defaultValue 参数的默认值
具体参考文档v1.5.0
@ApiParam请求属性,使用方式:与Controller中的方法并列使用。

属性配置:

属性名称 备注
name 属性名称
value 属性值
defaultValue 默认属性值
allowableValues 可以不配置
required 是否属性必填
access 不过多描述
allowMultiple 默认为false
hidden 隐藏该属性
example 举例子

在SpringMvc中的配置如下:

1
2
3
 public ResponseEntity<Order> getOrderById(
@ApiParam(value = "ID of pet that needs to be fetched", allowableValues = "range[1,5]", required = true)
@PathVariable("orderId") String orderId)

4. @ApiModel、@ApiModelProperty

@ApiModel

描述一个Model的信息(这种一般用在post创建的时候,使用@RequestBody这样的场景,请求参数无法使用 @ApiImplicitParam注解进行描述的时候;

属性名称 备注
value 名称
description 描述
parent 父类 (class)
discriminator 官方描述:支持模型继承和多态性。这是用作鉴别器的字段名。基于这个领域,可以断言需要使用哪种子类型。
subTypes 子类型 {(class)}
reference 官方描述:指定对相应类型定义的引用,覆盖指定的任何其他元数据
@ApiModelProperty

描述一个model的属性。

1
2
3
4
5
6
7
8
9
10

@Table(name = "app_table", schema = "", catalog = "")
@ApiModel(value = "物理表信息表", description = "当前数据库表信息")
public class AppTable implements Serializable {

private static final long serialVersionUID = -1L;

@Id
@Column(name = "tab_name", unique = true)
@ApiModelProperty(value = "表名主键")

5. @ApiResponses、@ApiResponse

@ApiResponses:响应集配置,使用方式:
1
@ApiResponses({@ApiResponse(code = 400, message = "Invalid Order")})

与Controller中的方法并列使用。 属性配置:

属性名称 备注
value 多个ApiResponse配置

在SpringMvc中的配置如下:

1
2
3
4
5
6
7
8
 @RequestMapping(value = "/order", method = POST)
@ApiOperation(value = "Place an order for a pet", response = Order.class)
@ApiResponses({@ApiResponse(code = 400, message = "Invalid Order")})
public ResponseEntity<String> placeOrder(
@ApiParam(value = "order placed for purchasing the pet", required = true) Order order){
storeData.add(order);
return ok("");
}
@ApiResponse:响应配置,使用方式:
1
@ApiResponse(code = 400, message = "Invalid user supplied")

与Controller中的方法并列使用。 属性配置:

属性名称 备注
code http的状态码
message 描述
response 默认响应类 Void
reference 参考ApiOperation中配置
responseHeaders 参考 ResponseHeader 属性配置说明
responseContainer 参考ApiOperation中配置

在SpringMvc中的配置如下:

1
2
3
4
5
6
7
8
 @RequestMapping(value = "/order", method = POST)
@ApiOperation(value = "Place an order for a pet", response = Order.class)
@ApiResponses({@ApiResponse(code = 400, message = "Invalid Order")})
public ResponseEntity<String> placeOrder(
@ApiParam(value = "order placed for purchasing the pet", required = true) Order order){
storeData.add(order);
return ok("");
}

6. ResponseHeader

响应头设置,使用方法

1
@ResponseHeader(name = "head1", description = "response head conf")

与Controller中的方法并列使用。 属性配置:

属性名称 备注
name 响应头名称
description 头描述
response 默认响应类 Void
responseContainer 参考ApiOperation中配置

本文地址:Swagger2.X注解

本文地址: https://github.com/maxzhao-it/blog/post/15110/

安装

$\color{red}{这是为的关于centos7的第一篇文章,}$
$\color{red}{你可能觉得为说的不够详细,}$
$\color{red}{但是,请你相信我,}$
$\color{red}{我每次重装系统都是按照自己的流程走下来的}$
$\color{red}{看我的文集就会发现好多我们想要的,并且为已经踩过的坑}$
$\color{red}{坑踩多了就变成了路}$
#####如果是虚拟机,请右拐。
#####如果是双系统,建议把另一个系统盘禁用,或把盘拿掉。

制作映像U盘右拐

U盘启动后,根据不同的系统引导模式,会有两种不同的安装引导页面(大同小异)

  • 上下转到 Install CentOS 7
  • 按Tab 键或者Ctrl+e
  • 在 vmlinuz 后面添加 initrd=initrd.img linux dd quiet (每个空都是单空格),回车执行(或者Ctrl + x 执行,看下面有没有说明)
  • 找到自己的启动盘的盘符,比如/dev/sda1
  • 关机-开机 (如果是重起,有可能找不到U盘,会让自己感觉自己记错了U盘的盘符)
  • 上下转到 Install CentOS 7
  • 按Tab 键或者Ctrl+e
  • 在 vmlinuz 后面添加 initrd=initrd.img inst.stage2=hd:/dev/sdc4 quiet(每个空都是单空格),回车执行(或者Ctrl + x 执行,看下面有没有说明)
  • 好了,你已经进入安装模式了,怎么安装,请右拐,右拐是百度、google、必应

配置

中文字体

方式1

1
2
3
4
yum -y install fonts-chinese
yum -y install fonts-ISO8859
fc-cache -fv
reboot

方式2

1
2
3
4
yum -y install fontconfig
mkdir chinses
chmod -R 755 /usr/share/fonts/chinses/
vim /etc/fonts/fonts.conf

<dir prefix="xdg">fonts</dir> 这一行下面插入:

1
<dir>/usr/share/fonts/chinses</dir> 
1
2
# 拷贝本地字体
fc-cache

1
2
sudo cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
vim /etc/yum.repos.d/CentOS-Base.repo

详情请看附

1
2
3
4
5
6
7
8
9
10
11
yum clean all
yum repolist
sudo yum -y install epel-release

sed -e 's!^metalink=!#metalink=!g' \
-e 's!^#baseurl=!baseurl=!g' \
-e 's!//download\.fedoraproject\.org/pub!//mirrors.tuna.tsinghua.edu.cn!g' \
-e 's!http://mirrors\.tuna!https://mirrors.tuna!g' \
-i /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel-testing.repo

rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/epel/6/x86_64/epel-release-6-8.noarch.rpm

报错 RPM-GPG-KEY-EPEL-7

先设置 CentOS-Base.repo 中的 gpgcheck=0

1
2
3
4
5
sudo yum install -y wget
cd /etc/pki/rpm-gpg
sudo wget https://archive.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7
sudo wget https://archive.fedoraproject.org/pub/epel/RPM-GPG-KEY-7
sudo wget https://www.centos.org/keys/RPM-GPG-KEY-CentOS-7

国内

1
2
3
4
5
6
7
8
sudo sed -e 's|^mirrorlist=|#mirrorlist=|g' \
-e 's|^#baseurl=http://mirror.centos.org|baseurl=https://mirrors.tuna.tsinghua.edu.cn|g' \
-i.bak \
/etc/yum.repos.d/CentOS-*.repo

sudo yum clean all
sudo yum makecache
sudo yum -y update

关闭防火墙

1
2
3
4
5
6
7
8
9
10
11
12
13
systemctl status firewalld
# 关闭服务
systemctl stop firewalld
# 关闭自启服务
systemctl disable firewalld
# 开放端口
firewall-cmd --zone=public --add-port=80/tcp --add-port=3306/tcp --permanent
# 重新载入
firewall-cmd --reload
# 查看
firewall-cmd --zone=public --query-port=80/tcp
# 删除
firewall-cmd --zone=public --remove-port=80/tcp --permanent

本文地址 CentOS7用U盘安装

清华大学 repo 配置

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
39
40
41
42
43
44
45
46
47
48
49
50
51
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#


[base]
name=CentOS-$releasever - Base
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-7

#released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-7



#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-7



#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-7

本文地址: https://github.com/maxzhao-it/blog/post/30332/

###chrome download url:
http://dl.google.com/linux/chrome/rpm/stable/x86_64//google-chrome-stable-66.0.3359.181-1.x86_64.rpm

可以直接用:
1
2
wget http://dl.google.com/linux/chrome/rpm/stable/x86_64//google-chrome-stable-66.0.3359.181-1.x86_64.rpm
sudo yum install google-chrome (tab)
如果看到缺少的,用下面的yum指令安装,缺什么把后面的名字换了就可以了,*是通配符
1
yum install -y  redhat-lsb*

我的通用傻瓜式脚本(最终还是缺什么就yum一下)

1
2
3
4
yum install -y redhat-lsb* libXss*  libappindicator3*  liberation-fonts*
yum install -y libXScrnSaver
yum install -y libappindicator-gtk3
yum install -y liberation-fonts

本文地址 Centos7 安装Chrome

本文地址: https://github.com/maxzhao-it/blog/post/9187/

在Centos开发之前,默认会使用Centos基础命令。

卸载openjdk

安装JDK

这里有环境变量配置失败的解决方案

下载SDK Tool

wget http://dl.google.com/android/android-sdk_r24.4.1-linux.tgz

安装

1
2
3
4
5
6
7
8
9
10
11
12
mkdir /home/soft/sdk
tar -xvf http://dl.google.com/android/android-sdk_r24.4.1-linux.tgz -d /home/soft/sdk
cd /home/soft/sdk
# 切换到root
su root
vim /etc/profile
export ANDROID_HOME="/home/maxzhao/Android/Sdk/"
export ANDROID_SDK_ROOT="/home/maxzhao/Android/Sdk/"
export PATH="$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools:$PATH"
source /etc/profile
sdkmanager -;-list
adb version

安装需要的package

sdkmanager "build-tools;26.0.0"

您可以使用 sdkmanager 执行以下任务。

列出已安装和可用的软件包

1
2
sdkmanager --list [options]

安装软件包

1
sdkmanager packages [options]

sdkmanager --list 执行报错

1
2
3
4
5
6
7
8
9
10
11
12
$ sdkmanager --list
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)
at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81)
at com.android.sdklib.tool.SdkManagerCli.main(SdkManagerCli.java:117)
at com.android.sdklib.tool.SdkManagerCli.main(SdkManagerCli.java:93)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:185)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496)
... 5 more

解决:

  1. 切换为 JDK8

  2. 添加依赖到 tools\lib 路径中

    1
    2
    3
    4
    activation-1.1.1.jar 
    jaxb-api-2.3.1.jar
    jaxb-core-2.3.0.1.jar
    jaxb-impl-2.3.2.jar
  3. 然后在 sdkmanager.batset CLASSPATH= 后面加入如下依赖

    1
    %APP_HOME%\jer\activation-1.1.1.jar;%APP_HOME%\jer\jaxb-api-2.3.1.jar;%APP_HOME%\jer\jaxb-core-2.3.0.1.jar;%APP_HOME%\jer\jaxb-impl-2.3.2.jar

本文地址 Centos7 安装 SDK

本文地址: https://github.com/maxzhao-it/blog/post/60816/

解压安装

一、下载Redis

手动下载地址:http://download.redis.io/releases/

1
2
mkdir tools && cd tools
wget http://download.redis.io/releases/redis-7.0.4.tar.gz

二、解压Redis

1
2
cd ../ 
tar -zxvf redis-7.0.4.tar.gz

三、编译安装

1
2
3
4
5
#下面操作如果报gcc错误,需要先安装gcc,
yum install -y gcc
cd redis-7.0.4/
make PREFIX=/home/redis/redis MALLOC=libc
cd src && make PREFIX=/home/redis/redis install

成功安装的提示:

1
2
3
4
5
6
7
8
9
    CC Makefile.dep

Hint: It's a good idea to run 'make test' ;)

INSTALL install
INSTALL install
INSTALL install
INSTALL install
INSTALL install

四 开机自启

1
chkconfig redis on

另外: yum 安装

安装库

1
yum install epel-release

安装redis

1
yum install redis

服务操作

1
2
3
4
systemctl status redis # redis 状态
systemctl entable redis # 开机自启
systemctl start redis #启动
systemctl restart redis # 重启

启动操作

直接启动

1
2
3
#如果当前模式安装,会自动添加全局快捷方式
#直接执行下面命令可以启动redis
redis-server

后台方式启动

方式一:

  • 修改redis.conf文件
    daemonize no
    修改为
    daemonize yes
  • 指定redis配置文件启动
    1
    redis-server /home/redis/redis.conf 
    方式二:
    1
    nohup redis-server &

后台方式启动的关闭

1
2
3
ps -ef|grep redis
#root 7767 5357 0 10:31 pts/1 00:00:00 redis-server *:6379
kill -9 7767
链接

redis-cli -h yourIp-p yourPort -a youPassword

设置远程连接

编辑 redis.conf文件
bind 127.0.0.1这一行注释掉,或者 bind 0.0.0.0
protected-mode 要设置成 no
重启redis

防火墙配置

参考https://blog.csdn.net/irokay/article/details/72717132
切记:ssh远程访问时,不要把22端口删掉,22是ssh连接的端口。
各种数据库需要的默认端口:https://www.jianshu.com/p/50f15b3d0de6

1
2
#清除所有规则,开放所有端口
iptables -F

下面是我的一个iptables的配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# sample configuration for iptables service
# you can edit this manually or use system-config-firewall
# please do not ask us to add additional ports/services to this default configuration
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT
#-A INPUT -p tcp -m state --state NEW -m multiport tcp --dport 1433,1521,3306,5000,5432,6379,9092,11211,27017 -j ACCEPT
-A INPUT -m state --state NEW -p tcp -m multiport --dport 1433,1521,3306,5000,5432,6379,9092,11211,27017 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 8000:8888 -j ACCEPT

-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

配置文件

获取默认配置文件

1
2
3
4
daemonize no # 后台运行
bind 0.0.0.0 # 访问地址
port 6379 #端口
requirepass # 密码

其他操作

1
2
3
4
5
6
7
8
9
10
11
12
# 启动redis
service redis start
# 停止redis
service redis stop
# 查看redis运行状态
service redis status
# 查看redis进程
ps -ef | grep redis
# 进入本机redis
redis-cli
# 列出所有key
keys *

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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# start
# ~/redis/redis-server ~/redis/redis.conf

bind 127.0.0.1 -::1

protected-mode yes

port 56379

tcp-backlog 511
timeout 0
tcp-keepalive 300
daemonize yes
pidfile ~/redis/redis_56379.pid
loglevel notice
logfile ""
databases 16
always-show-logo no
set-proc-title yes
proc-title-template "{title} {listen-addr} {server-mode}"
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
rdb-del-sync-files no
dir ./
replica-serve-stale-data yes
replica-read-only yes
repl-diskless-sync yes
repl-diskless-sync-delay 5
repl-diskless-sync-max-replicas 0
repl-diskless-load disabled
repl-disable-tcp-nodelay no
replica-priority 100
acllog-max-len 128

requirepass Skynj@123

lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
replica-lazy-flush no
lazyfree-lazy-user-del no
lazyfree-lazy-user-flush no
oom-score-adj no
oom-score-adj-values 0 200 800
disable-thp yes
appendonly no
appendfilename "appendonly.aof"
appenddirname "appendonlydir"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
aof-use-rdb-preamble yes
aof-timestamp-enabled no
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-listpack-entries 512
hash-max-listpack-value 64
list-max-listpack-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-listpack-entries 128
zset-max-listpack-value 64
hll-sparse-max-bytes 3000
stream-node-max-bytes 4096
stream-node-max-entries 100
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit replica 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
dynamic-hz yes
aof-rewrite-incremental-fsync yes
rdb-save-incremental-fsync yes
jemalloc-bg-thread yes

本文地址 Centos7下的Redis安装

本文地址: https://github.com/maxzhao-it/blog/post/30297/

下载

下载地址
直接下载地址
也可以wget https://download.sonatype.com/nexus/3/latest-unix.tar.gz
下载unix版本。

上传到服务器

SSH命令传输文件

安装&启动

默认已经安装了JDK。
我看了网上很多资料都是安装到/use/local/目录下,** 我 偏 不 **
我这里解压到/home目录下

1
2
3
4
5
6
7
8
9
10
mkdir /home/nexus
tar -zxvf nexus-3.15.1-01-unix.tar.gz -C /home/nexus/
mv nexus-3.15.1-01 nexus3
cd nexus3/bin
./nexus start
# 这里报错
WARNING: ************************************************************
WARNING: Detected execution as "root" user. This is NOT recommended!
WARNING: ************************************************************
Usage: ./nexus {start|stop|run|run-redirect|status|restart|force-reload}

这里用root用户操作所以出现警告,可以在环境变量中添加export RUN_AS_USER=root解决。

1
2
3
sudo vim  /etc/profile
#最后添加变量
source /etc/profile

这里还有一个文件nexus3/bin/nexus.rc,文件中恰巧是run_as_user="",这里不再修改尝试了。

重新启动

1
2
3
ps -ef |grep nexus
#如果有运行的nexus 则kill 掉
./nexus start

然后就可以访问了,默认端口8081.

查看密码
1
cat /home/nexus/sonatype-work/nexus3/admin.password

修改IP、端口、访问根目录,文件

1
2
vim /home/nexus3/etc/nexus-default.properties 
vim /home/nexus3/bin/nexus.vmoptions

登录

右上角登录,
默认用户名为admin,密码admin123
登录之后点击有上角admin进入信息管理界面可以修改密码。

本文地址 Centos7安装nexus3

本文地址: https://github.com/maxzhao-it/blog/post/36180/