Ubuntu 14.04 国内更新源

作者:Rui 发布时间:September 9, 2015 分类:Linux,CLOUD 浏览:807

1、备份源

# sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

2、编辑源文件/etc/apt/sources.list,并添加以下地址

# sudo gedit /etc/apt/sources.list

网易163源:

deb http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse 

搜狐源:

deb http://mirrors.sohu.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.sohu.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.sohu.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.sohu.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.sohu.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.sohu.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.sohu.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.sohu.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.sohu.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.sohu.com/ubuntu/ trusty-backports main restricted universe multiverse

oschina源:

deb http://mirrors.oschina.net/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.oschina.net/ubuntu/ trusty-backports main restricted universe multiverse
deb http://mirrors.oschina.net/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.oschina.net/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.oschina.net/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.oschina.net/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.oschina.net/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.oschina.net/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.oschina.net/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.oschina.net/ubuntu/ trusty-updates main restricted universe multiverse

3、 更新源索引,使新源生效

# sudo apt-get update

4、其他版本的源
只要将trusty 换成相应的版本的代号即可

更多国内源请参考:

http://wiki.ubuntu.org.cn/%E6%BA%90%E5%88%97%E8%A1%A8#Precise.2812.04.29.E7.89.88.E6.9C.AC

SSH Password-less login

作者:Rui 发布时间:September 9, 2015 分类:Linux,CLOUD 浏览:612

工作中有管理多台Linux主机,经常SSH远程登录其他主机,每次输入密码比较麻烦,SSH Password-less login 是解决这个问题比较好的方法之一。该文章记录一下SSH Password-less login 的具体使用步骤。

####设置环境

SSH client : 10.147.15.71
SSH Remote Login Server: 10.147.6.205

该示例中,我们要设置从 IP 71的服务器SSH 自动登录205的服务器

Step 1: 创建 Authentication SSH-Kegen Keys – (10.147.15.71)

# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/xp017734/.ssh/id_rsa): [Press enter key]
Created directory '/home/xp017734/.ssh'.
Enter passphrase (empty for no passphrase): [Press enter key]
Enter same passphrase again: [Press enter key]
Your identification has been saved in /home/xp017734/.ssh/id_rsa.
Your public key has been saved in /home/xp017734/.ssh/id_rsa.pub.
The key fingerprint is:
5f:ad:40:00:8a:d1:9b:99:b3:b0:f8:08:99:c3:ed:d3 xp017734@cbjlx9438
The key's randomart image is:
+--[ RSA 2048]----+
|        ..oooE.++|
|         o. o.o  |
|          ..   . |
|         o  . . o|
|        S .  . + |
|       . .    . o|
|      . o o    ..|
|       + +       |
|        +.       |
+-----------------+

阅读剩余部分...

How to run a Java program in a Docker container

作者:Rui 发布时间:September 9, 2015 分类:JAVA,Docker,CLOUD 浏览:625

In this post I’m going to show how to create a new Docker image from scratch, how to add the JDK, and how we can use this image to compile and run a Java program.

Creating the Image with the JDK

The first step is to create a new Docker image from the base Docker image ubuntu:14.04 and to install a JDK on top of that. We use a Dockerfile to provide the instructions to build such an image.
There is a link explaining how to Install Oracle Java 8 In Ubuntu Via PPA Repository [JDK8]. Basically we want to execute these commands in a Dockerfile.
The Dockerfile is simply as follows:

RUN apt-get update 
RUN apt-get install software-properties-common -y 
RUN add-apt-repository ppa:webupd8team/java -y 
RUN apt-get update 
RUN echo debconf shared/accepted-oracle-license-v1-1 select true | debconf-set-selections 
RUN apt-get install oracle-java8-installer -y 
RUN apt-get install oracle-java8-set-default 

It’s worth noting that we want the JDK installation to be automated (auto accept license) because the image is built in a not-interactive way and it wouldn’t be possible for us to manually accept the license during the JDK installation. This is done by the debconf-set-selections command. Now we just need to copy the Dockerfile above into a directory (in this article I’m using ~/dockertest) and run the docker build command:

~/dockertest$ docker build -t massimo/javatest:v1 .

阅读剩余部分...

如何在 Ubuntu上配置伪分布式Hadoop

作者:Rui 发布时间:August 28, 2015 分类:JAVA,Linux,BIGDATA 浏览:489

环境

  1. Ubuntu 12.04 TLS
  2. Oracle JDK 1.8
  3. Hadoop2.6.4

创建用户并设置SSH

创建用户

sudo useradd -m hadoop -s /bin/bash
sudo passwd hadoop 
sudo adduser hadoop sudo
sudo su - hadoop

SSH Password-less login setting

cd ~/.ssh/                     
ssh-keygen -t rsa             
cat ./id_rsa.pub >> ./authorized_keys  

环境变量设置

解压 Hadoop2.6.4 并将Hadoop-2.6.4 放到 /home/hadoop.

vim ~/.bashrc

在此文件中添加一下变量

export JAVA_HOME=/usr/lib/jvm/java-8-oracle
export HADOOP_HOME=/home/hadoop/hadoop-2.6.4
export PATH=$PATH:$HADOOP_HOME/sbin:$HADOOP_HOME/bin

阅读剩余部分...