Dec 11, 2016
Technology在ubuntu14.04上搭建mesos时,需要安装jdk8或jdk9,然而官方仓库中没有类似的选项,
因而有两种work-around,第一种是手动安装jdk, 第二种是使用第三方库安装.
手动安装
下载安装包:
$ wget --header "Cookie: oraclelicense=accept-securebackup-cookie"
http://download.oracle.com/otn-pub/java/jdk/8u111-b14/jdk-8u111-linux-x64.tar.gz
如果是jdk9,则下载安装包为:
$ wget
http://www.java.net/download/java/jdk9/archive/140/binaries/jdk-9-ea+140_linux-x64_bin.tar.gz
下载完毕后,安装步骤如下:
$ sudo bash
# tar -zxf jdk-9-ea+140_linux-x64_bin.tar.gz -C /opt/jdk/
# update-alternatives --install /usr/bin/java java /opt/jdk/jdk-9/bin/java 100
# update-alternatives --install /usr/bin/javac javac /opt/jdk/jdk-9/bin/javac 100
# update-alternatives --display java
# update-alternatives --display javac
第三方库
激活ppa库如下:
$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update
$ sudo apt-get install oracle-java8-installer
$ sudo apt-get install oracle-java8-set-default
在安装过程中需要从oracle官方网站下载安装包,为了避免重复下载过程,可以将安装包直接拷贝到
/var/cache/oracle-jdk9-installer目录或者/var/cache/oracle-jdk8-installer目录。
Dec 9, 2016
TechnologySince the vagrant version and virtualbox version are too old in official
repository, we need to upgrade them for using the newest feature, following
are the tips.
Virtualbox
Manually Install
Download URL:
https://www.virtualbox.org/wiki/Downloads
Before installing the newest version, make sure you have uninstalled the old
version via `sudo apt-get purge virtualbox*".
Use dpkg for installing the virtualbox then using sudo apt-get -f install
for resolving the dependency issue.
After installed the virtualbox, use sudo /sbin/vboxconfig for building the
kernel module.
Use Repository
In Xenial, use following command for adding the repository:
$ sudo vim /etc/apt/sources.list
deb http://download.virtualbox.org/virtualbox/debian xenial contrib
$ wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
$ sudo apt-get update
$ sudo apt-get install -y virtualbox-5.1
Also use sudo /sbin/vboxconfig for solving the kernel module issue.
Vagrant
Download the newest version from:
https://www.vagrantup.com/downloads.html
Dec 7, 2016
TechnologyAfter updating vagrant, my vagrant could use, the error msg are listed as
following:
$ vagrant box list
Vagrant failed to initialize at a very early stage:
The plugins failed to initialize correctly. This may be due to manual
modifications made within the Vagrant home directory. Vagrant can
attempt to automatically correct this issue by running:
vagrant plugin repair
If Vagrant was recently updated, this error may be due to incompatible
versions of dependencies. To fix this problem please remove and re-install
all plugins. Vagrant can attempt to do this automatically by running:
vagrant plugin expunge --reinstall
I tried vagrant plugin repair and vagrant plugin expunge --reinstall but
both failed.
So , manually reinstall the vagrant-libvirt plugin:
$ CONFIGURE_ARGS='with-ldflags=-L/opt/vagrant/embedded/lib \
with-libvirt-include=/usr/include/libvirt with-libvirt-lib=/usr/lib' \
GEM_HOME=~/.vagrant.d/gems GEM_PATH=$GEM_HOME:/opt/vagrant/embedded/gems \
PATH=/opt/vagrant/embedded/bin:$PATH \
vagrant plugin install vagrant-libvirt
Installing the 'vagrant-libvirt' plugin. This can take a few minutes...
/opt/vagrant/embedded/lib/ruby/2.2.0/rubygems/dependency.rb:315:in `to_specs':
Could not find 'fog-core' (>= 0) among 44 total gem(s) (Gem::LoadError)
Checked in 'GEM_PATH=/opt/vagrant/embedded/gems', execute `gem env` for more
information
Seems we need to reinstall fog-core to vagrant’s GEM_PATH, use following
commands:
$ sudo pacman -S ruby
$ gem source -r https://rubygems.org
$ gem source -a http://rubygems.org
$ GEM_HOME=~/.vagrant.d/gems GEM_PATH=$GEM_HOME:/opt/vagrant/embedded/gems \
PATH=/opt/vagrant/embedded/bin:$PATH
$ sudo chmod 777 -R /opt/vagrant/embedded/gems
$ vim ~/.gemrc
gem: "--user-install"
+ install: --no-user-install
$ proxychains4 gem install --install-dir /opt/vagrant/embedded/gems/ fog-core
$ CONFIGURE_ARGS='with-ldflags=-L/opt/vagrant/embedded/lib \
with-libvirt-include=/usr/include/libvirt with-libvirt-lib=/usr/lib' \
GEM_HOME=~/.vagrant.d/gems GEM_PATH=$GEM_HOME:/opt/vagrant/embedded/gems \
PATH=/opt/vagrant/embedded/bin:$PATH \
vagrant plugin install vagrant-libvirt
$ vim ~/.gemrc
gem: "--user-install"
- install: --no-user-install
Now vagrant will work ok, verify it via:
$ vagrant box list
CentOS72ForKubernetes (virtualbox, 0)
CentOS72KVM (libvirt, 0)
CentOS72Kubernetes (virtualbox, 0)
fog-libvirt issue
When build fog-libvirt, we met:
domain.c:5696:29: error: ‘VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK’ undeclared (first use in this function)
INT2NUM(VIR_DOMAIN_QEMU_AGENT_COMMAND_BLOCK));
^
/opt/vagrant/embedded/include/ruby-2.2.0/ruby/ruby.h:241:30: note: in definition of macro ‘INT2FIX’
#define INT2FIX(i) (((VALUE)(i))<<1 | FIXNUM_FLAG)
Then the solution would be change the ld from :
# ln -fs /usr/bin/ld.gold /usr/bin/ld
# vagrant plugin install --plugin-version 0.0.3 fog-libvirt
# rm -f /usr/bin/ld
# ln -fs /usr/bin/ld.bfd /usr/bin/ld
Now you got the vagrant-libvirt working again.
Notice: This would be happend in vagrant-1.9.1
Dec 7, 2016
TechnologyThe script is listed as following, use python2 for running it:
from bs4 import BeautifulSoup
import urllib2
import re
## Pages contains the download page url
url_list = [
"https://support.citrix.com/search?searchQuery=%3F&lang=en&sort=cr_date_desc&ct=Hotfixes&ctcf=Recommended&prod=XenServer&pver=XenServer+6.2.0&st=0",
"https://support.citrix.com/search?searchQuery=%3F&lang=en&sort=cr_date_desc&ct=Hotfixes&ctcf=Recommended&prod=XenServer&pver=XenServer+6.2.0&st=10",
"https://support.citrix.com/search?searchQuery=%3F&lang=en&sort=cr_date_desc&ct=Hotfixes&ctcf=Recommended&prod=XenServer&pver=XenServer+6.2.0&st=20",
"https://support.citrix.com/search?searchQuery=%3F&lang=en&sort=cr_date_desc&ct=Hotfixes&ctcf=Recommended&prod=XenServer&pver=XenServer+6.2.0&st=30",
]
for url in url_list:
#response = urllib2.urlopen('https://support.citrix.com/search?searchQuery=%3F&lang=en&sort=cr_date_desc&ct=Hotfixes&ctcf=Recommended&prod=XenServer&pver=XenServer+6.2.0&st=0')
response = urllib2.urlopen(url)
### Fetch the urllib2 result.
html = response.read()
# print len(html)
### Make soup of the html.
soup = BeautifulSoup(html, 'html.parser')
# print soup.prettify()
### Get all of the download page link:
for i in soup.findAll('h4'):
for a in i.findAll('a'):
#print a['href']
page_response = urllib2.urlopen(a['href'])
page_html = page_response.read()
page_soup = BeautifulSoup(page_html, 'html.parser')
for elem in page_soup(text=re.compile(r"window.location.href")):
prefix = elem.string.find("supportkc")
#print prefix
url_begin_pos = elem.string.find("window.location.href") + 24
url_end_pos = elem.string.find("zip") + 3
if prefix > 0:
print "https://support.citrix.com"+elem.string[url_begin_pos:url_end_pos]
else:
print elem.string[url_begin_pos:url_end_pos]
The total patches are around 2G size.
The correct version:
from bs4 import BeautifulSoup
import urllib2
import re
## Pages contains the download page url
url_list = [
"https://support.citrix.com/search?searchQuery=%3F&lang=en&sort=cr_date_desc&ct=Hotfixes&ctcf=Recommended&prod=XenServer&pver=XenServer+6.2.0&st=0",
"https://support.citrix.com/search?searchQuery=%3F&lang=en&sort=cr_date_desc&ct=Hotfixes&ctcf=Recommended&prod=XenServer&pver=XenServer+6.2.0&st=10",
"https://support.citrix.com/search?searchQuery=%3F&lang=en&sort=cr_date_desc&ct=Hotfixes&ctcf=Recommended&prod=XenServer&pver=XenServer+6.2.0&st=20",
"https://support.citrix.com/search?searchQuery=%3F&lang=en&sort=cr_date_desc&ct=Hotfixes&ctcf=Recommended&prod=XenServer&pver=XenServer+6.2.0&st=30",
]
for url in url_list:
response = urllib2.urlopen(url)
### Fetch the urllib2 result.
html = response.read()
# print len(html)
### Make soup of the html.
soup = BeautifulSoup(html, 'html.parser')
# print soup.prettify()
### Get all of the download page link:
for i in soup.findAll('h4'):
for a in i.findAll('a'):
print a['href']
print a.text
page_response = urllib2.urlopen(a['href'])
page_html = page_response.read()
page_soup = BeautifulSoup(page_html, 'html.parser')
try:
print page_soup.findAll('blockquote')[1].text
except:
pass
else:
pass
try:
print page_soup.find_all('span',attrs={'class':'block-quote'})[1].text
except:
pass
else:
pass
for elem in page_soup(text=re.compile(r"window.location.href")):
prefix = elem.string.find("supportkc")
#print prefix
url_begin_pos = elem.string.find("window.location.href") + 24
url_end_pos = elem.string.find("zip") + 3
if prefix > 0:
print "https://support.citrix.com"+elem.string[url_begin_pos:url_end_pos]
else:
print elem.string[url_begin_pos:url_end_pos]
Manually get the result, and this time we get the uuid.
a tip for reverse the output is using tac rather than cat.
Dec 6, 2016
TechnologyFirst download the image from gcr.io:
$ sudo docker pull gcr.io/google-samples/cassandra:v11
Create a replicas using following yaml file:
apiVersion: v1
kind: ReplicationController
metadata:
name: cassandra
# The labels will be applied automatically
# from the labels in the pod template, if not set
# labels:
# app: cassandra
spec:
replicas: 1
# The selector will be applied automatically
# from the labels in the pod template, if not set.
# selector:
# app: cassandra
template:
metadata:
labels:
app: cassandra
spec:
containers:
- command:
- /run.sh
resources:
limits:
cpu: 0.5
env:
- name: MAX_HEAP_SIZE
value: 512M
- name: HEAP_NEWSIZE
value: 100M
- name: CASSANDRA_SEED_PROVIDER
value: "io.k8s.cassandra.KubernetesSeedProvider"
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
image: gcr.io/google-samples/cassandra:v11
name: cassandra
ports:
- containerPort: 7000
name: intra-node
- containerPort: 7001
name: tls-intra-node
- containerPort: 7199
name: jmx
- containerPort: 9042
name: cql
volumeMounts:
- mountPath: /cassandra_data
name: data
volumes:
- name: data
emptyDir: {}
Create rc:
$ kubectl create -f cassandra-controller.yaml
Also create a service using following yaml definition:
apiVersion: v1
kind: Service
metadata:
labels:
app: cassandra
name: cassandra
spec:
clusterIP: None
ports:
- port: 9042
selector:
app: cassandra
Start the service via:
$ kubectl create -f cassandra-service.yaml
Now scale the replica via:
$ kubectl scale rc cassandra --replicas=2
replicationcontroller "cassandra" scaled
Get the pods name and docker exec the command nodetool status to view the cassandra cluster status:
kubectl exec -ti cassandra-0px0a -- nodetool status
Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
-- Address Load Tokens Owns (effective) Host ID Rack
UN 172.17.0.5 65.61 KiB 32 100.0% fe61ce57-2a8b-462c-8fbf-12c69461f17c rack1
UN 172.17.0.6 84.76 KiB 32 100.0% c9b78b8c-f207-41f8-b3f7-d962dbebe687 rack1
Now scale the replicas to 4 and examine the result:
$ kubectl scale rc cassandra --replicas=4
replicationcontroller "cassandra" scaled
$ kubectl exec -ti cassandra-0px0a -- nodetool status
Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
-- Address Load Tokens Owns (effective) Host ID Rack
UN 172.17.0.5 65.61 KiB 32 50.8% fe61ce57-2a8b-462c-8fbf-12c69461f17c rack1
UN 172.17.0.7 48.33 KiB 32 40.0% 2b9fcbed-e737-496e-b960-d3d32b3091f5 rack1
UN 172.17.0.6 84.76 KiB 32 55.4% c9b78b8c-f207-41f8-b3f7-d962dbebe687 rack1
UN 172.17.0.8 58.09 KiB 32 53.8% 5ba29b11-7366-48d8-b3ed-ddefbd6f2e28 rack1
See now you could play happily with cassandra on kubernetes.