Posts tagged CentOS

Linux Logo

Linux – CentOS – SELinux – Cannot Start httpd – Permission to httpd.conf Denied

0

If you are attempting to start apache (httpd) and get permission denied errors, chances are your SELinux is enabled, and not configured to allow httpd connections. Use the following commands to get your httpd working.

# To view current selinux settings related to httpd:
getsebool -a | fgrep -i httpd

# To "pinhole" SELinux to allow httpd to start correctly:
setsebool -P httpd_can_network_connect 1
setsebool -P httpd_enable_homedirs 1

Linux – CentOS6 – Ruby – It seems your ruby installation is missing psych

0

If you are compiling ruby from source on a CentOS box, you may come across a “it seems your ruby installation is missing psych” message. To fix this issue you will also need to compile libyaml. If you installed libyaml to a custom directory you will need to let ruby know during configuration:

 ./configure --prefix=/usr/local/_custom/app/ruby --with-opt-dir=/usr/local/_custom/app/libyaml/

Now, after you have done `make && make install` you should be able to run ruby without the error message.

Linux – CentOS6 – Adding or Updating Custom Gateway

0

Just started working with CentOS6 and came across an issue where I found it difficult to add a gateway for my eth0 interface. The netinstall I conducted didn’t appear to have an entry area for it (or I may have missed it). If you need to add or update your gateway do the following:

vi /etc/sysconfig/network
NETWORKING=yes
GATEWAY=192.168.0.254
/etc/init.d/network restart

Now your gateway should be working as expected.

Linux – CentOS – 6 – Installing Percona MySQL

0

If you are looking to install Percona MySQL on a CentOS 6 server, you will need to install the ‘Percona-Server-shared-compat.x86_64′ package, if you don’t, you will end up with errors when installing the ‘Percona-Server-server-55.x86_64′ package.

MySQL – Percona – Setting Character Sets and Collations to UTF8

0

This morning I was reinstalling Percona-Server-server (v5.5.13) via Yum on my CentOS box and decided to dig into the my.cnf file a bit and make sure I had everything setup correctly. Lo and behold, I did not. I noticed that a few of my charset and collation settings were using latin1 when they should have been using UTF8.

Being a DBA newb, I tried to set server variables like ‘character_set_database’ only to see the following error messages: “110726 20:24:04 [ERROR] /usr/sbin/mysqld: unknown variable ‘character_set_database=utf8′”. I read the docs on mysql.com @ http://dev.mysql.com/doc/refman/5.5/en/server-system-variables.html#sysvar_character_set_database and couldn’t see what the problem was. It was listed as a ‘Global’ option, however if you scroll up to “Table 5.2″ you will notice that character_set_database cmd-line option is blank, which I assume means it cannot be set via the my.cnf file. I believe this setting can be set during ‘CREATE DATABASE’ commands, but I didn’t want to have to do this every time I created a database.

So I did some toying around and found the ‘character_set_server’ and ‘collation_server’ settings will actually control the children settings (database, table, etc). So all you have to do to ensure consistent utf8 for your mysql server is to add the following to your my.cnf file:


character_set_server = utf8
collation_server = utf8_general_ci

Be sure to restart the daemon, then you can issue the following commands:


# Show me collation settings

mpurcell@dev1 ~ $ -> mysql -e "show variables" -u mpurcell -p | fgrep -i collat
Enter password:
collation_connection    utf8_general_ci
collation_database      utf8_general_ci
collation_server        utf8_general_ci

# Show me charset settings
mpurcell@dev1 ~ $ -> mysql -e "show variables" -u mpurcell  -p | fgrep -i char
Enter password:
character_set_client    utf8
character_set_connection    utf8
character_set_database    utf8
character_set_filesystem    binary
character_set_results    utf8
character_set_server    utf8
character_set_system    utf8
character_sets_dir    /usr/share/mysql/charsets/

Now your mysql server is setup to store and collate in UTF8.

Linux – CentOS – No acceptable C compiler found in $PATH

2

If you attempt to compile an application from source and run into a ‘no acceptable C compiler found in $PATH’ on a CentOS system, just run:

yum install gcc

Linux – CentOS – Unable to Set Timezone

2

This morning I had a weird issue on one of my production boxes. I did a ‘date’ and noticed that the timezone was EDT, when it should be UTC. So I changed the timezone to UTC by:

rm -f /etc/localtime

ln -sf /usr/share/zoneinfo/UTC /etc/localtime

Now when I did ‘date’, I still saw the timezone was EDT, when it should have been UTC. I was directed by the hosting company to reinstall the ‘tzdata’ package, so I did, and then redid the steps to change timezone:

yum reinstall tzdata

rm -f /etc/localtime

ln -sf /usr/share/zoneinfo/UTC /etc/localtime

Now, when I do ‘date’, it shows the correct date/time.

Just wanted to put it out there in case anyone else has the same issue.

Linux – Install Memcached on CentOS

0

According to http://memcached.org/, Memcached is a “distributed memory object caching system”. What this means is that memcached will return stored values from memory rather than other storage mediums such as disk or database. How do you access these values? Well, depending upon the key construct you used, you just need to provide the memcached with the proper key and you will gain access to stored values (also known as a key-value pair).

Memcached provides a layer which sits between your application and your backend storage solution. What memcached does is allow you, the developer, to store commonly retrieved data into the cache layer so subsequent requests will use the cache version rather than querying your database or pinging your filesystem. As you can probably tell, this is a much faster solution and reduces the resources needed by your databases.

There is a lot of power that memcached provides, but as a developer you need to ensure your app can correctly harness this power. What I mean by this is; imagine you update a value in your database, then through your application you submit a form to confirm the value has indeed been changed, but for some reason you keep seeing the old value. Guess what? Your old value was cached and you optimized your application to use cache before hitting the database. As a developer you need to create a method of clearing cache when needed so you don’t bang your head on the desk trying to figure out why values you changed are not being respected by your application.

Now that you have a basic understanding of what memcached does, lets install it on your centos system.

Memcached is not available to your system by default (via YUM), you will have to gain access to rpmforge (a collection of rpms). If you don’t have rpmforge setup, follow this guide: http://melikedev.com/2010/03/10/centos-basic-usage-guide/ in the section RPMForge.

Now that you have rpmforge setup you should be able to get access to memcached. Try:

yum list memcached

If all looks good, then go ahead and install:

yum install memcached

It should also install about 10 more dependencies all from rpmforge, but shouldn’t have any negative impact on your system. When that’s finished you now have memcached installed on your system.

Now it’s time to configure. First we want to add a user to the system so we can run the memcached(aemon) as a non-root user:

adduser memcached

Now we can edit memcached settings:


# /etc/sysconfig/memcached

PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="64"
OPTIONS=""

Now you should be able to start your memcached server:

sudo -u memcached /etc/init.d/memcached start

If you get an permission related error regarding the lock file, you will have to ensure that the memcached user can write the log file to /var/lock/subsys (This lock file ensures you don’t run multiple memcacheds at the sametime). What I did is:


chown root:daemon /var/lock/subsys #allow daemon group, group control over subsys

chmod 775 /var/lock/subsys #make subsys dir writable by group owner

You can now test your memcached server by following these steps outlined here: http://melikedev.com/category/memcache/.

Now that you have an up and running cache server you should develop a caching class within your app that will access your memcached server so you can save commonly run query results within the caching layer. Don’t get carried away though, try to be strategic about what you are populating your cache with, and don’t forget to develop some mechanism for clearing cache when needed.

Good luck.

CentosLogo

CentOS – Basic Usage Guide

1

This post will house basic usage commands for CentOS 5.4. It is a ‘living doc’, meaning that it will be updated over time so bookmark if interested.

YUM

Yum is the package manager built into CentOS distros and by package manager I don’t mean your local delivery guy, I mean how you can install, update, and remove software packages from your system.  Listed here are YUM commands you may find useful.

Update package repo:

yum update

View installed packages:

rpm -qa
#OR
yum list installed

View available updates:

yum list updates

Remove existing i386 apps from x64 system (USE WITH CAUTION!)


yum list installed | fgrep i386 > tmp.txt

yum remove $(awk '{print $1}' tmp.txt | xargs)

To only install 64 bit apps, add following line to /etc/yum.conf:

exclude=*.i386 *.i586 *.i686

Install yum-utils. (Useful set of utilities including package-cleanup)

su -c 'yum install yum-utils'

If you ever get a “missing dependency” error when trying to update a package via yum, check to make sure you have the right version installed (i686 vs x86_64). I had this issue when trying to update glibc-common. It wouldn’t update because the version of glibc was i686, which I explicitly removed via the yum.conf file (explained above).

yum list <package name>

Remove a package:

yum remove <package name>

Check available updates:

 yum check-update

Misc

Check CentOS version:

cat /etc/redhat-release

Reboot:

reboot

Delete User (-r will remove home dir):

userdel -r <username>

If user is logged in, force log them out:

pkill -KILL -u <username>

Change timezone:

Note: Personally, I highly recommend you set your system's local timezone to UTC. This will avoid any issues where some logs are in UTC, some are in local time, and will ensure a consistent time construct across all apps and modules such as php and mysql. Not to mention if you happen to move the server to a different timezone...


sudo rm /etc/localtime

sudo ln -s /usr/share/zoneinfo/UTC /etc/localtime

RPMForge

If you need to install apps like irssi you will have to use rpmforge repo. To install follow the instructions @ http://wiki.centos.org/AdditionalResources/Repositories/RPMForge

To keep your system as pristine as possible, I would edit the /etc/yum.repos.d/rpmforge.repo file and change enabled=1 to enabled=0. This will ensure you are not overriding centos approved packages with newer rpmforge packages. To install a package that resided in rpmforge only, do the following:

yum install <some_package> --enablerepo=rpmforge

This will allow you to use rpmforge on a case-by-case basis giving you much more control over what gets onto your system.

IRSSI

In order to get irssi to work on centos you may have to create a symlink:


cd /usr/lib64

ln -s perl5/5.8.8/x86_64-linux-thread-multi/CORE/libperl.so

IPTables

If you are running httpd and can't connect, try disabling IPTables:

/etc/init.d/iptables stop

SELinux

Determine if SELinux is currently running:

sestatus
Go to Top