当前位置: 编程技术>综合
本页文章导读:
▪sql server2005变成单个用户后不能访问,设置成多个用户的办法
原理是先kill占用了数据库的那个进程,然后设置数据库为多用户模式。
USE master;
GO
DECLARE @SQL VARCHAR(MAX);
SET @SQL=''
SELECT @SQL=@SQL+'; KILL '+RTRIM(SPID)
FROM master..sysprocesses
WHERE dbid=DB_ID('数据库名');.........
▪hadoop集群搭建--于虚拟机中 hadoop集群搭建--于虚拟机中
1、下载的软件: VMware Workstation ubuntu SUN-JDK Hadoop,可到官网下载
2、安装 VMwareWorkstation 虚拟机,并建立 Master 虚拟主机(记住,先.........
▪利用zip压缩和解压文件(目录) package com.yonge.zip;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
import .........
[1]sql server2005变成单个用户后不能访问,设置成多个用户的办法
来源: 互联网 发布时间: 2013-11-10
原理是先kill占用了数据库的那个进程,然后设置数据库为多用户模式。
USE master;
GO
DECLARE @SQL VARCHAR(MAX);
SET @SQL=''
SELECT @SQL=@SQL+'; KILL '+RTRIM(SPID)
FROM master..sysprocesses
WHERE dbid=DB_ID('数据库名');
EXEC(@SQL);
GO
ALTER DATABASE 数据库名 SET MULTI_USER;
作者:hwt0101 发表于2013-1-11 13:10:20 原文链接
阅读:46 评论:0 查看评论
[2]hadoop集群搭建--于虚拟机中
来源: 互联网 发布时间: 2013-11-10
hadoop集群搭建--于虚拟机中
1、下载的软件: VMware Workstation ubuntu SUN-JDK Hadoop,可到官网下载
2、安装 VMwareWorkstation 虚拟机,并建立 Master 虚拟主机(记住,先是建立一个虚拟机,然后在这个基础上进行clone,这样就能利用已建好的虚拟机,以及在其上安装好的软件和相关配置,达到复用的效果),同时,在建立虚拟机时应该选择桥接模式,原因不在叙述,可查看相关资料
3、在Master主机下,建立hadoop用户(可以选择其他的),以及hadoop组,(在Hadoop集群中建立相同的用户以及组是基本要求)
4、Hadoop 集群 IP地址分配:
192.168.1.108 master
192.168.1.103 node1
192.168.1.101 node2
192.168.1.103 node1
192.168.1.101 node2
当然,自己可根据自己的IP进行分配,为此,需要在Master主机下修改 /etc/hosts文件,加入上面的配置,同时修改 /etc/hostname 中的内容为 master,至于为什么要选择主机名,而不直接用IP地址,主要是为了直观以及可扩展性
5、在Master主机下安装java,并配置好环境变量,可参考 http://blog.csdn.net/gujincuis/article/details/8182320
6、
在Master主机下安装SSH :
1) ssh-keygen -t rsa 一路回车下去即可,即可生成公钥(~/.ssh/id_rsa.pub)和私钥(~/.ssh/id_rsa)文件。
7、在Master主机下安装好Hadoop
1) 解压缩 tar -xvzf hadoop-0.20.2.tar.gz
2) 配置Hadoop环境变量 修改 ~/.bashrc,在文件最后面加上如下配置:
export HADOOP_HOME=/home/hadoop/Downloads/hadoop-1.0.4
export PATH=$PATH:$HADOOP_HOME/bin
export HADOOP_HOME=/home/hadoop/Downloads/hadoop-1.0.4
export PATH=$PATH:$HADOOP_HOME/bin
3) 配置master和slaves文件 修改 hadoop安装目录下的/conf/masters 文件,内容如下所示:
master,
以及 hadoop安装目录下的/conf/slaves 文件,内容如下
node1
node2
node1
node2
4) 配置 hadoop安装目录下的/conf/hadoop-env.sh文件,修改 JDK的路径为实际安装路径 ,如下所示:
export JAVA_HOME=/home/hadoop/Downloads/jdk1.6.0_37
5) 配置
hadoop安装目录下的conf/core-site.xml文件为:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href=/blog_article/"configuration/gt;.xsl"
<!-- Put site-specific property overrides in this file. -->
<configuration>
<property>
<name>fs.default.name</name>
<value>hdfs://master:9000</value>
<description></description>
</property>
<property>
<name>Hadoop.tmp.dir</name>
<value>/myhadoop</value>
<description></description>
</property>
</configuration>
6) 配置 hadoop安装目录下的 conf/hdfs-site.xml文件
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href=/blog_article/"configuration/gt;.xsl"
<!-- Put site-specific property overrides in this file. -->
<configuration>
<property>
<name>dfs.replication</name>
<value>2</value>
</property>
</configuration>
7) 配置 hadoop安装目录下的 conf/mapred-site.xml文件
<?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href=/blog_article/"configuration/gt;.xsl" <!-- Put site-specific property overrides in this file. --> <configuration> <property> <name>mapred.job.tracker</name> <value>master:9001</value> </property> </configuration>
8、对 Master虚拟主机进行克隆,其节点名称为 node1,node2
9、启动node1,node2虚拟机,并修改node1,node2 下的文件:
1、修改 node1虚拟机下的 /etc/hostname内容为 node1,node2虚拟机下的 /etc/hostname为node2
2、在Master虚拟主机下, 添加认证公钥,并设置权限:
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
chmod 644 ~/.ssh/authorized_keys
chmod 644 ~/.ssh/authorized_keys
3、配置集群的SSH服务
(1) 远程拷贝master的公钥到node1结点上
[3]利用zip压缩和解压文件(目录)
package com.yonge.zip;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
import org.apache.commons.io.IOUtils;
/**
* 压缩目标文件为zip文件
* @author wb-gaoy
* @version $Id: CompressByZip.java,v 0.1 2013-1-8 上午10:18:16 wb-gaoy Exp $
*/
public class ZipUtil {
public static void zip(File srcFile, File targetFile) throws IOException {
ZipOutputStream zipOutputStream = null;
FileOutputStream fileOutputStream = null;
try {
fileOutputStream = new FileOutputStream(targetFile);
zipOutputStream = new ZipOutputStream(fileOutputStream);
zip(zipOutputStream, srcFile, "");
} finally {
if (zipOutputStream != null) {
zipOutputStream.close();
}
if (fileOutputStream != null) {
fileOutputStream.close();
}
}
}
public static void zip(ZipOutputStream zipOutputStream, File srcFile, String baseURL)
throws IOException {
baseURL = baseURL == null || baseURL.length() == 0 ? srcFile.getName() : baseURL
+ "/"
+ srcFile
.getName();
if (srcFile.isDirectory()) {
File[] files = srcFile.listFiles();
if (files != null && files.length > 0) {
for (File f : files) {
zip(zipOutputStream, f, baseURL);
}
} else {
zipOutputStream.putNextEntry(new ZipEntry(baseURL + "/"));
}
} else {
zipOutputStream.putNextEntry(new ZipEntry(baseURL));
FileInputStream fileInputStream = null;
try {
//读数据
fileInputStream = new FileInputStream(srcFile);
byte[] bytes = new byte[1024];
int length = -1;
while ((length = fileInputStream.read(bytes)) != -1) {
zipOutputStream.write(bytes, 0, length);
}
} finally {
if (fileInputStream != null) {
fileInputStream.close();
}
}
}
}
public static void unzip(File srcFile, File targetFile) throws IOException {
FileInputStream fileInputStream = null;
ZipInputStream zipInputStream = null;
FileOutputStream fileOutputStream = null;
try {
fileInputStream = new FileInputStream(srcFile);
zipInputStream = new ZipInputStream(fileInputStream);
if (!targetFile.exists()) {
targetFile.mkdirs();
}
ZipEntry entry = zipInputStream.getNextEntry();
File tempFile;
while (entry != null) {
tempFile = new File(targetFile, entry.getName());
if (entry.isDirectory()) {
tempFile.mkdir();
} else {
tempFile.getParentFile().mkdirs();
fileOutputStream = new FileOutputStream(tempFile);
IOUtils.copy(zipInputStream, fileOutputStream);
}
entry = zipInputStream.getNextEntry();
}
} finally {
if (zipInputStream != null) {
zipInputStream.close();
}
if (fileInputStream != null) {
fileInputStream.close();
}
if (fileOutputStream != null) {
fileOutputStream.close();
}
}
}
public static void main(String[] args) {
File file = new File("C:\\ecmng\\site\\tmp\\test");
try {
//zip(file, new File("demo.zip"));
unzip(new File("demo.zip"), file);
} catch (IOException e) {
e.printStackTrace();
}
}
}
已有 0 人发表留言,猛击->>这里<<-参与讨论
ITeye推荐
- —软件人才免语言低担保 赴美带薪读研!—
最新技术文章: