CentOS配置静态IP

VirtualBox里安装CentOS,配置静态IP

(1)CentOS 6,修改/etc/sysconfig/network-scripts/ifcfg-eth0文件:

......
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.1.9
NETMASK=255.255.255.0
GATEWAY=192.168.1.1

(2)CentOS 7,修改/etc/sysconfig/network-scripts/ifcfg-enp0s3文件:

......
BOOTPROTO="static"
ONBOOT="yes"
IPADDR="192.168.1.5"
NETMASK="255.255.255.0"
GATEWAY="192.168.1.1"
DNS1="192.168.1.1"
DNS2="8.8.8.8"

 

使用LXC初体验

我使用的OSCentOS 7.1,需要安装lxclxc-templates。安装后的模板在/usr/share/lxc/templates目录下:

# ls
lxc-alpine    lxc-archlinux  lxc-centos  lxc-debian    lxc-fedora  lxc-openmandriva  lxc-oracle  lxc-sshd    lxc-ubuntu-cloud
lxc-altlinux  lxc-busybox    lxc-cirros  lxc-download  lxc-gentoo  lxc-opensuse      lxc-plamo   lxc-ubuntu

接下来以CentOS为模板创建一个container

lxc-create -t centos --name cn-centos

临时的root密码存在/var/lib/lxc/cn-01/tmp_root_pass

# cat /var/lib/lxc/cn-centos/tmp_root_pass
Root-cn-centos-EXb6bB

启动container

# lxc-start -n cn-centos

停止container

# lxc-stop -n cn-centos

参考资料:
Setup Linux Containers Using LXC On Ubuntu 15.04

 

搭建Scala开发环境

本文以CentOS 7为例,介绍如何搭建Scala开发环境:

(1)安装Scala :
执行“yum install scala”命令:

[root@localhost ~]# yum install scala
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.mirrors.tds.net
 * extras: bay.uchicago.edu
 * updates: dallas.tx.mirror.xygenhosting.com
Nothing to do

提示找不到Scala安装包,所以采用另外方式。使用wget命令直接下载:

[root@localhost ~]# wget http://downloads.typesafe.com/scala/2.11.6/scala-2.11.6.rpm
--2015-05-27 22:07:32--  http://downloads.typesafe.com/scala/2.11.6/scala-2.11.6.rpm
......
Length: 111919675 (107M) [application/octet-stream]
Saving to: ‘scala-2.11.6.rpm’

100%[=========================================================================>] 111,919,675  298KB/s   in 6m 15s

2015-05-27 22:13:48 (291 KB/s) - ‘scala-2.11.6.rpm’ saved [111919675/111919675]

接下来安装Scala

[root@localhost ~]# rpm -ivh scala-2.11.6.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:scala-2.11.6-0                   ################################# [100%]

安装成功,执行Scala

[root@localhost ~]# scala
/usr/bin/scala: line 23: java: command not found

运行Scala需要JRE支持,所以下一步安装Java环境。

(2)执行yum install java

[root@localhost ~]# yum install java
......
Complete!

(3)运行scala,打印“Hello world!”:

[root@localhost ~]# scala
Welcome to Scala version 2.11.6 (OpenJDK 64-Bit Server VM, Java 1.8.0_45).
Type in expressions to have them evaluated.
Type :help for more information.

scala> print("Hello world!")
Hello world!
scala> :quit

安装成功!