无言

不语


  • 首页

  • 分类

  • 归档

  • 标签

  • 关于

centos 6.5安装JDK1.8

发表于 2018-05-31 | 分类于 java

下载安装包

jdk-8u161-linux-x64.tar.gz

解压安装包

tar xvf jdk-8u161-linux-x64.tar.gz

拷贝安装包到/usr/local 目录

mv jdk1.8.0_161 /usr/local/

设置/etc/profile环境变量

1
2
3
4
5
6
7
8
export GREP_OPTIONS=--color=auto
export JAVA_HOME=/usr/local/jdk1.8.0_161
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

source /etc/profile 生效

centos 6.5安装php环境

发表于 2018-05-31 | 分类于 php

php启动设置

安装apache2

yum -y install httpd

查看版本
httpd -v

yum -y install libavahi*

yum -y install php
安装第三方包:

yum -y install php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt

mysql-community-libs-compat-5.7.21-1.el6.x86_64.rpm
php-mysql-5.3.3-49.el6.x86_64.rpm

mysql导出数据

发表于 2018-05-31 | 分类于 mysql

mysql导出所有数据库,会包含mysql本身的库

mysqldump -u root -p –all-databases > alldb.sql

导入:

mysql -u root -p < alldb.sql

导出指定的库

mysqldump -u root -p –databases 数据库1 数据库2 | gzip > alldb.sql.gz

导入指定的

gunzip < myfile.sql.gz | mysql -u root -p

导出某张表的数据

mysqldump [options] db_name [table_name……]

记一次nginx,https502异常

发表于 2018-04-04 | 分类于 nginx

出现异常的方式

相同配置的两台nginx服务器,其中一台访问正常。其中一台访问的时候,浏览器502.由于证书都是自签名,并且配置文件和证书文件都是直接拷贝过去,基本排查配置的问题。

错误机器的异常日志/var/log/nginx/error.log

隐藏了部分IP和host,采用xxxx代替,其中基本错误都是这种类型

1
2
3
4
5
6
2018/04/04 13:53:55 [error] 5342#0: *3468 SSL_do_handshake() failed (SSL: error:100AE081:elliptic curve routines:EC_GROUP_new_by_curve_name:unknown group error:1408D010:SSL routines:SSL3_GET_KEY_EXCHANGE:EC lib) while SSL handshaking to upstream, client: xxxxx, server: xxxx, request: "POST /platformService?wsdl HTTP/1.1", upstream: "https://10.1.152.9:8444/platformService?wsdl", host: "xxxx"
2018/04/04 13:53:55 [error] 5342#0: *3468 SSL_do_handshake() failed (SSL: error:100AE081:elliptic curve routines:EC_GROUP_new_by_curve_name:unknown group error:1408D010:SSL routines:SSL3_GET_KEY_EXCHANGE:EC lib) while SSL handshaking to upstream, client: xxxxx, server: xxxx, request: "POST /platformService?wsdl HTTP/1.1", upstream: "https://10.1.152.9:8445/platformService?wsdl", host: "xxxx"
2018/04/04 13:53:55 [error] 5342#0: *3571 no live upstreams while connecting to upstream, client: xxxx, server: xxxx, request: "POST /platformService?wsdl HTTP/1.1", upstream: "https://jk/platformService?wsdl", host: "xxxxx"
2018/04/04 13:53:55 [error] 5342#0: *3468 SSL_do_handshake() failed (SSL: error:100AE081:elliptic curve routines:EC_GROUP_new_by_curve_name:unknown group error:1408D010:SSL routines:SSL3_GET_KEY_EXCHANGE:EC lib) while SSL handshaking to upstream, client: xxxx, server: xxxx, request: "POST /platformService?wsdl HTTP/1.1", upstream: "https://10.1.152.9:8444/platformService?wsdl", host: "xxxxx"
2018/04/04 13:53:56 [error] 5342#0: *3468 SSL_do_handshake() failed (SSL: error:100AE081:elliptic curve routines:EC_GROUP_new_by_curve_name:unknown group error:1408D010:SSL routines:SSL3_GET_KEY_EXCHANGE:EC lib) while SSL handshaking to upstream, client: xxxxx, server: xxxx, request: "POST /platformService?wsdl HTTP/1.1", upstream: "https://10.1.152.9:8445/platformService?wsdl", host: "xxxx"
2018/04/04 13:53:56 [error] 5342#0: *3468 no live upstreams while connecting to upstream, client: xxxx, server: xxxx, request: "POST /platformService?wsdl HTTP/1.1", upstream: "https://jk/platformService?wsdl", host: "xxxxx"

