Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Mar 23, 2015

Strange Supervisorctl Problem: unix:///tmp/supervisor.sock no such file

I am using supevisord which is a great tool to spawn processes
http://supervisord.org/running.html

When I get things configured, I run supervisor with the command below:
supervisord -c /etc/supervisord.conf

Supervisor runs successfully and I can see programs got started, but when I check processes using
supervisorctl status

I got an strange error as below:


I tried several solutions for example change supervisord.conf ot use http socket

It even reported an refuse connection error.
supervisorctl status http://127.0.0.1:9001 refused connection.

I searched a lot and finally got the solution.

Problem:
I was using a old version of supervisord.conf file, people who work on clusters and do maintenance work often do this. But the problem happend because I did a fresh install of supervisord, and copied a supervisord.conf from another machine. The install is the latest version, and the copied one is old, which caused the problem.

The solution is very simple:


echo_supervisord_conf > /etc/supervisord.conf
#modify supervisord.conf, after it's done
sudo supervisord -c /etc/supervisord.conf
sudo supervisorctl status



The first line generates a new supervisord.conf which is a template, and then you can modify with the programs you want to start. And then start supervisord and check status. The result is good.


If you find this article is useful, please click the ads on this page to help. Thank you very much.

Jan 26, 2014

How to configure static network IP address in Linux

Sometimes in Linux we need to have a static IP address, for example to install a Hadoop cluster, this is a recommended step. Though in windows it can be done graphically, in Linux it has an interesting way to do through a few commands. Let's take a look.

Part One: configure a static IP address in a physical machine
Note: here a physical machine I mean a machine that installs Linux OS directly, rather than a virtual machine.
Also almost all operations here need a sudo access, so we can sudo to an qualified account or add sudo ahead to each of the command.
1. view or edit 70-persistent-net-rules file
open a terminal, type
cat /etc/udev/rules.d/70-persistent-net-rules



By default, the name will be eth0, which means it will use a file name "ifcfg-eth0" to control the network settings,  but you can also let it use a new control file, say for example eth1. This can be done by in terminal, type
vim /etc/udev/rules.d/70-persistent-net-rules

and modify the name value to eth1.

2. Modify a configuration file
cd /etc/sysconfig/network-scripts
ls


You will see a file named ifcfg-eth0, which is the network configuration file as we mentioned earlier.
If you step1 you configured it to use a new file for example eth1, then you need to create a new configuration file:


vim ifcfg-eth1

Please configure it like below.

Note:
1). NM_CONTROLLED must set to no, so that it's not controlled by a service called NetworkManager
2) BOOTPROTO value is static, because it's a static IP. If it's controlled by NetworkManager, the value is dhcp
3) Add the entry for GATEWAY, IPADDR, and DNS here. If you have multiple DNS, you can put DNS1=...; DNS2=...; if you have only one DNS, you just put DNS1=....
4) People might have question that how I can know what values I can input in step 3. Here are two commands that we can use: ifconfig and route

3. Add DNS IP information in /etc/resolv.conf
vim /etc/resolv.conf


4. Persistent the configuration
1) We want to stop NetworkManager, so that the IP is set as we input and will not be changed by the service.
service NetworkManager stop

2) Make service NetworkManager by default not started when reboot system
chkconfig NetworkManager off

3) If you are using a new control file, for example in step 1 you want it to use eth1, and the original one is eth0. We need to bring down eth0 and bring up eth1
ifdown eth0

ifup eth1

4) restart network service
service network restart

5) if in step 3 or 4 you met some errors for example saying eth1 cannot be initialized. please reboot the system
reboot


Now you will have a static IP successfully configured.

Part Two:  configure a static IP address in a VMware virtual machine
configure a static IP in virtual machine is similar as doing it in physical machine, but there are a few differences.
Step 1. Same as step 1 in part one
Difference: In case you run vim /etc/udev/rules.d/70-persistent-net.rules and get the result as below. You may not know which is the right one to change.

Here you need to check in VMware your virtual machine settings by
right click your virtual machine name --> Network Adapter --> Advanced
It will show the MAC address, comparing it with the result above, now you will now it's the second one to modify.

Step 2: the same as Step 2 in part one
Difference: VMware NAT settings by default use 192.168.136.2 as the DNS and GATEWAY


so your configuration setting can be like below

Step 3: the same as Step 3 in part one
Step 4: the same

OK. All set!

If you find this blog is useful, please kindly click the ads on this page to help. Thank you very much.

Dec 17, 2013

How to install Chrome on CentOS 6.4 and 6.5

I have been always using Chrome, and even I am quite new to linux, I still want to use Chrome even it's not supported in CentOS 6.4 and 6.5, and below are the steps.

First of all, thanks to Rihard, he provides a script to install Chrome, which does 99.9% of the work. It's great!
 http://chrome.richardlloyd.org.uk/

But when I use the script, I still met some problems, maybe it's because I am using the company's internet proxy, or because in China, we cannot access some websites due to great firewall. Anyway, I need to do something to finish the 0.1% work left.

Step1: Follow the instructions here: http://chrome.richardlloyd.org.uk/ , download install_chrome.sh (http://chrome.richardlloyd.org.uk/install_chrome.sh)

