Create MySQL database and user (including MYSQLdump)
Posted: May 29, 2012 Filed under: Admin, MySQL | Tags: clone database, create user, Mysqldumb Leave a comment »IT IS NOT FINISHED YET
There are loads of ways to do this, Webmin, PHPmyadmin, MySQL GUI tools but if all you have is a Linux command line then you need the good old fashioned native MySQL commands
You will need mysql installed for this to work
yum install mysql
mysql -u (root user of database) -p -h (server name of MySQL database)
eg. mysql -u mysqlroot -p -h localhost
Once you have a command line then you need to create the user, you can also create the database whilst you are here
Create the database
create database (database name);
Now create the user
create user ‘username’@'localhost’ identified by ‘password’;
create user ‘username’@'%’ identified by ‘password’;
grant all priveleges on databasename.* to ‘username’@'localhost’ with grant option
grant all priveleges on databasename.* to ‘username’@'%’ with grant option
To create a mysql dump there are a few options, output to a sql file that then can be user to create the database or straight to the remote data base. Cloning to a remote database can be found in the Duplicate Sugar CRM instance
To create a sql file then
mysqldump -u (root name of mysql) –password=the password -h (host name of the server) > sqlfilename.sql
You can then link to the database that you wish to run the sql file into by using the following command.
mysql -u (root name of mysql) -p -h (host name of the server) < sqlfilename.sql
Installing Sugar CRM community Amazon EC2
Posted: May 19, 2012 Filed under: Amazon AWS, EC2, IT Survival, SugarCRM | Tags: Amazon AWS, EC2, SugarCRM Leave a comment »This is pretty simple and I will have to be doing it quite a lot in the next coming months, so this is more an aide de memoire
It is presumed that you already have a server with Apache and PHP installed. If not you need to yum apache and php.
At the time of writing we were looking at the RC2 release (brave I know
)
cd ~
mkdir software
cd software
wget http://downloads.sourceforge.net/project/sugarcrm/1%20-%20SugarCRM%206.5.0/SugarCommunityEdition-6.5.0/SugarCE-6.5.0RC2.zip
unzip SugarCE-6.5.0RC2.zip
mv SugarCE-Full-6.5.0RC2 /var/www/html/sugar65ce
I create this link so the URL can stay the same irrespective of the version
ln -s /var/www/html/sugar65ce/ crmcom
chown -R apache:apache sugar65ce/
cd sugar65ce
chmod 766 config.php
chmod 766 custom/
Web browse to the domian
http://domain-name.com/crmcom/install.php
Take all the default options, because of the chmod above you should get no errors
Provide all the database details when prompted ( I personally have called the database sugarcrm_com and we are also a professional user of CRM)
* * * * * cd /var/www/html/sugar65ce; php -f cron.php > /dev/null 2>&1
Blackberry BES Admin password does not work
Posted: May 16, 2012 Filed under: Amazon AWS, Blackberry Server, EC2, IT Survival Leave a comment »WOW
The Balckberry BES server certainly has some issues. The password for the Admin user failed to work. I know I got it correct as I use a choice of very secure password for my installs.
After much searching I discovered the prescribed way to get this back working is to re-install.
Well that was not going to happen. So I ran up another BES server and then just stole the password from the database that was encoded.
Please note that I am using the “BlackBerry Administration Service” for the authentication rules as per the installation of the BES server
If you are using the AD authentication there is a knowledge base here that will help you I think. I have not used it to reset the password, but I did use it successfully to generate a password. Blackberry KB18161
Back to you error though, this will work on BES 5.0 SP3 and Microsoft SQL 2005. I don’t think the SQL server has an effect but just so you know the versions.
Open up an SQL connection the BES SQL server, I use studio manager but as long as you have the SQL connection who cares.
This will update a user called Admin and set the password to blackberry
UPDATE BASUsers
SET LoginPassword = ‘D8BBFD88EB76EF129C4AA7C812AEB7664D2BE09B6D51D8555E0FC9F54515F88FC2F3BD209887BE064B0F2C11F7C9E6E86BA733667BA3BE4A459968FDB6DF8526:489F5C4B’
WHERE (LoginName = ‘Admin’)
This worked for me, there are other posts on forums but unfortunately the encrypted password does not work. RIM probably changed the encryption between releases.
Good luck and it does work
Alistair
Install S3Fuse and mount local disk Amazon EC2
Posted: May 11, 2012 Filed under: Amazon AWS, EC2, IT Survival | Tags: Amazon AWS, EC2, S3, S3cmd, S3Fuse, s3tools Leave a comment »There is a need to mount a S3 bucket to an EC2 server. Please NOTE that mounting drives should not be used in high read write environments. If all you want to do is push a backup to the disk because S3cmd will not do it for you then by all means use this. Do not use it for files that are server via a heavily used web server. (these are not my findings but from a startup company that I was talking to at the 2012 London AWS summit)
The install instructions for fuse are pretty concise so as per usual this will be about those little gotya’s (if that’s how you spell it
)
The are some pre-requisites as always but these are listed on the site. For S3Fuse installation instructions
So from the install instructions with some slight amendments of course
yum install gcc libstdc++-devel gcc-c++ fuse fuse-devel curl-devel libxml2-devel openssl-devel mailcap make
cd ~
mkdir software
cd software
As usual you need to get the latest stable release and at the time of writing 1.61.1 was stable
wget http://s3fs.googlecode.com/files/s3fs-1.61.tar.gz
tar xvzf s3fs-1.61.tar.gz
cd s3fs-1.61
./configure –prefix=/usr
make
make install
S3Fuse should now be installed. We need to test this now. So we need to mount a bucket to the server. You will need your Amazon AWS ID and secret. I am assuming that you know how to do this already but if you need a hint for the URL https://aws-portal.amazon.com/gp/aws/securityCredentials
You need to create a .passwd-s3fs file. This is best done as root as it should be stored in the home directory and should of course be secured done.
cd ~
echo accessKeyId:secretAccessKey > .passwd-s3fs
chmod 600 ~/.passwd-s3fs
to test mount a bucket you either need to know the bucket name or use s3cmd to list the bucket names etc… see installing and using s3cmd
Once you know which bucket you want to mount then
cd /mnt
mkdir bucketname - this is only a suggestion but it keeps it consistent and therefore easy to debug
then issue the s3fs commands
/usr/bin/s3fs mybucket /mnt -ouse_cache=/tmp
e.g.
the bucket name is call domainname-website-export so
(all s3 buckets as you know have to be unique and therefore I have adopted the practice of starting every bucket with the domain name)
cd /mnt
mkdir website-export
/usr/bin/s3fs -o allow_other domainname-website-export /mnt/website-export -ouse_cache=/tmp
NOTE the -o allow – makes the mounted directory accessible by other users of the server.
you should now be able to cd /mnt/website-export and create a file
Now to permanently mount the drive when the server boots up etc… the command for the fstab is as follows :
s3fs#bucketname /mnt/mount_folder fuse allow_other 0 0
e.g.
vi /ect/fstab
vi hint i
s3fs#domainname-website-export /mnt/website-export fuse allow_other 0 0
vi hint Esc :wq
mount -a
You should now have a mounted drive, that is accessible by any user of the server.
Instance reachability check failed
Posted: May 4, 2012 Filed under: Amazon AWS, EC2, IT Survival | Tags: Amazon AWS, EC2 Leave a comment »This is one error you do not want to see when you are booting up an EC2 instance the dreaded
Instance reachability check failed. Pass 0/2 checks or 1/2 check. Especially when this is you backup copy of a live system.
Believe me when I tell you that this strategy is being changed very quickly and S3 will be used for backup sets.
So how the hell do you fix this issue. Well if you are in the following situation all may not be lost.
This is based on the Ec2 instance being EBS backed if it is S3 then sorry not sure how you will get it working.
This method will allow you to get you data from the system and then allow you to rebuild the server, e.g. apache webserver.
This has worked on a Linux server, I have not tried it on a Windows server but it should work. Hopefully I will nerver have to try
Start by creating a disk volume from the snapshot
When the dialogue shows enter the details in terms of size. I made the volume the same size as the snapshot.
Make a note of the zone as you will need to launch an instance in this zone.
Yes to create the Volume.
Now Launch a new instance in the zone when the volume was created, this is where the micro instance come into their own. Once this is operational you need to attach the newly created volume to the instance.
Navigate to the volume screen and pick the volume, at the top of the screen use the drop down box to display Attach Volume and pick the newly created instance.
This will attach the volume to the server.
Log-on to the server, since this is Linux you need to mount the disk.
To make this complete and just in case you are a bit rusty, this is how you do this.
fdisk -l
will give you an output something like this
Disk /dev/xvda1: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0×00000000
Disk /dev/xvda1 doesn’t contain a valid partition table
Disk /dev/xvdf: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0×00000000
Disk /dev/xvdf doesn’t contain a valid partition table
The important line is the /dev/xvdf – this indicated the mounted volume
To mount the volume, as root (sudo su)
cd /
mkdir u10
mount -t ext4 /dev/xvfd /u10
Note if you get an error regarding the format change to ext3 or another disk format, but this should work.
You can now cd into u10 and you have access to the file system.
Good luck if this has happened to you
Alistair
Apache Virtual Host Configuration
Posted: April 30, 2012 Filed under: Apache, IT Survival, Linux 1 Comment »Arrrrrgggggghhhhh!!!!!!!
Linux and Apache great and frustrating all at the same time, how can this be !!!!!!!
Configuring an Apache server to run multiple web sites, nothing hard in that I hear you say.
For those who need a quick lesson, find the httpd.conf file and add lines of code at the end to mirror something like this.
httpd.conf is usually foounf in /etc/httpd/conf or /usr/local/apache2/conf depending on how it was installed.
To host multiple site you use the virtualhost parameters. So a simple site config is to host www.acmetest.com on the local server
<VirtualHost *:80>
ServerName www.acmetest.com
DocumentRoot /usr/local/apache2/htdocs/acme
<Directory “/usr/local/apache2/htdocs/acme”>
Options -Indexes +FollowSymLinks +ExecCGI
AllowOverride AuthConfig FileInfo
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
So you would think this would work, but the default web server was still serving out the index.html page. After 1 hour of trying to work out what is wrong with these few lines I remembered in the back of my addled brain SElinux.
At a command line
setenforce 0
Restart the web server and hey it WORKS!!!!
This is not advisable for production systems. There is more regarding how to allow Apache configuration and SELinux on the Centos Wiki. Navigate to Section 5.
I will be looking at further on a little later and let you know what the commands are to get a working site with SELinux enabled.
Port mirroring Cisco switches
Posted: April 13, 2012 Filed under: Cisco, IT Survival | Tags: cisco, port mirroring Leave a comment »To mirror a port i.e. pass traffic to another port so that it can be analised is different per Cisco switch but the basis is
Create a monitoring group
Tell one or more of the ports that it is the source
Tell one port that it is the destination.
Becareful here as this can increase load on the switch.
The command are as follows:
Cisco 2950
monitor session 1 source interface x/x both
monitor session 1 destination interface x/x
This puts the switch into monitoring mode, you can have more than 1 session also
To show what is being monitored
show monitor
To stop monitoring of 1 session or turn off completley
no monitor session x
no monitor
Install Wireshark Fedoracore
Posted: April 13, 2012 Filed under: General Admin, IT Survival, Linux | Tags: fedoracore, Wireshark Leave a comment »Been mucking around with Wireshark as we have an weird issue somewhere on the network
So decided to try to install Wireshark on Centos, this is still a work in progress, see my post. Decided to try the trusty Fedoracore distro instead.
For your info the distro is
cat /etc/redhat-release
Fedora release 16 (Verne)
uname -a
Linux wireshark-01.domainname 3.1.0-7.fc16.i686 #1 SMP Tue Nov 1 21:00:16 UTC 2011 i686 i686 i386 GNU/Linux
The server was yum updated straight after the build
There are some dependancies
yum install libGeoIP*
yum install libsmi*
Open the Add remove programs in the Xwindow and type wireshark. Selcet all the packages and apply
The last thing to do is
usermod -a -G wireshark _your_username_
Install Wireshark Centos
Posted: April 6, 2012 Filed under: General Admin, IT Survival, Linux | Tags: Centos, Wireshark Leave a comment »This is here because it still is not finished, but it is getting there
There is a post in Survival guides on how to install Wireshark on Ubuntu and is very much a flippant post. Here is how you do it from the source code as is sometime best.
Because this is from source we need the GCC libs and make. There are some packages that are required to compile the source also
I am installing this on Centos 5.5 updated with yum
yum install gcc gcc-c++ make bison flex libtiff-devel libjpeg-devel libcap-devel libpcap-devel libtiff-devel glib-devel
I got an issue when trying to install GTK+ as the server already had glib2-devel installed, if you get a glib-2 error then you will need to
yum erase glib2-devel
and then reinstall glib from the source again
NOTE yum grouplist – displays the lists of installations based on how the distribution is set-up
yum groupinstall “X Software Development”
export PKG_CONFIG_PATH=/usr/lib:/usr/local/lib/pkgconfig
cd ~
mkdir software
cd software
wget ftp://sourceware.org/pub/libffi/libffi-3.0.10.tar.gz
tar xzvf libffi-3.0.10.tar.gz
cd libffi-3.0.10
./configure
make
make install
cd ..
wget http://www.python.org/ftp/python/2.5.6/Python-2.5.6.tgz
tar xzvf Python-2.5.6.tgz
cd Python-2.5.6
./configure
make
make install
cd ..
I would recommend a reboot here especially if you un-installed the glib2-devel
wget http://ftp.gnome.org/pub/gnome/sources/glib/2.4/glib-2.4.8.tar.gz
tar xzvf glib-2.4.8.tar.gz
cd glib-2.4.8
./configure
make
make install
You can yum Pango but I got version 1 and the docs say install 1.2 is best, so install from source
cd ..
wget http://ftp.gnome.org/pub/GNOME/sources/pango/1.20/pango-1.20.5.tar.gz
tar xzvf pango-1.20.5.tar.gz
cd pango-1.20.5
./configure
make
make install
cd ..
For the next bit you need to unzip a .xz file. You need the zx package to do this
wget http://tukaani.org/xz/xz-5.0.3.tar.gz
tar xzvf xz-5.0.3.tar.gz
cd xz-5.0.3
./configure
make
make install
cd ..
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib
ldconfig
wget http://ftp.gnome.org/pub/gnome/sources/atk/2.4/atk-2.4.0.tar.xz
xz -d atk-2.4.0.tar.xz
tar xvf atk-2.4.0.tar
cd atk-2.4.0
./configure
make
make install
cd ..
wget http://ftp.gnome.org/pub/gnome/sources/gtk+/2.4/gtk+-2.4.14.tar.gz
tar xzvf gtk+-2.4.14.tar.gz
cd gtk+-2.4.14
./configure
make
make install
cd ..
wget http://wiresharkdownloads.riverbed.com/wireshark/src/wireshark-1.6.6.tar.bz2
bunzip2 -d wireshark-1.6.6.tar.bz2
tar xvf wireshark-1.6.6.tar
cd wireshark-1.6.6
./configure
make
make install
Install Oracle Express in Amazon AWS
Posted: April 3, 2012 Filed under: Amazon AWS, EC2, IT Survival | Tags: Amazon, AWS, Oracle Express 1 Comment »I took this configuration out of my Project.net installation as some of you may want to run Oracle express in Amazon for other things, the main reason that this was a little tricky is that the project software needs a constant host name and therefore the Oracle needs a little help
Launch an instance, and connect. You need to change the host name, to do this.
vi /etc/sysconfig/network
Change the host name line to
HOSTNAME= A FQDN
The network needs to be restarted
cd /etc/init.d
./network restart
Download the oracle xe express database from the Oracle web site, I have yet to figure out how to do this via a command line in Linux, so download via a web browser and then upload to the server, this can be done via the pscp.exe that is shipped with putty, there are loads of tutorials on the net that will tell you how to do this.
Once uploaded and as per usual I have created a software folder, and uploaded the rpm to this folder.
cd ~
mkdir software
You need a swap space on the server to allow Oracle to be installed this can be found at survivalguides create swap space written by yours truly.
Install Oracle XE via RPM or DEB depending on your Linux distribution
cd ~/software
service iptables stop
rpm -i oracle-xe-10.2.0.1-1.0.i386.rpm
Run “/etc/init.d/oracle-xe configure” to configure Oracle
Specify the HTTP port that will be used for Oracle Application Express [8080]:8080
Specify a port that will be used for the database listener [1521]:1521
Specify a password to be used for database accounts. Note that the same password will be used for SYS and SYSTEM. (* make sure you remember this password *)
Do you want Oracle Database 10g Express Edition to be started on boot (y/n) [y]: y
vi /etc/profile
Insert the following lines at the bottom
export ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server
export ORACLE_HOMEexport ORACLE_SID=XEexport NLS_LANG=AMERICAN.AL32UTF8
export PATH=$PATH:$ORACLE_HOME/bin
You need to run the profile to get the variables
. /etc/profile
Note the space between . /
It is also worth adding these lines to the .bashrc file in the home directory
service oracle-xe stop
Again an Amazon quirk is the localhost name so add the host name that was created at the start of the procedure to the hosts file.
vi /etc/hosts
service oracle-xe start
To test that this is a connection to the database use the standard Oracle test command
tnsping xe
You can also use the sqlplus client
sqlplus sys/(password for oracle)@xe as sysdba
This should give you an SQL prompt.
exit
This will get you out of the sqlplus client.
Once the server is restarted this will stop working, again another Amazon little gotya, this is because the IP address changes and so can the host name. To get around this you need to change the tnsnames.ora file to match the new name of the server.
vi /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/network/admin/tnsnames.ora
My tns file looks like this
# tnsnames.ora Network Configuration File:
XE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = project.acme.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = XE)
)
)
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
This is a read only file so you will need to use
:wq!
To save the file
You also need to change the listener.ora file as this also contains the host name of the server.
vi /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/network/admin/listener.ora
My file looks like this
# listener.ora Network Configuration File:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /usr/lib/oracle/xe/app/oracle/product/10.2.0/server)
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE))
(ADDRESS = (PROTOCOL = TCP)(HOST = project.acme.com)(PORT = 1521))
)
)
DEFAULT_SERVICE_LISTENER = (XE)
This is a read only file so you will need to use
:wq!
To save the file
You need to create the following file, to recreate the hosts file every time the server is rebooted, this will allow the oracle to work properly.
The script file I called createhostfile.ksh and the contents is
#!/bin/bash
getip=`/sbin/ifconfig eth0 | grep ‘inet addr’ | awk ‘{print $2}’ | sed -e ‘s/.*://’`
newhost=”${getip} project.acme.com“
rm -f /etc/hosts
echo “127.0.0.1 localhost localhost.localdomain” > /etc/hosts
echo $newhost >> /etc/hosts
Note that I called my server project, you will need to replace this with what you have call your server.
To create the file
cd /etc
vi createhostfile.ksh
paste the script above
chmod 755 createhostfile.ksh
Now we can change the oracle-xe file that is used to start and stop oracle.
vi /etc/init.d/oracle-xe
After all of the comment insert the following line
/etc/createhostfile.ksh
This will call the host file creating every time that oracle is started.