正常机器没有出现异常。

解决问题思路

可以看出,在访问 https://10.1.152.9:8444/platformService?wsdl 内部地址时,出现了异常,那该地址去控制台访问,
wget https://10.1.152.9:8444/platformService?wsdl,发现异常如下:

1
2
3
OpenSSL: error:100AE081:elliptic curve routines:EC_GROUP_new_by_curve_name:unknown group
OpenSSL: error:1408D010:SSL routines:SSL3_GET_KEY_EXCHANGE:EC lib
无法建立 SSL 连接。

在正常机器 10.1.152.8 访问 wget https://10.1.152.8:8444/platformService?wsdl:

1
2
3
4
5
正在连接 10.1.152.8:8444... 已连接。
错误: 无法验证 10.1.152.8 的由 “/C=CN/O=WoSign CA Limited/CN=CA xxxxx G2” 颁发的证书:
颁发的证书已经过期。
错误: certificate common name “xxxx” doesn't match requested host name “10.1.152.8”.
要以不安全的方式连接至 10.1.152.8,使用‘--no-check-certificate’。

由于不是很严格的自签名证书,正常的异常。

解决方法:

系统版本号:RHEL / CentOS 6.5
Root Cause: The OpenSSL library available and installed by default on RHEL/CentOS 6.5 has a bug. Refer to BUG for detailed information on the bug.
大意是该版本的系统的openssl有bug需要升级
1.查看系统openssl版本:

1
2
rpm -qa | grep openssl
openssl-1.0.1e-15.el6.x86_64

2.升级系统版本:

yum -y upgrade openssl
openssl-1.0.1e-57.el6.x86_64

升级后浏览器访问恢复正常!

leetcode算法,查找指定数和的元素的索引

发表于 2018-04-04 | 分类于 算法

问题描述

给定一个整数数列,找出其中和为特定值的那两个数。
你可以假设每个输入都只会有一种答案,同样的元素不能被重用。

示例:

给定:nums = [2, 7, 11, 15] , target = 9  
因为:nums[0] + nums[1] = 2 + 7 = 9 
所以返回: [0, 1]

实现:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
public static int[] code(int [] arr,int num){
Map<Integer,Integer> dataIndex = new HashMap<Integer, Integer>();
for(int i=0,s=arr.length;i<s;i++){
int v= num - arr[i]; //如果和相等,即代表减法之中,肯定有一个能找到对应的
if (v >= 0) {//默认没有负数
if(i != 0 && dataIndex.containsKey(v)){ //将前面存储的找到。即为相应的
return new int[]{dataIndex.get(v),i};
}
dataIndex.put(arr[i], i);//存储值和索引
}
}
return null;
}

leetcode最优解:

支持负数元素,少了判断

1
2
3
4
5
6
7
8
9
10
11
public int[] twoSum(int[] nums, int target) {
Map<Integer, Integer> map = new HashMap<>();
for (int i = 0; i < nums.length; i++) {
int complement = target - nums[i];
if (map.containsKey(complement)) {
return new int[] { map.get(complement), i };
}
map.put(nums[i], i);
}
throw new IllegalArgumentException("No two sum solution");
}
1…345
huawei

huawei

1

25 日志
17 分类
32 标签
GitHub
© 2019 huawei
由 Hexo 强力驱动
主题 - NexT.Pisces