Step2: It's better that you switch to root account to run the script, or use sudo ./install_chrome.sh. Assume you are running a root account:

chmod u+x install_chrome.sh
./install_chrome.sh

In this step, I met several problems:
a. connection to https://dl.google.com failed...
I solved this by using a no proxy internet. In our company, we always using proxy. But the connection just failed, so I run the command at home where no proxy is used.

b. download is very slow as shown in the screenshot below

The time estimation goes up to several hours and the progress always hung.
I solved this by using Ctrl C to stop the ./install_chrome.sh, and run this command again. Sometimes it hang at another package, but tried several times, the installation succeeded.


Note for CentOS 6.4: In CentOS 6.4, I see the script installed successfully. But when I click the icon, nothing happened. Then I open a terminal:

cd /usr/bin
./google-chrome

It shows the error:
[sai@localhost bin]$ ./google-chrome
./google-chrome: /usr/lib64/libnss3.so: version `NSS_3.14.3' not found (required by ./google-chrome)

I tried to follow the instructions here but didn't work.
http://www.linuxquestions.org/questions/slackware-14/google-chrome-30-error-nss-4-13-5-upgrade-4175482053/

What I did to solve this problem is: 
I searched and find a link here:
And I download and installed it. Now the problem solved. 

[Update on 2014/2/25] Sorry I didn't know the package link will be removed so I didn't save a copy of the package. I tried to find one and put it in the share folder below. Please try it and let me know whether it works for you:
https://drive.google.com/file/d/0B_ZDNNkWG1dYVXpHeDBwaHNBTXc/edit?usp=sharing
Last but not least, 
to uninstall Chrome, please run:
./install_chrome.sh -u

to update Chrome, please run:
sudo yum update google-chrome-stable



If you find this blog is useful, please kindly click the ads on this page to help. Thank you very much.

Oct 11, 2013

[Solved] How to Change and Config Yum Repository Source in RedHat 6 (No Package Available Problem)

I am using Red Hat Enterprise Linux Workstation 6.1, as it is a enterprise version. When I tried to install a software, for example I run: yum install vim
It returns that I "No package vim available".

I run:
1. cd  /ect/yum.repos.d
2. ls
The redhat.repo is empty.

Only after got a valid license, it will have the right value. For people don't have purchased a license, I have to find a way to config another source. Fortunately I figured out how to do it.

Then general solution is to:

  1. Unistall the original yum in Red Hat 
  2. Download yum rpm packages 
  3. Install Yum 
  4. Config Repository Source
  5. Run Yum and Test Install
The following are the details. 

1. Uninstall The Original Yum in Red Hat

rpm -aq|grep yum|xargs rpm -e --nodeps

2. Download yum rpm packages
You can manually go to the URL http://mirrors.163.com/centos/6/os/x86_64/Packages/ to find what's the right package version:

I have done this and find out them, so run these commands in terminal:

wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-3.2.29-40.el6.centos.noarch.rpm

wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm

wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm

wget http://mirrors.163.com/centos/6/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm

3. Install Yum


rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpm
rpm -ivh yum-metadata-parser-1.1.2-16.el6.x86_64.rpm 
rpm -ivh yum-3.2.29-40.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm

Please notice that the in the last command it installs two packages together, because the two packages have dependencies on each other.

4. Update the repo configuration
a. cd /etc/yum.repos.h
b. backup original redhat.repo
mv redhat.repo redhat.repo.repo.bak
c. download a copy of CentOS repo, for example our version is verson 6
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
d. modify CentOS6-base-163.repo
vi CentOS6-Base-163.repo

the repo file contains 5 sections: [base], [updates], [exras], [centoplus], [contrib]

For each section, you need to replace with the the values in your environment
$releaserver means the version, in our case it's 6
$basearch means which branch, in our case it's x86_64, (another branch is i386

Modify each of the 5 sections.

The result looks like below:

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#

[base]
name=CentOS-$releasever - Base - 163.com
baseurl=http://mirrors.163.com/centos/6/os/x86_64
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=os
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#released updates
[updates]
name=CentOS-$releasever - Updates - 163.com
baseurl=http://mirrors.163.com/centos/6/updates/x86_64
                                                           
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - 163.com
baseurl=http://mirrors.163.com/centos/6/extras/x86_64/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=extras
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - 163.com
baseurl=http://mirrors.163.com/centos/6/centosplus/x86_64/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - 163.com
baseurl=http://mirrors.163.com/centos/6/contrib/x86_64/
#mirrorlist=http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=contrib
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6


f. the last step is to replace the original redhat.repo
mv CentOS6-Base-163.repo redhat.repo

[Note] In my case, I am using the mirror located in China which is hosted by Netease (163), people can also use the website http://mirrors.fedoraproject.org/publiclist/ to find one that good for yourself.
For example http://mirror.overthewire.com.au/pub/centos/6/
It has the same structure.

5. Run Yum and Test Install
run yum:
yum clean all

test install
yum install vim


hallelujah!

If you think this article is useful, please click the ads on this page to help. Thank you very much.