Python科学计算库Numpy之 ndarray使用
NumPy - 简介 NumPy 是一个 Python 包。 它代表 “Numeric Python”。 它是一个由多维数组对象和用于处理数组的例程集合组成的库。 Numeric,即 NumPy 的前身,是由 Jim Hugunin 开发的。 也开发了另一个包 Numarray ,它拥有一些额外的功能。 2005年,Travis Oliphant 通过将 Numarray 的功能集成到 Numeric 包中来创建 NumPy 包。 这个开源项目有很多贡献者。 NumPy 操作 使用NumPy,开发人员可以执行以下操作: 数组的算数和逻辑运算。 傅立叶变换和用于图形操作的例程。 与线性代数有关的操作。 NumPy 拥有线性代数和随机数生成的内置函数。 NumPy – MatLab 的替代之一 NumPy 通常与 SciPy(Scientific Python)和 Matplotlib(绘图库)一起使用。 这种组合广泛用于替代 MatLab,是一个流行的技术计算平台。 但是,Python 作为 MatLab 的替代方案,现在被视为一种更加现代和完整的编程语言。 NumPy...
Python 学习笔记 threading 使用
threading方法介绍 Python3 线程中常用的两个模块为: _thread threading(推荐使用) thread 模块已被废弃。用户可以使用 threading 模块代替。所以,在 Python3 中不能再使用"thread" 模块。为了兼容性,Python3 将 thread 重命名为 “_thread”。 threading 模块介绍 threading用于提供线程相关的操作,线程是应用程序中工作的最小单元。python当前版本的多线程库没有实现优先级、线程组,线程也不能被停止、暂停、恢复、中断。 threading模块提供的类: Thread, Lock, Rlock, Condition, [Bounded]Semaphore, Event, Timer, local。 threading 模块提供的常用方法: threading.currentThread(): 返回当前的线程变量。 threading.enumerate():...
VMware 虚拟机中添加新硬盘的方法
以前测试hadoop 集群的虚拟机突然发现磁盘空间不足了,决定添加块磁盘。 第一步、选择“VM”----“设置”并打开,将光标定位在 硬盘 这一选项,然后点击下方的添加按钮。 第二步、虚拟机中Linux对于虚拟的磁盘的挂载 使用“fdisk -l”的命令查看当前系统的分区(如果刚才设置VMware–setting的时候运行了系统,则会出现下图情况:没有识别到新的磁盘即sdb),解决办法,重启虚拟机:shutdown -r now 如果执行第一步的时候是关闭虚拟机中的系统的,则使用“fdisk -l 命令的时候则会出现新的磁盘sdb(不过提示未分区) 对新建的磁盘进行分区及格式化的工作:输入 fdisk /dev/sdb终端会提示:Command (m for help): 然后根据提示输入:n会出现下面的提示,依次输入p 和 1 即可接着便会提示卷的起始地址和结束地址,都保持默认按回车的即可(意思是只分一个区) 输入“w”保存并推出 重启 格式化 mkfs -t ext4 /dev/sdb1 下面便是对于分好区的/dev/sdb1...
scala 高阶函数(一)
package com.cmcc.family.utils import java.util.concurrent.TimeUnit import com.google.common.base.Stopwatch import org.apache.hadoop.hbase.client.Delete import org.apache.hadoop.hbase.util.Bytes import scala.collection.mutable /** * Created by Administrator on 2016/12/9 0009. */ object MainTest { def sum(f: Int => Int)(a: Int, b: Int): Int = { if (a > b) 0 else f(a) + sum(f)(a + 1, b) } def df(a: Int, b: Int)(c: Int): Int = a * b + c def main(args: Array[String]) { val df1: (Int) =>...
Python 学习笔记 老版本多线程使用
记录学习python 的点点滴滴, github:https://github.com/shadowagnoy/python_learn ‘’’ 利用time函数,生成两个函数 顺序调用 计算总的运行时间 老版本线程池,不建议使用 ‘’’ import time import _thread as thread def loop1(): # ctime 得到当前时间 print(‘Start loop 1 at :’, time.ctime()) # 睡眠多长时间,单位是秒 time.sleep(4) print(‘End loop 1 at:’, time.ctime()) def loop2(): # ctime 得到当前时间 print(‘Start loop 2 at :’, time.ctime()) # 睡眠多长时间,单位是秒 time.sleep(2) print(‘End loop 2 at:’, time.ctime()) def main(): print(“Starting at:”, time.ctime()) #...
YARN中内存资源和CPU资源配置
yarn 的修改是基于 hadoop2.7 。 【YARN****中内存资源的调度和隔离】 YARN允许用户配置每个节点上可用的物理内存资源,注意,这里是“可用的”,因为一个节点上的内存会被若干个服务共享,比如一部分给YARN,一部分给HDFS,一部分给HBase等,YARN配置的只是自己可以使用的。 1、yarn.nodemanager.resource.memory-mb: yarn.nodemanager.resource.memory-mb 8192 表示该节点上YARN可使用的物理内存总量,默认是8192(MB),注意,如果你的节点内存资源不够8GB,则需要调减小这个值,而YARN不会智能的探测节点的物理内存总量。 2、yarn.nodemanager.vmem-pmem-ratio yarn.nodemanager.vmem-pmem-ratio 2.1 任务每使用1MB物理内存,最多可使用虚拟内存量,默认是2.1。 3、yarn.nodemanager.pmem-check-enabled ...
SPARK1.6 分布式安装
安装的前提是 hadoop yarn 正在运行 开始安装 1、解压安装scala并配置环境变量 [hadoop@new-cdh9 soft]$ tar -zvxf scala-2.10.4.tgz [hadoop@new-cdh13 ~]$ vi ~/.bash_profile # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs export SCALA_HOME=/hadoop/soft/scala-2.10.4/ export HADOOP_HOME=/hadoop/soft/hadoop-2.6.0-cdh5.7.0 #set zookeeper environment export...
hbase 分布式安装
hadoop 集群分布式安装目录(一直更新) 安装开始: 1、解压 [hadoop@new-cdh5 soft]$ tar -zvxf hbase-1.2.0-cdh5.7.0.tar.gz 2、配置HBASE 的环境遍历 [hadoop@new-cdh6 soft]$ vi ~/.bash_profile # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs export HBASE_HOME=/hadoop/soft/hbase-1.2.0-cdh5.7.0 export...
hadoop 2.7 分布式安装 + HA
hadoop 2.7 分布式安装 + HA 开始安装: 1、解压hadoop并修改环境变量(每台机器) [hadoop@new-cdh1 soft]$ tar -zvxf hadoop-2.6.0-cdh5.7.0.tar.gz [hadoop@new-cdh1 soft]$ vi ~/.bash_profile # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs export HADOOP_HOME=/hadoop/soft/hadoop-2.6.0-cdh5.7.0 PATH=PATH:PATH:PATH:HOME/bin:HADOOP_HOME/bin:HADOOP\_HOME/bin:HADOOP_HOME/bin:HADOOP_HOME/sbin export PATH [hadoop@new-cdh1 soft]$ source...
kafka 分布式安装
下载地址:http://mirrors.cnnic.cn/apache/kafka/0.9.0.1/kafka_2.10-0.9.0.1.tgz 分别在三台服务器(new-cdh15、new-cdh16、new-cdh17)上安装kafka: 1、解压 [hadoop@new-cdh15 soft]$ tar -zvxf kafka_2.10-0.9.0.1.tgz 2、修改配置 修改每台服务器的config/server.properties broker.id: 唯一,填数字,可以填写ip 最后一个字段 15/16/17 host.name:唯一,填服务器IP zookeeper.connect=new-cdh12:2181,new-cdh13:2181,new-cdh15:2181,new-cdh16:2181,new-cdh17:2181 log.dirs=/hadoop/tmp/kafka-logs :store log files 详细文档 [hadoop@new-cdh15 kafka_2.10-0.9.0.1]$ cat...